Skip to content

Instantly share code, notes, and snippets.

@jeangontijo
Last active May 27, 2019 00:25
Show Gist options
  • Save jeangontijo/82ef810097be68c9f418349a94859988 to your computer and use it in GitHub Desktop.
Save jeangontijo/82ef810097be68c9f418349a94859988 to your computer and use it in GitHub Desktop.
Toggle Class on Scroll
window.addEventListener("scroll", function (event) {
var scroll = this.scrollY;
if(scroll > 0){
document.querySelector('nav').classList.add('scroll');
} else {
document.querySelector('nav').classList.remove('scroll');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment