function debounce(func, wait = 10, immediate = true) {
let timeout;
return function() {
let context = this, args = arguments;
let later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
};
let callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) func.apply(context, args);
};
};
let scrollPos = 0;
const nav = document.querySelector('.site-nav');
function checkPosition() {
let windowY = window.scrollY;
if (windowY < scrollPos) {
nav.classList.add('is-visible');
nav.classList.remove('is-hidden');
} else {
nav.classList.add('is-hidden');
nav.classList.remove('is-visible');
}
scrollPos = windowY;
}
window.addEventListener('scroll', debounce(checkPosition));
/scss/mixins/_buttons.scss
@mixin button-variant(
$background,
$border,
$change,
$btn-hover-change-bg,
$btn-hover-change-border,
$btn-active-change-bg,
$btn-active-change-border) {
@if $change == "darken" {
$hover-bg: darken($background, $btn-hover-change-bg);
$hover-border: darken($border, $btn-hover-change-border);
$active-bg: darken($background, $btn-active-change-bg);
$active-bg: darken($border, $btn-active-change-border);
} else {
$hover-bg: lighten($background, $btn-hover-change-bg);
$hover-border: lighten($border, $btn-hover-change-border);
$active-bg: lighten($background, $btn-active-change-bg);
$active-bg: lighten($border, $btn-active-change-border);
}
...
}
}