我想根据if函数的结果来隐藏/显示NiceScroll。
在我的html中有三个部分,从左到右一个一个地滚动。
我的脚本如下:
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();
}
});当滚动到第2节之外时,它会隐藏起来,但当向后滚动时,它不会重新出现。
发布于 2013-05-23 04:34:23
我在Github上找到了这个答案的解决方案。
最好在document ready事件期间创建NiceScroll。
$("body").getNiceScroll().show()https://stackoverflow.com/questions/16344196
复制相似问题