小编Szy*_*mon的帖子

NiceScroll显示/隐藏

我想NiceScroll根据功能的结果隐藏/显示if

在我的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();
    }
});
Run Code Online (Sandbox Code Playgroud)

滚动到第2节之外时,它会隐藏,但向后滚动时,它不会再次出现。

jquery show hide nicescroll

5
推荐指数
1
解决办法
9446
查看次数

标签 统计

hide ×1

jquery ×1

nicescroll ×1

show ×1