0

我正在尝试为我的网站创建无限循环。我为此使用jQuery Endless Scroll 插件

<script type='text/javascript' src='/js/jquery.min.js'></script>
<script type='text/javascript' src='/js/jquery.endless-scroll.js'></script>

$(document).ready(function() {
    $(window).endlessScroll({
        inflowPixels: 300,
                ceaseFireOnEmpty :false,
        callback: function() {
            var $img = $('#clmn-a .box:nth-child(4)').clone();
            $('#clmn-a').append($img);
        }
    });
});

一切正常,但此功能也在顶部滚动上运行。我只想在用户到达页脚附近时加载数据。那么如何在jQuery Endless Scroll 插件中禁用 Top Scroll Load

插件链接:https ://github.com/fredwu/jquery-endless-scroll

4

1 回答 1

0

试试这个:

$(document).ready(function() {

    EndlessScroll.prototype.detectScrollDirection = function() {
        var currentScrollTop;
        this.didScroll = true;
        currentScrollTop = $(this.target).scrollTop();
        if (currentScrollTop > this.lastScrollTop) {
          this.scrollDirection = 'next';
        }
        else{
        }
        return this.lastScrollTop = currentScrollTop;
      };


    $(window).endlessScroll({
        inflowPixels: 300,
                ceaseFireOnEmpty :false,
        callback: function() {
            var $img = $('#clmn-a .box:nth-child(4)').clone();
            $('#clmn-a').append($img);
        }
    });
});
于 2016-08-25T07:20:40.930 回答