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

Js/jQuery:

'$(function(){
var shrinkBar = 200;

$(window).scroll(function() {
var scroll = getCurrentScroll();
if ( scroll >= shrinkBar ) {
$('.bar').addClass('shrink');
}
else {
$('.bar').removeClass('shrink');
}
});

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

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

Crowdsource coding tasks.

2 Solutions

Winning solution

Here is my solution: https://jsfiddle.net/sha2o0sj/

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 19 days ago

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

link: http://jsfiddle.net/7HHa5/4/

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

View Timeline