Explorar el Código

minor refactoring

Gildas hace 7 años
padre
commit
6d5915680e
Se han modificado 1 ficheros con 6 adiciones y 6 borrados
  1. 6 6
      lib/lazy/content/content-lazy-loader.js

+ 6 - 6
lib/lazy/content/content-lazy-loader.js

@@ -33,12 +33,6 @@ this.lazyLoader = this.lazyLoader || (() => {
 	function process(options) {
 		return new Promise(async resolve => {
 			let timeoutId, srcAttributeChanged;
-			const idleTimeoutId = await setTimeout(() => {
-				if (!srcAttributeChanged) {
-					clearTimeout(timeoutId);
-					lazyLoadEnd(maxTimeoutId, idleTimeoutId, observer, options, resolve);
-				}
-			}, options.maxLazyLoadImagesIdleTime * 1.2);
 			const maxTimeoutId = await setTimeout(() => {
 				clearTimeout(timeoutId);
 				lazyLoadEnd(maxTimeoutId, idleTimeoutId, observer, options, resolve);
@@ -56,6 +50,12 @@ this.lazyLoader = this.lazyLoader || (() => {
 				}
 			});
 			observer.observe(document, { attributeFilter: MONITORED_ATTRIBUTES, subtree: true, childList: true, attributes: true });
+			const idleTimeoutId = await setTimeout(() => {
+				if (!srcAttributeChanged) {
+					clearTimeout(timeoutId);
+					lazyLoadEnd(maxTimeoutId, idleTimeoutId, observer, options, resolve);
+				}
+			}, options.maxLazyLoadImagesIdleTime * 1.2);
 			injectScript(SCRIPT_BEFORE_PATH);
 		});
 	}