Explorar el Código

improved scrolling emulation

Gildas hace 7 años
padre
commit
ca1810cae3
Se han modificado 2 ficheros con 4 adiciones y 3 borrados
  1. 2 1
      lib/lazy/web-lazy-loader-after.js
  2. 2 2
      lib/lazy/web-lazy-loader-before.js

+ 2 - 1
lib/lazy/web-lazy-loader-after.js

@@ -32,7 +32,8 @@
 		clearTimeout(window._singleFile_timeoutScroll);
 		delete window._singleFile_timeoutScroll;
 		delete document.documentElement.scrollTop;
-		window.scrollY = window.pageYOffset = window._singleFile_offsetY;
+		document.documentElement.__defineGetter__("scrollY", () => document.documentElement.scrollTop);
+		document.documentElement.__defineGetter__("pageYOffset", () => document.documentElement.scrollTop);
 		dispatchEvent(new UIEvent("scroll"));
 	}
 

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

@@ -26,7 +26,6 @@
 	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);
@@ -43,7 +42,8 @@
 
 	function scroll(offsetY, maxOffsetY) {
 		document.documentElement.__defineGetter__("scrollTop", () => offsetY);
-		window.scrollY = window.pageYOffset = offsetY;
+		document.documentElement.__defineGetter__("scrollY", () => offsetY);
+		document.documentElement.__defineGetter__("pageYOffset", () => offsetY);
 		dispatchEvent(new UIEvent("scroll"));
 		if (offsetY < maxOffsetY) {
 			window._singleFile_timeoutScroll = setTimeout(() => scroll(offsetY + SCROLL_LENGTH, maxOffsetY), SCROLL_DELAY);