gpt4 book ai didi

javascript - 在 fullpage.js 上添加 onLeave 会中断滚动

转载 作者:行者123 更新时间:2023-11-30 00:23:07 26 4
gpt4 key购买 nike

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

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

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

谢谢!

最佳答案

我已经解决了它,即我之前做错了 - 我为 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!");
}
}
});

很抱歉浪费了你的时间,再一次向插件的创建者致敬:)

关于javascript - 在 fullpage.js 上添加 onLeave 会中断滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32434631/

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