Unlimited

let lastScrollTop = 0; // Store the previous scroll position const header = document.getElementById('header'); // Get the header element window.addEventListener('scroll', function() { let currentScroll = window.pageYOffset || document.documentElement.scrollTop; // Get current scroll position if (currentScroll > lastScrollTop) { // If scrolling down, hide the header header.classList.add('hidden'); } else { // If scrolling up, show the header header.classList.remove('hidden'); } // Update the last scroll position lastScrollTop = currentScroll <= 0 ? 0 : currentScroll; }, false);
Scroll to Top