fix: infinite scroll with small number of items #9524 (#9525)

v1.18.x
gasoved 4 years ago committed by GitHub
parent 9950602eff
commit cb1dd0a3db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -10,15 +10,20 @@ define('forum/infinitescroll', function () {
var scrollTimeout = 0; var scrollTimeout = 0;
scroll.init = function (el, cb) { scroll.init = function (el, cb) {
const $body = $('body');
if (typeof el === 'function') { if (typeof el === 'function') {
callback = el; callback = el;
container = $('body'); container = $body;
} else { } else {
callback = cb; callback = cb;
container = el || $('body'); container = el || $body;
} }
previousScrollTop = $(window).scrollTop(); previousScrollTop = $(window).scrollTop();
$(window).off('scroll', startScrollTimeout).on('scroll', startScrollTimeout); $(window).off('scroll', startScrollTimeout).on('scroll', startScrollTimeout);
if ($body.height() <= $(window).height()) {
callback(1);
}
}; };
function startScrollTimeout() { function startScrollTimeout() {

Loading…
Cancel
Save