Menu sticky when scroll up (desktop only)

function menuStickyWhenScrollUp () { var element = $('selector'); var checkpoint = menuHeader.data('responsive'); var windowWidth = $(window).innerWidth(); var position = 0; /* normal */ if(checkpoint <= windowWidth) { $(window).scroll(function(event) { var currentPos = $(this).scrollTop(); // on top if (currentPos === 0 ) { /* code here */ } // scroll down if (currentPos > position && currentPos > 300) { /* code here */ } // scroll up else { if(currentPos > 300) { /* code here */ } } position = currentPos; }); } /* responsive mode */ else { } }
Menu sticky when scroll up (desktop only).
Just for fun...

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.