刚刚开始使用 fullPage.js 并且到目前为止很喜欢它。
无论如何,当实现连续和循环效果并且您位于第一部分时,它允许最终用户向上滚动并落在最后一部分上......这在尝试向用户讲故事时是一个问题。因此我只是想禁用向上滚动,但不知道该怎么做。
我做了一些研究,发现了 moveSectionUp 并尝试禁用它,但不知道如何做。任何熟悉 fullPage.js 的人都可以帮我吗?
注意:我只希望在第一部分禁用它,其余部分可以自由地来回滚动。
提前致谢。
最佳答案
使用fullpage.js函数setAllowScrolling
参数 up
如下所示:
//disabling scrolling up
$.fn.fullpage.setAllowScrolling(false, 'up');
您可以在 afterRender
回调和 afterLoad
上使用它来使用它,如下所示:
$('#fullpage').fullpage({
sectionsColor: ['yellow', 'orange', '#C0C0C0', '#ADD8E6'],
continuousVertical: true,
afterRender: function () {
//disabling scrolling up on page load if we are in the 1st section
if($('.fp-section.active').index('.fp-section') === 0){
$.fn.fullpage.setAllowScrolling(false, 'up');
}
},
afterLoad: function (anchorLink, index) {
if (index !== 1) {
//activating the scrolling up for any other section
$.fn.fullpage.setAllowScrolling(true, 'up');
} else {
//disabling the scrolling up when reaching 1st section
$.fn.fullpage.setAllowScrolling(false, 'up');
}
}
});
这样访问者将无法在页面加载时向上滚动。
来自文档:
setAllowScrolling(boolean, [directions])
Adds or remove the possibility of scrolling through sections by using the mouse wheel/trackpad or touch gestures (which is active by default).
directions: (optional parameter) Admitted values: all, up, down, left, right or a combination of them separated by commas like down, right. It defines the direction for which the scrolling will be enabled or disabled.
关于javascript - Fullpage.js 使用连续滚动或循环时禁用 moveSectionUp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29046386/