Skip to content

Instantly share code, notes, and snippets.

View wiseoldman's full-sized avatar
🔥

Phil. wiseoldman

🔥
View GitHub Profile
@wiseoldman
wiseoldman / NavigationScrollHandler.js
Last active March 12, 2019 09:43
[NavigationScrollHandler] Add a class to the navigation when scrolling X pixels using requestAnimationFrame for better performance. The snippet also handles fixed navigations with the WordPress admin-bar #navigation
class NavigationScrollHandler {
constructor({ scrollDistance = 100, onEnter = () => {}, onExit = () => {}, headerElement = false } = {}) {
this.onEnter = onEnter;
this.onExit = onExit;
this.scrollDistance = scrollDistance;
this.headerElement = headerElement;
this.visibleAdminBar = document.querySelector('body.admin-bar');
this.lastKnownScrollY = 0;
this.ticking = false;
@wiseoldman
wiseoldman / arrows.scss
Created April 11, 2018 09:46
[Line arrow mixin] Line arrow mixin for scss #arrow
@mixin arrow($line-width:4px, $size:4px, $color:#000, $direction:down) {
border: solid $color;
border-width: 0 $line-width $line-width 0;
display: inline-block;
padding: $size;
margin-top: -$size;
@if $direction == down {
transform: rotate(45deg);
} @else if $direction == up {
@wiseoldman
wiseoldman / social-share.js
Last active April 11, 2018 09:47
[Social sharing] Social sharing functionality #social
function socialShare (e) {
e.preventDefault();
const href = this.getAttribute('href');
const options = 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,';
const network = this.getAttribute('data-network');
const networks = {
facebook: { width: 600, height: 300 },
twitter: { width: 600, height: 254 },
google: { width: 515, height: 490 },