Skip to content

Instantly share code, notes, and snippets.

@tim-bec
Created November 6, 2013 16:44
Show Gist options
  • Save tim-bec/7339567 to your computer and use it in GitHub Desktop.
Save tim-bec/7339567 to your computer and use it in GitHub Desktop.
Change some classes while scrolling
$(function() {
$(window).scroll(function() {
var scrolled = $(window).scrollTop();
if (scrolled > 20) {
$('header').addClass('topFixed');
}
if (scrolled > 50) {
$('header').addClass('small');
} else {
$('header').removeClass('small');
$('header').removeClass('topFixed');
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment