Fixed endless scroll loading next page too eagerly

This commit is contained in:
Marcin Kurczewski 2014-09-18 13:06:43 +02:00
parent 2c358b3c77
commit 9699aeaf64

View file

@ -148,15 +148,16 @@ App.Presenters.PagedCollectionPresenter = function(
if (!endlessScroll) { if (!endlessScroll) {
return; return;
} }
var $scroller = jQuery('<div/>');
window.clearInterval(scrollInterval); window.clearInterval(scrollInterval);
scrollInterval = window.setInterval(function() { scrollInterval = window.setInterval(function() {
if ($scroller.is(':visible')) { var baseLine = $target.offset().top + $target.innerHeight();
var scrollY = jQuery(window).scrollTop() + jQuery(window).height();
if (scrollY > baseLine) {
nextPageInplace(); nextPageInplace();
window.clearInterval(scrollInterval); window.clearInterval(scrollInterval);
} }
}, 50); }, 100);
$target.append($scroller);
} }
function refreshPageList() { function refreshPageList() {