// Hide Header on on scroll down var didScroll; var lastScrollTop = 0; var delta = 5; var navbarHeight = $('.navbar').outerHeight(); $(window).scroll(function (event) { didScroll = true; }); setInterval(function () { if (didScroll) { hasScrolled(); didScroll = false; } }, 250); function hasScrolled() { var st = $(this).scrollTop(); // Make sure they scroll more than delta if (Math.abs(lastScrollTop - st) <= delta) return; // If they scrolled down and are past the navbar, add class .nav-up. // This is necessary so you never see what is "behind" the navbar. if (st > lastScrollTop && st > navbarHeight) { // Scroll Down $('.navbar').removeClass('scrollNav').addClass('nav-up'); $('.subNav').removeClass('scrollSubNav').addClass('nav-up'); } else { // Scroll Up if (st + $(window).height() < $(document).height() || st === 0) { $('.navbar').removeClass('nav-up').addClass('scrollNav'); $('.subNav').removeClass('nav-up').addClass('scrollSubNav'); } } lastScrollTop = st; } $('.closeBtn').on('click', function () { $(".searchOverlay").fadeToggle(200); $(".button a").toggleClass('btn-open').toggleClass('btn-close'); open = false; }); $(".searchIconBtn").click(function () { $(".searchOverlay").fadeToggle(200); $(this).toggleClass('btn-open').toggleClass('btn-close'); }); $(".mobileCloseBtn").click(function () { $(".collapse").removeClass("show"); }); $(".mainPageMenuBtn").on("click", function () { $(".mainPageMenuBtn").removeClass("active"); $(this).addClass('active'); var id = $(this).attr('href'); $('.mainDetail').removeClass("active"); $(id).addClass("active"); $('html, body').animate({ scrollTop: $($.attr(this, 'href')).offset().top - 150 }, 1000); }); $(".mapbtn").on("click", function () { $('html, body').animate({ scrollTop: $($.attr(this, 'href')).offset().top - 150 }, 1000); }); $('.scrollTop').click(function () { // When arrow is clicked $('html').animate({ scrollTop: 0 // Scroll to top of body }, 500); });