在 fullpage.js 上添加 onLeave 会中断滚动
Adding onLeave on fullpage.js breaks scroll
我正在使用 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!");
}
}
});
很抱歉浪费了您的时间,再次感谢插件的创建者:)
我正在使用 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!");
}
}
});
很抱歉浪费了您的时间,再次感谢插件的创建者:)