Skip to content

Instantly share code, notes, and snippets.

@jhealey5
jhealey5 / Revealer.vue
Created December 20, 2018 17:51
reveal on scroll
<script>
export default {
props: ['offset', 'trigger'],
methods: {
checkPos() {
let current_top = this.$el.getBoundingClientRect().top;
if (current_top <= this.reveal_point) {
@jhealey5
jhealey5 / getPercentage.js
Created December 19, 2018 07:48
Gets scrolled percentage of page relative to element
getPercentage(){
let wh = window.innerHeight,
scroll = window.pageYOffset,
height = this.$el.offsetHeight,
top = this.$el.getBoundingClientRect().top + scroll;
let distance = (scroll) - top;
let percentage = distance / ((height - wh - 180) / 100);
return Math.max(Math.min(Math.round(percentage), 100), 0);
<script>
import { TweenMax, ScrollToPlugin } from 'gsap/all';
export default {
props: ['offset'],
name: 'ScrollTo',
mounted(){
this.$el.addEventListener('click', this.scroll);
@jhealey5
jhealey5 / Tags.php
Created December 14, 2018 10:39
Loads cms images/svgs inline
public function image()
{
$img = Asset::find($this->getParam('id'));
$retina = $this->getParam('retina');
if ($img->extension() == 'svg') {
return File::get($img->resolvedPath());
}
$width = $retina ? $img->width() / 2 : $img->width();
public function svg()
{
$name = $this->getParam('name');
$path = '/site/themes/big/dist/images/' . $name . '.svg';
if (FILE::exists($path)) {
return File::get($path);
}
}
@jhealey5
jhealey5 / functions-social.php
Created December 21, 2017 08:46
spotify-fetch.php
// Spotify API
function Spotify($url) {
$API_ID = '';
$API_SECRET = '';
function getToken($id, $secret){
$url = 'https://accounts.spotify.com/api/token?grant_type=client_credentials';
@jhealey5
jhealey5 / next-prev-post.php
Created February 15, 2017 11:59
next-prev-post
<?php
$prev_id = get_adjacent_post(false, '', true)->ID;
$previous_post_title = get_the_title( $prev_id );
$previous_post_url = get_permalink( $prev_id );
$next_id = get_adjacent_post(false, '', false)->ID;
$next_post_title = get_the_title( $next_id );
$next_post_url = get_permalink( $next_id );
?>
<?php if ($prev_id !== $product->ID && $previous_post_url): ?>
/**
* Add Join to search query
* Part 1 of 3 part functions to add ACF fields to search page results
*
* @param $join
* @return mixed
*/
function acf_search_join( $join ) {
global $wpdb;
if ( is_search() && is_main_query() ) {
function time_ago($time) {
$time = isValidTimeStamp($time) ? $time : strtotime($time);
$periods = array("second", "min", "hr", "d", "w", "m", "y", "decade");
$lengths = array("60","60","24","7","4.35","12","10");
$now = time();
$difference = $now - $time;
$tense = "ago";
@jhealey5
jhealey5 / noscroll.js
Created February 26, 2016 09:07
No Scroll
// NoScroll https://github.com/davidtheclark/no-scroll
(function(root) {
var scrollbarSize;
function getScrollbarSize() {
if (typeof scrollbarSize !== 'undefined') return scrollbarSize;
var doc = document.documentElement;
var dummyScroller = document.createElement('div');
dummyScroller.setAttribute('style', 'width:99px;height:99px;'