Reputation:
I saw a site recently that had a hidden scrollbar which appear on scroll. This may also be because it's a slickgrid. I'm able to control my scrollbar CSS specific to a div
but can't control it from javascript. My script so far has been pretty simplistic:
$('#mydiv').scroll(function(){
$('#mydiv::-webkit-scrollbar').fadeIn(500);
//I've also tried .css() above and tried the .hover event as well
})
My div and scrollbar css:
#mydiv{overflow-x: hidden; overflow-y: auto; height: 80%; width: 100%;}
#mydiv::-webkit-scrollbar{display: none;}
Is there a way to show the scrollbar on scroll? I already know how to control on hover by changing overflow on :hover
in css.
Upvotes: 0
Views: 183
Reputation: 495
No plugins needed, try this:
JS:
$(window).bind('mousewheel', function(e) {
var el = $('body');
el.css('overflow-y', 'scroll');
if (el[0].hideScroll) clearTimeout(el[0].hideScroll);
el[0].hideScroll = setTimeout(function() {
el.css('overflow-y', 'hidden');
}, 500);
});
CSS:
body {
overflow-y: hidden;
}
Upvotes: 1