2019-08-15 17:40:13 +00:00
|
|
|
/*
|
|
|
|
* Scroll up Header
|
|
|
|
* Modified from https://codepen.io/sajjad/pen/vgEZNy
|
2019-08-19 04:24:40 +00:00
|
|
|
* TODO: Convert to Vanilla JS
|
2019-08-15 17:40:13 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
// Hide header on scroll down
|
|
|
|
var didScroll;
|
|
|
|
var lastScrollTop = 0;
|
2019-10-07 22:13:09 +00:00
|
|
|
var delta = 10;
|
2019-08-15 17:40:13 +00:00
|
|
|
var navbarHeight = $('.mw-header-container').outerHeight();
|
|
|
|
|
|
|
|
$(window).scroll(function(event){
|
|
|
|
didScroll = true;
|
|
|
|
});
|
|
|
|
|
|
|
|
setInterval(function() {
|
|
|
|
if (didScroll) {
|
|
|
|
hasScrolled();
|
|
|
|
didScroll = false;
|
|
|
|
}
|
|
|
|
}, 250);
|
|
|
|
|
|
|
|
function hasScrolled() {
|
|
|
|
var st = $(this).scrollTop();
|
|
|
|
|
|
|
|
// Make scroll more than delta
|
|
|
|
if(Math.abs(lastScrollTop - st) <= delta)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// If scrolled down and past the navbar, add class .nav-up.
|
|
|
|
if (st > lastScrollTop && st > navbarHeight){
|
|
|
|
// Scroll Down
|
|
|
|
$('header').removeClass('nav-down').addClass('nav-up');
|
|
|
|
} else {
|
|
|
|
// Scroll Up
|
|
|
|
if(st + $(window).height() < $(document).height()) {
|
|
|
|
$('header').removeClass('nav-up').addClass('nav-down');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
lastScrollTop = st;
|
|
|
|
}
|