Переглянути джерело

prevent "scrolling" to infinity and beyond

Gildas 7 роки тому
батько
коміт
979cb707da
1 змінених файлів з 4 додано та 4 видалено
  1. 4 4
      lib/lazy/web-lazy-loader-before.js

+ 4 - 4
lib/lazy/web-lazy-loader-before.js

@@ -35,13 +35,13 @@
 	};
 	scrollBy(0, 1);
 	requestAnimationFrame(() => scrollBy(0, -1));
-	scroll(0);
+	scroll(0, document.documentElement.offsetHeight);
 
-	function scroll(offsetY) {
+	function scroll(offsetY, maxOffsetY) {
 		document.documentElement.__defineGetter__("scrollTop", () => offsetY);
 		dispatchEvent(new UIEvent("scroll"));
-		if (offsetY < document.documentElement.offsetHeight) {
-			window._singleFile_timeoutScroll = setTimeout(() => scroll(offsetY + 100), 50);
+		if (offsetY < maxOffsetY) {
+			window._singleFile_timeoutScroll = setTimeout(() => scroll(offsetY + 100, maxOffsetY), 50);
 		}
 	}