Skip to content

Instantly share code, notes, and snippets.

Created August 1, 2013 20:56
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 anonymous/fcbb946c6d9aa8624771 to your computer and use it in GitHub Desktop.
Save anonymous/fcbb946c6d9aa8624771 to your computer and use it in GitHub Desktop.
$(document).ready(function(e) {
//hide menu
var lastScrollTop, incr = 0;
var menuSpace = 20; startsOn = 80;
$(window).scroll(function(event) {
var st = $(this).scrollTop();
if (st > startsOn) {
if (st > lastScrollTop) {
incr += 1;
if (incr >= menuSpace) {
$(".topMenu").addClass("hide");
incr = menuSpace;
}
} else {
incr -= 1;
if (incr <= 5) {
$(".topMenu").removeClass("hide");
incr = 0;
}
}
} else {
$(".topMenu").removeClass("hide");
}
lastScrollTop = st;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment