Skip to content

Instantly share code, notes, and snippets.

@caffeinewriter
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caffeinewriter/a6aba20384954c32de54 to your computer and use it in GitHub Desktop.
Save caffeinewriter/a6aba20384954c32de54 to your computer and use it in GitHub Desktop.
jQuery Receding Menu
//jQuery to retract a menu on scroll down, and show on scroll up, in 11 SLOC
var menuSelector = '.menuClass #menuId';
var lastScrollTop = 0;
$(window).scroll(function(event){
var st = $(this).scrollTop();
if (st > lastScrollTop){
$(menuSelector).slideUp(400,'easeOutCirc');
} else {
$(menuSelector).slideDown(400,'easeOutCirc');
}
lastScrollTop = st;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment