jquery - NiceScroll show/hide -
i'd hide/show nicescroll
based on result of if
function.
in html
there 3 sections scrolled left right 1 one.
my script follows:
var section2 = $('#section2').offset().left; $(window).scroll(function(){ var scrollzpos = $(document).scrollleft(); if (scrollzpos <= section2 ) { $("body").getnicescroll().hide(); } if (scrollzpos == section2 ) { $("body").nicescroll({touchbehavior:false,cursorcolor:"#67a5df",horizrailenabled:false,cursoropacitymax:1,autohidemode:false,cursorwidth:10,cursorborder:0,cursorborderradius:0,cursorminheight:180}); } else if(scrollzpos >= section2 ){ $("body").getnicescroll().hide(); } });
it hides when scrolling outside of section 2, when scrolling doesn't reappear.
i found solution answer on github.
it's better create nicescroll
during document
ready
event.
$("body").getnicescroll().show()
Comments
Post a Comment