Last active
May 27, 2019 00:25
-
-
Save jeangontijo/82ef810097be68c9f418349a94859988 to your computer and use it in GitHub Desktop.
Toggle Class on Scroll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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