2015-03-31 32 views
3

我有一個頁面,其中有一個固定位置的按鈕,點擊時應該計算視口的高度,然後向下滾動該頁面的高度。即。到下一個視口。當用戶到達沒有更多空間滾動的時候,我想隱藏這個按鈕。不知道如何做到這一點,到目前爲止,我有這個:向下滾動當前視口的高度

$(document).on('click', '.next-viewport-down', function(event){       
        event.preventDefault(); 
        var viewportHeight = $(window).height(); 

         $('html, body').stop(true,true).animate({ 
           ..... 
          }, 2000); 
      }); 

回答

4

試試這個。

$(document).on('click', '.next-viewport-down', function(event){       
    event.preventDefault(); 
    var viewportHeight = $(window).height(); 

    $('html, body').animate({ 
     scrollTop: viewportHeight, 
     complete: function() { 
      //Hide your button here 
     } 
    }, 2000); 
}); 
相關問題