Created
March 22, 2012 13:58
-
-
Save mattboon/2158494 to your computer and use it in GitHub Desktop.
jQuery - Action when user has scrolled
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
$(document).scroll(function(e) { | |
var nav = $('nav'), | |
page = $('body'), | |
scrollValue = page[0].offsetTop - window.pageYOffset; | |
if(scrollValue < -20 ) { | |
nav.addClass('scrolled'); | |
} | |
else { | |
nav.removeClass('scrolled'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment