gpt4 book ai didi

jquery - NiceScroll显示/隐藏

转载 作者:行者123 更新时间:2023-12-03 23:05:37 29 4
gpt4 key购买 nike

我想根据 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 部分之外时它会隐藏,但当向后滚动时它不会重新出现。

最佳答案

我在 Github 上找到了这个答案的解决方案。

最好在 document ready 事件期间创建 NiceScroll

$("body").getNiceScroll().show()

关于jquery - NiceScroll显示/隐藏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16344196/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com