我正在寻找一点帮助!
我正在将Alvaro Trigo的Fullpage.js用于正在开发的Wordpress网站。
在主页上,我让每个部分每隔5000ms自动滚动一次。
如果用户决定使用鼠标导航每个部分,则当前将覆盖此功能。
如果用户在5000ms内处于非活动状态(即未手动滚动),则客户端已请求重新激活自动滚动。
Here is the work in progress。
预先谢谢您-任何帮助将不胜感激!如果您需要更多信息,请告诉我。
最佳答案
Example online
尝试这个:
var myIntervalId;
var auto = true;
$('#fullpage').fullpage({
sectionsColor: ['yellow', 'orange', '#C0C0C0', '#ADD8E6'],
continuousVertical: true,
afterLoad: function (anchorLink, index){
//for any section
if(typeof myIntervalId === 'undefined' || !auto){
clearInterval(myIntervalId);
myIntervalId = setInterval(function() {
$.fn.fullpage.moveSectionDown();
}, 1000);
}
}
});
addMouseWheelHandler();
function MouseWheelHandler() {
clearInterval(myIntervalId);
auto = false;
}
function addMouseWheelHandler() {
if (document.addEventListener) {
document.addEventListener('mousewheel', MouseWheelHandler, false); //IE9, Chrome, Safari, Oper
document.addEventListener('wheel', MouseWheelHandler, false); //Firefox
} else {
document.attachEvent('onmousewheel', MouseWheelHandler); //IE 6/7/8
}
}