Skip to content
This repository was archived by the owner on Feb 12, 2022. It is now read-only.

Commit dcef25c

Browse files
authored
Merge pull request #2039 from jacobroschen/fix-inifite-scroll
Prevent infinite scroll from fetching all pages
2 parents a62c39a + 7db35e5 commit dcef25c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

js/infinite-scroll.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@
8484
getPercentage: function () {
8585
var height = (this.$element.css('box-sizing') === 'border-box') ? this.$element.outerHeight() : this.$element.height();
8686
var scrollHeight = this.$element.get(0).scrollHeight;
87+
// If we cannot compute the height, then we end up fetching all pages (ends up #/0 = Infinity).
88+
// This can happen if the repeater is loaded, but is not in the dom
89+
if (scrollHeight === 0 || scrollHeight - this.curScrollTop === 0) {
90+
return 0;
91+
}
8792
return (height / (scrollHeight - this.curScrollTop)) * 100;
8893
},
8994

0 commit comments

Comments
 (0)