var lastScrollTop = 0;
var delta = 5;
var navbarHeight = $('.navbar').outerHeight();
var didScroll;
$(window).scroll(function(event) {
didScroll = true;
});
setInterval(function() {
if (didScroll) {
hasScrolled();
didScroll = false;
}
}, 50);
function hasScrolled() {
var st = $(this).scrollTop();
if (Math.abs(lastScrollTop - st) <= delta) {
return;
}
// If current position > last position AND scrolled past navbar...
if (st > lastScrollTop && st >= navbarHeight) {
// Scroll Down
$('.navbar').removeClass('nav-top').removeClass('nav-down').addClass('nav-up');
$('.coupon-widget').removeClass('nav-top').removeClass('nav-down').addClass('nav-up');
$('.pos-widget').removeClass('nav-top').removeClass('nav-down').addClass('nav-up');
}
else if (st <= 5) {
$('.navbar').addClass('nav-top').removeClass('nav-down').removeClass('nav-up');
$('.coupon-widget').addClass('nav-top').removeClass('nav-down').removeClass('nav-up');
$('.pos-widget').addClass('nav-top').removeClass('nav-down').removeClass('nav-up');
} else {
// Scroll Up
// If did not scroll past the document (possible on mac)...
if (st + $(window).height() < $(document).height()) {
$('.navbar').removeClass('nav-top').removeClass('nav-up').addClass('nav-down');
$('.coupon-widget').removeClass('nav-top').removeClass('nav-up').addClass('nav-down');
$('.pos-widget').removeClass('nav-top').removeClass('nav-up').addClass('nav-down');
}
}
lastScrollTop = st;
}
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-M0X0S94KP1');