This is very helpful on mobile browsing. The menu will hide once the user scroll to DOWN direction. And will Show Menu once the user scroll to UP direction.
I gave my nav bar an ID called MagicMenu
then just put this code in your custom footer and it will works just wonderful.
<script type="text/javascript">
// Hide #MagicMenu on on scroll down
var didScroll;
var lastScrollTop = 0;
var delta = 5;
var navbarHeight = $('#MagicMenu').outerHeight();
$(window).scroll(function(event){
didScroll = true;
});
setInterval(function() {
if (didScroll) {
hasScrolled();
didScroll = false;
}
}, 250);
function hasScrolled() {
var st = $(this).scrollTop();
// Make sure they scroll more than delta
if(Math.abs(lastScrollTop - st) <= delta)
return;
// If they scrolled down and are past the navbar, add class .MagicMenu-up.
// This is necessary so you never see what is "behind" the navbar.
if (st > lastScrollTop && st > navbarHeight){
// Scroll Down
$('#MagicMenu').fadeOut(500);
} else {
// Scroll Up
if(st + $(window).height() < $(document).height()) {
$('#MagicMenu').fadeIn(500);
}
}
lastScrollTop = st;
}
</script>