spacing fixes

This commit is contained in:
alistair3149 2019-10-08 15:22:02 -04:00
parent 9875f6d759
commit 21b26a6509

View file

@ -1,8 +1,8 @@
/* /*
* Scroll up Header * Scroll up Header
* Modified from https://codepen.io/sajjad/pen/vgEZNy * Modified from https://codepen.io/sajjad/pen/vgEZNy
* TODO: Convert to Vanilla JS * TODO: Convert to Vanilla JS
*/ */
// Hide header on scroll down // Hide header on scroll down
var didScroll; var didScroll;
@ -10,7 +10,7 @@ var lastScrollTop = 0;
var delta = 0; var delta = 0;
var navbarHeight = $('.mw-header-container').outerHeight(); var navbarHeight = $('.mw-header-container').outerHeight();
$(window).scroll(function(event){ $(window).scroll(function(event) {
didScroll = true; didScroll = true;
}); });
@ -25,22 +25,22 @@ function hasScrolled() {
var st = $(this).scrollTop(); var st = $(this).scrollTop();
// Make scroll more than delta // Make scroll more than delta
if(Math.abs(lastScrollTop - st) <= delta) if (Math.abs(lastScrollTop - st) <= delta)
return; return;
// If scrolled down and past the navbar, add class .nav-up. // If scrolled down and past the navbar, add class .nav-up.
if (st > lastScrollTop && st > navbarHeight){ if (st > lastScrollTop && st > navbarHeight) {
// Scroll Down // Scroll Down
$('header').removeClass('nav-down').addClass('nav-up'); $('header').removeClass('nav-down').addClass('nav-up');
} else if (document.scrollTop == 0){ } else if (document.scrollTop == 0) {
// Remove class when header is back in place // Remove class when header is back in place
$('header').removeClass('nav-down') $('header').removeClass('nav-down')
} else { } else {
// Scroll Up // Scroll Up
if(st + $(window).height() < $(document).height()) { if (st + $(window).height() < $(document).height()) {
$('header').removeClass('nav-up').addClass('nav-down'); $('header').removeClass('nav-up').addClass('nav-down');
} }
} }
lastScrollTop = st; lastScrollTop = st;
} }