Parcourir la source

store scrollY before any scroll

Gildas il y a 7 ans
Parent
commit
41e27f0363
1 fichiers modifiés avec 1 ajouts et 1 suppressions
  1. 1 1
      lib/lazy/web-lazy-loader-before.js

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

@@ -26,6 +26,7 @@
 	const SCROLL_DELAY = 50;
 
 	window._singleFile_getBoundingClientRect = Element.prototype.getBoundingClientRect;
+	window._singleFile_offsetY = window.scrollY;
 	Element.prototype.getBoundingClientRect = function () {
 		const boundingRect = window._singleFile_getBoundingClientRect.call(this);
 		const quarterLeft = Math.floor(screen.width / 4);
@@ -38,7 +39,6 @@
 	};
 	scrollBy(0, 1);
 	requestAnimationFrame(() => scrollBy(0, -1));
-	window._singleFile_offsetY = window.scrollY;
 	scroll(SCROLL_LENGTH, document.documentElement.scrollHeight - screen.height);
 
 	function scroll(offsetY, maxOffsetY) {