Hey there! I'm looking for a way to hide my navigation bar when not scrolling, and then display it again once I start scrolling. Currently, I have two menus on this website: one with a white background and the other with a blue background.
You can find the menus at
http://dev.thegabrielmethod.com/gabriel/
My goal is to hide the navigation menu items on the white background when the user is not scrolling, and then reveal them as soon as they start scrolling down the page.
https://i.sstatic.net/o1k3h.png
I've tried implementing the following code snippet but unfortunately, it's not working properly:
<script type='text/javascript'>//<![CDATA[
$(document).ready(function() {
var headerTop = $('#header').offset().top;
var headerBottom = headerTop + 120; // Sub-menu should appear after this distance from top.
$(window).scroll(function () {
var scrollTop = $(window).scrollTop(); // Current vertical scroll position from the top
if (scrollTop > headerBottom) {
if (($("#navigation-alongside").is(":visible") === false)) {
$('#navigation-alongside').fadeIn('slow');
}
} else {
if ($("#navigation-alongside").is(":visible")) {
$('#navigation-alongside').hide();
}
}
});
});
</script>
If anyone has any advice or suggestions, please feel free to share!