2014-09-25 25 views
0

我將選項觸發器設置爲true,如果我從開始(頁面頂部)開始滾動並開始向下滾動,它就像魅力一樣工作。路點在刷新後不會觸發以上目標元素

但是,如果我刷新頁面底部的頁面並開始向上滾動,它不會像從頁面頂部向下滾動時那樣觸發上述目標元素。

這裏我的代碼:

$('.anim').each(function(index, elHtml) { 
    var el = $(this); 
    // console.log($(this), el); 
    var _animation = el.data('animation'), 
     _duration = el.data('duration') ? el.data('duration') : 1000, 
     _offset = el.data('offset') ? el.data('offset') : 'bottom-in-view'; 
    el.waypoint(function(direction){ 
     el.velocity(_animation, _duration); 
     if(direction == 'up'){ 
     el.velocity(_animation, _duration); 
     } 
    }, { 
     offset: _offset, 
     triggerOnce: true 
    }); 

    }); 

請讓我知道如果你有解決方案。 謝謝你的時間:)

回答

0

這是因爲當頁面加載並添加Waypoints時,它們檢查是否已經向下傳遞,如果它們已經傳遞,它會觸發航點。所以就你的情況而言,你正在向下的方向擊中航點,並且在向下觸發後它們將被銷燬。

您的用例的「解決方法」是使用enabled: false選項將其禁用。然後,在頁面加載完成後,在航點上調用啓用。

+0

非常感謝你,並感謝你的偉大的插件! – 2014-11-07 19:58:28

相關問題