Skip to content

Instantly share code, notes, and snippets.

@mattboon
Created March 22, 2012 13:58
Show Gist options
  • Save mattboon/2158494 to your computer and use it in GitHub Desktop.
Save mattboon/2158494 to your computer and use it in GitHub Desktop.
jQuery - Action when user has scrolled
$(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