重新激活fullpage.js中的自动滚动

时间:2015-12-01 12:00:33

标签: javascript jquery fullpage.js

我正在寻求一些帮助!

我正在使用Alvaro Trigo的Fullpage.js来开发我正在开发的Wordpress网站。

在主页上,我每个部分每隔5000毫秒自动滚动一次。

如果用户决定使用鼠标导航每个部分,则会覆盖此功能。

如果用户处于非活动状态(即不手动滚动)5000毫秒,客户端已请求重新激活自动滚动。

Here is the work in progress

提前感谢 - 非常感谢任何帮助!如果您需要更多信息,请与我们联系。

1 个答案:

答案 0 :(得分:0)

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
    }
}