2015-12-01 34 views
2

我正在尋找一些幫助!重新激活fullpage.js中的自動滾動功能

我正在使用Alvaro Trigo的Fullpage.js爲我正在開發的Wordpress網站。

在主頁上,我有每個部分每5000ms自動滾動一次。

如果用戶決定使用鼠標瀏覽每個部分,則此功能目前被覆蓋。

如果用戶在5000ms內不活動(即不是手動滾動),客戶端請求重新激活自動滾動。

Here is the work in progress

在此先感謝您 - 任何幫助將不勝感激!如果您需要更多信息,請告訴我。

回答

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

嗨阿爾瓦羅 - 謝謝你回來這麼快。我可能沒有正確解釋這個... 我需要自動滾動重新激活後,用戶用鼠標停止它,然後5秒鐘無效。在JSFiddle中,鼠標滾輪會停止自動滾動,但不會重新激活。 提前致謝,並對錯誤溝通感到抱歉。 埃文。 – Evan

+0

@Evan這個例子在用戶停止時重新激活滾動。再次審查。你可以測試它滾動。它會在1秒後再次激活。 (只是把它改爲5你的情況) – Alvaro

+0

對不起,它不適用於我:(我已經在Safari,Firefox和Chrome中試過了,我能夠以某種方式給你看一個屏幕截圖嗎? – Evan