【问题标题】:Adding onLeave on fullpage.js breaks scroll在 fullpage.js 上添加 onLeave 会中断滚动
【发布时间】:2015-09-07 08:53:03
【问题描述】:

我正在使用fullpage.js,它是一个很棒的插件,但是,在我将 onLeave 回调添加到页面后(来自 github 的默认示例),花哨的滚动功能,即,而不是每次鼠标滚动向上或向下滚动一个部分无论滚动长度如何,每滚动一步都会跳转一个部分。

我在 fullpage.js 问题部分被告知问题已经解决,我应该使用最新的库,但我已经尝试了 CDN 以及将插件安装到我的项目中,问题仍然存在。

抱歉,我无法包含问题的示例 - 我无法在 jsfiddle 中重现它。

谢谢!

【问题讨论】:

  • 你的项目公开了吗?还是本地的?
  • 抱歉浪费了您的时间,我解决了这个问题,我没有意识到 afterload 和 onLeave 应该放在同一个 $('#fullpage').fullpage({})并用逗号分隔
  • 我很抱歉浪费了你的时间,我一直做错了,即我为 afterLoad 和 onLeave 做了两个单独的 $('#fullpage').fullpage({}),但是当我把它们他们在一个昏迷状态下工作。谢谢你,再次抱歉。

标签: javascript jquery css fullpage.js


【解决方案1】:

我已经解决了它,即我之前做错了 - 我为 afterLoad 和 onLeave 创建了一个新的 $('#fullpage').fullpage({})。

当我将它们放在同一个中并用昏迷将它们分开时,它们会按预期工作。

$('#fullpage').fullpage({
        anchors: ['firstPage', 'secondPage', 'thirdPage', 'fourthPage', 'lastPage'],

        afterLoad: function(anchorLink, index){
            var loadedSection = $(this);

            //using index
            if(index == 3){
                //alert("Section 3 ended loading");
            }

            //using anchorLink
            if(anchorLink == 'secondSlide'){
                //alert("Section 2 ended loading");
            }
        },

        onLeave: function(index, nextIndex, direction){
            var leavingSection = $(this);

            //after leaving section 2
            if(index == 2 && direction =='down'){
                alert("Going to section 3!");
            }

            else if(index == 2 && direction == 'up'){
                //alert("Going to section 1!");
            }
        }
    });

很抱歉浪费了你一次又一次的道具给创造者的好插件:)

【讨论】:

    猜你喜欢
    • 2015-10-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-19
    相关资源
    最近更新 更多