Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nextab/c56f6a0cf46faab4df5ca3f6edb61530 to your computer and use it in GitHub Desktop.
Save nextab/c56f6a0cf46faab4df5ca3f6edb61530 to your computer and use it in GitHub Desktop.
(function() {
// Add scroll class to body when scrolling
function handleScroll() {
const scrollPosition = window.scrollY || document.documentElement.scrollTop;
if (scrollPosition > 0) {
document.body.classList.add('scrolling');
} else {
document.body.classList.remove('scrolling');
}
}
handleScroll();
window.addEventListener('scroll', handleScroll, { passive: true });
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment