Javascript

<script>
jQuery(function(){
jQuery(window).scroll(function() {
var windowWidth = jQuery(window).width();
//set window width you want menu to change sticky position
if(windowWidth > 768) {
//scroll distance down page you want sticky nav to enable (larger than windowWidth set above)
if (jQuery(this).scrollTop() >= 190) {
jQuery('.NAV_CLASS’).addClass('sticky-nav');
}
else {
jQuery('.NAV_CLASS').removeClass('sticky-nav');
}

} else {
//scroll distance down you want sticky nav to enable (smaller than windowWidth set above)
if (jQuery(this).scrollTop() >= 300) {
jQuery('.NAV_CLASS').addClass('sticky-nav');
}
else {
jQuery('.NAV_CLASS').removeClass('sticky-nav');
}

}

});
});
</script>

** .NAV_CLASS = existing class on menu

CSS

.sticky-nav {
position: fixed;
}

** extra styling may be necessary on sticky-nav

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.