Преглед изворни кода

improve support of lazy loaded contents (e.g. twitter) (fix #542)

Gildas пре 5 година
родитељ
комит
1618f376c5
1 измењених фајлова са 9 додато и 4 уклоњено
  1. 9 4
      lib/single-file/processors/hooks/content/content-hooks-frames-web.js

+ 9 - 4
lib/single-file/processors/hooks/content/content-hooks-frames-web.js

@@ -184,6 +184,7 @@
 	addEventListener(LOAD_DEFERRED_IMAGES_END_EVENT, () => loadDeferredImagesEnd());
 	addEventListener(LOAD_DEFERRED_IMAGES_KEEP_ZOOM_LEVEL_END_EVENT, () => loadDeferredImagesEnd(true));
 	addEventListener(LOAD_DEFERRED_IMAGES_RESET_ZOOM_LEVEL_END_EVENT, () => {
+		const scrollingElement = document.scrollingElement || document.documentElement;
 		const transform = document.documentElement.style.getPropertyValue("-sf-transform");
 		const transformPriority = document.documentElement.style.getPropertyPriority("-sf-transform");
 		const transformOrigin = document.documentElement.style.getPropertyValue("-sf-transform-origin");
@@ -196,6 +197,10 @@
 		document.documentElement.style.removeProperty("-sf-transform");
 		document.documentElement.style.removeProperty("-sf-transform-origin");
 		document.documentElement.style.removeProperty("-sf-min-height");
+		delete scrollingElement.clientHeight;
+		delete scrollingElement.clientWidth;
+		delete screen.height;
+		delete screen.width;
 	});
 
 	function loadDeferredImagesEnd(keepZoomLevel) {
@@ -204,11 +209,11 @@
 			element.loading = "lazy";
 			element.removeAttribute(LAZY_LOAD_ATTRIBUTE);
 		});
-		delete scrollingElement.clientHeight;
-		delete scrollingElement.clientWidth;
-		delete screen.height;
-		delete screen.width;
 		if (!keepZoomLevel) {
+			delete scrollingElement.clientHeight;
+			delete scrollingElement.clientWidth;
+			delete screen.height;
+			delete screen.width;
 			if (window._singleFile_getBoundingClientRect) {
 				Element.prototype.getBoundingClientRect = window._singleFile_getBoundingClientRect;
 				window.innerHeight = window._singleFile_innerHeight;