我正在尝试编写一个函数来自动滚动具有无限滚动的页面。它部分有效,但在Facebook这样的页面上,它会在某个时刻意外停止。有什么建议吗?
function scroll() {
if ($bottom <= ($(document).height() + $(window).height() + 100)) {
$('html, body').animate({
scrollTop: $bottom
}, 2500, 'linear', function() {
console.log(($(document).height() + $(window).height() + 100) + ' ' + $bottom);
$bottom = $bottom + 100;
scroll();
});
} else {
$('html, body').stop(true);
}
}
感谢