如何在 jQuery Endless Scroll 插件中停止 TOP Scroll Load
How to stop TOP Scroll Load in jQuery Endless Scroll plugin
我正在尝试为我的网站创建无限循环。为此,我正在使用 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
试试这个:
$(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);
}
});
});
我正在尝试为我的网站创建无限循环。为此,我正在使用 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试试这个:
$(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);
}
});
});