我正在尝试为我的网站创建无限循环。我正在使用 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
答案 0 :(得分: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);
}
});
});