I am using this code to show/hide the header on scroll but the header is slightly glitchy, the code is from an article written in 2013 so I don't know if that's the cause...
function hasScrolled() {
var l = $(this).scrollTop();
Math.abs(lastScrollTop - l) <= delta ||
(l > lastScrollTop && l > navbarHeight
? $("header").removeClass("nav-down").addClass("nav-up")
: l + $(window).height() < $(document).height() &&
$("header").removeClass("nav-up").addClass("nav-down"),
(lastScrollTop = l));
}
var didScroll,
lastScrollTop = 0,
delta = 5,
navbarHeight = $("header").outerHeight();
$(window).scroll(function (l) {
didScroll = !0;
});
setInterval(function () {
didScroll && (hasScrolled(), (didScroll = !1));
}, 250);
Thanks in advance :)