Kaynağa Gözat

added constants

Gildas 7 yıl önce
ebeveyn
işleme
dd39fb3549
1 değiştirilmiş dosya ile 5 ekleme ve 2 silme
  1. 5 2
      lib/lazy/web-lazy-loader-before.js

+ 5 - 2
lib/lazy/web-lazy-loader-before.js

@@ -22,6 +22,9 @@
 
 (() => {
 
+	const SCROLL_LENGTH = 100;
+	const SCROLL_DELAY = 50;
+
 	window._singleFile_getBoundingClientRect = Element.prototype.getBoundingClientRect;
 	Element.prototype.getBoundingClientRect = function () {
 		const boundingRect = window._singleFile_getBoundingClientRect.call(this);
@@ -35,13 +38,13 @@
 	};
 	scrollBy(0, 1);
 	requestAnimationFrame(() => scrollBy(0, -1));
-	scroll(0, document.documentElement.offsetHeight);
+	scroll(SCROLL_LENGTH, document.documentElement.offsetHeight);
 
 	function scroll(offsetY, maxOffsetY) {
 		document.documentElement.__defineGetter__("scrollTop", () => offsetY);
 		dispatchEvent(new UIEvent("scroll"));
 		if (offsetY < maxOffsetY) {
-			window._singleFile_timeoutScroll = setTimeout(() => scroll(offsetY + 100, maxOffsetY), 50);
+			window._singleFile_timeoutScroll = setTimeout(() => scroll(offsetY + SCROLL_LENGTH, maxOffsetY), SCROLL_DELAY);
 		}
 	}