소스 검색

fixed scrolling emulation

Gildas 7 년 전
부모
커밋
1bf141c1fb
2개의 변경된 파일4개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 0
      lib/lazy/web-lazy-loader-after.js
  2. 3 1
      lib/lazy/web-lazy-loader-before.js

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

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

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

@@ -38,10 +38,12 @@
 	};
 	scrollBy(0, 1);
 	requestAnimationFrame(() => scrollBy(0, -1));
-	scroll(SCROLL_LENGTH, document.documentElement.offsetHeight);
+	window._singleFile_offsetY = window.scrollY;
+	scroll(SCROLL_LENGTH, document.documentElement.scrollHeight - screen.height);
 
 	function scroll(offsetY, maxOffsetY) {
 		document.documentElement.__defineGetter__("scrollTop", () => offsetY);
+		window.scrollY = window.pageYOffset = offsetY;
 		dispatchEvent(new UIEvent("scroll"));
 		if (offsetY < maxOffsetY) {
 			window._singleFile_timeoutScroll = setTimeout(() => scroll(offsetY + SCROLL_LENGTH, maxOffsetY), SCROLL_DELAY);