1
0
Эх сурвалжийг харах

prevent "scrolling" to infinity and beyond

Gildas 7 жил өмнө
parent
commit
979cb707da

+ 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);
 		}
 	}