簡體   English   中英

基於鼠標滾動的無限滾動

[英]Infinite scroll based on mouse scroll

希望在鼠標滾動到指定的容器底部時基於鼠標滾動實現無限滾動。 在搜索http://www.infinite-scroll.com/之后,我來到了這個插件,它需要滿足以下基本要求:

// infinitescroll() is called on the element that surrounds 
// the items you will be loading more of
  $('#content').infinitescroll({

    navSelector  : "div.navigation",            
                   // selector for the paged navigation (it will be hidden)
    nextSelector : "div.navigation a:first",    
                   // selector for the NEXT link (to page 2)
    itemSelector : "#content div.post"          
                   // selector for all items you'll retrieve
  });

即下一個和上一個選擇器。 我們是否可以基於鼠標滾動而不是單擊下一個上一個鏈接來進行無限滾動,即當鼠標到達指定容器底部時通過ajax加載內容

向滾動事件添加一個功能,並檢查是否向下滾動到底部。 您必須根據布局調整數字並稍微調整代碼:

var $window = $(window);

$(document).ready(function () {

        $(window).scroll(function () {
            var scrollheight2;
            scrollheight2 = $window.scrollTop();

            if (($("#content").height() - scrollheight2) <= 100) {
                    //AJAX STUFF
            }
        });
    });

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM