Skip to content

Instantly share code, notes, and snippets.

@andrewjcohen
Created March 13, 2014 16:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewjcohen/c06e5d77fbe087701fad to your computer and use it in GitHub Desktop.
Save andrewjcohen/c06e5d77fbe087701fad to your computer and use it in GitHub Desktop.
JQuery to fix the thoughtbot.com header on scroll
$(document).scroll(function() {
if( $(this).scrollTop() > $(window).height() - 90 && !$(mainNav).hasClass('showing') ) {
$(mainNav).addClass('showing');
}
else if ( $(this).scrollTop() < $(window).height() - 90 && $(mainNav).hasClass('showing') ) {
$(mainNav).removeClass('showing');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment