Can you convert this to pure javascript from jQuery?
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x


var shrinkBar = 200;

$(window).scroll(function() {
var scroll = getCurrentScroll();
if ( scroll >= shrinkBar ) {
else {

function getCurrentScroll() {
return window.pageYOffset || document.documentElement.scrollTop;

This makes the bar appear when scrolling down, is this what you want?
daphee 3 months ago
awarded to MSF via daphee

Crowdsource coding tasks.

2 Solutions

Winning solution

Here is my solution:

I am not sure whether this is the way you want as with your CSS adding the class "shrink" makes the bar appear so scrolling down makes the bar appear and scrolling up disappear.

Thank you SO much. Exactly what I wanted
mary 3 months ago

Ok, i believe this is what you want, look on it in this fiddle:


the navigation bar, will stay at top, when you scroll down. you can even affect the classes you want.

View Timeline