小编ris*_*isk的帖子

在某个滚动偏移或滚动时间之后的火焰滚动事件

我正在使用fullPage.jsJQuery插件(请参阅此处的演示).此插件定义完整窗口大小的部分,并在用户向上或向下滚动时从"滑动"部分滚动到"滑动".

我正在尝试修改它,以便滚动事件不会在滚动开始时立即触发但在短时间或某个滚动量之后,以防止用户意外滑动几个像素,这将触发滚动事件并滚动到下一张幻灯片

例如,如果用户滚动偏移<100px,则滚动回当前幻灯片,如果偏移> 100px,则滚动到下一张幻灯片.

fullpage.js代码.我想我必须修改这个功能才能得到我想要的东西:

//when scrolling...
$(window).scroll(function(e){
        if(!options.autoScrolling){
                var currentScroll = $(window).scrollTop();

                var scrolledSections = $('.section').map(function(){
                        if ($(this).offset().top < (currentScroll + 100)){
                                return $(this);
                        }
                });

                //geting the last one, the current one on the screen
                var currentSection = scrolledSections[scrolledSections.length-1];

                //executing only once the first time we reach the section
                if(!currentSection.hasClass('active')){
                        var yMovement = getYmovement(currentSection);

                        $('.section.active').removeClass('active');
                        currentSection.addClass('active');

                        var anchorLink  = currentSection.data('anchor');
                        $.isFunction( options.onLeave ) && options.onLeave.call( this, currentSection.index('.section'), yMovement);

                        $.isFunction( options.afterLoad ) …
Run Code Online (Sandbox Code Playgroud)

javascript jquery scroll jquery-plugins fullpage.js

4
推荐指数
1
解决办法
6469
查看次数

标签 统计

fullpage.js ×1

javascript ×1

jquery ×1

jquery-plugins ×1

scroll ×1