首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NiceScroll显示/隐藏

NiceScroll显示/隐藏
EN

Stack Overflow用户
提问于 2013-05-03 01:29:48
回答 1查看 10.1K关注 0票数 5

我想根据if函数的结果来隐藏/显示NiceScroll

在我的html中有三个部分,从左到右一个一个地滚动。

我的脚本如下:

代码语言:javascript
复制
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节之外时,它会隐藏起来,但当向后滚动时,它不会重新出现。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-05-23 04:34:23

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

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

代码语言:javascript
复制
$("body").getNiceScroll().show()
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16344196

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档