|
|
@@ -30,9 +30,9 @@ this.lazyLoader = this.lazyLoader || (() => {
|
|
|
|
|
|
function process(options) {
|
|
|
return new Promise(async resolve => {
|
|
|
- let timeoutId, idleTimeoutId, maxTimeoutId, loadingImages, observer, pendingImages = new Set();
|
|
|
- maxTimeoutId = await deferForceLazyLoadEnd(timeoutId, idleTimeoutId, maxTimeoutId, observer, options, cleanupAndResolve);
|
|
|
- observer = new MutationObserver(async mutations => {
|
|
|
+ let timeoutId, idleTimeoutId, maxTimeoutId, loadingImages;
|
|
|
+ const pendingImages = new Set();
|
|
|
+ const observer = new MutationObserver(async mutations => {
|
|
|
mutations = mutations.filter(mutation => mutation.type == ATTRIBUTES_MUTATION_TYPE);
|
|
|
if (mutations.length) {
|
|
|
const updated = mutations.filter(mutation => {
|
|
|
@@ -52,13 +52,14 @@ this.lazyLoader = this.lazyLoader || (() => {
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
- observer.observe(document, { subtree: true, childList: true, attributes: true });
|
|
|
idleTimeoutId = await setAsyncTimeout(() => {
|
|
|
if (!loadingImages) {
|
|
|
clearAsyncTimeout(timeoutId);
|
|
|
lazyLoadEnd(idleTimeoutId, observer, cleanupAndResolve);
|
|
|
}
|
|
|
}, options.loadDeferredImagesMaxIdleTime * 1.2);
|
|
|
+ maxTimeoutId = await deferForceLazyLoadEnd(timeoutId, idleTimeoutId, maxTimeoutId, observer, options, cleanupAndResolve);
|
|
|
+ observer.observe(document, { subtree: true, childList: true, attributes: true });
|
|
|
addEventListener(hooksFrame.LOAD_IMAGE_EVENT, onImageLoadEvent);
|
|
|
addEventListener(hooksFrame.IMAGE_LOADED_EVENT, onImageLoadedEvent);
|
|
|
if (typeof hooksFrame != "undefined") {
|