|
|
@@ -18,7 +18,7 @@
|
|
|
* along with SingleFile. If not, see <http://www.gnu.org/licenses/>.
|
|
|
*/
|
|
|
|
|
|
-/* global browser, document, timeout, MutationObserver */
|
|
|
+/* global browser, document, timeout, MutationObserver, setTimeout, clearTimeout */
|
|
|
|
|
|
this.lazyLoader = this.lazyLoader || (() => {
|
|
|
|
|
|
@@ -39,10 +39,10 @@ this.lazyLoader = this.lazyLoader || (() => {
|
|
|
lazyLoadEnd(maxTimeoutId, idleTimeoutId, observer, options, resolve);
|
|
|
}
|
|
|
}, options.maxLazyLoadImagesIdleTime * 1.2);
|
|
|
- const maxTimeoutId = timeout.set(() => {
|
|
|
+ const maxTimeoutId = setTimeout(() => {
|
|
|
timeout.clear(timeoutId);
|
|
|
lazyLoadEnd(maxTimeoutId, idleTimeoutId, observer, options, resolve);
|
|
|
- }, options.maxLazyLoadImagesIdleTime * 10);
|
|
|
+ }, options.maxLazyLoadImagesIdleTime * 3);
|
|
|
const observer = new MutationObserver(mutations => {
|
|
|
mutations = mutations.filter(mutation => mutation.type == ATTRIBUTES_MUTATION_TYPE);
|
|
|
if (mutations.length) {
|
|
|
@@ -66,9 +66,9 @@ this.lazyLoader = this.lazyLoader || (() => {
|
|
|
}
|
|
|
|
|
|
function lazyLoadEnd(maxTimeoutId, idleTimeoutId, observer, options, resolve) {
|
|
|
- timeout.clear(maxTimeoutId);
|
|
|
+ clearTimeout(maxTimeoutId);
|
|
|
timeout.clear(idleTimeoutId);
|
|
|
- timeout.set(resolve, options.maxLazyLoadImagesIdleTime);
|
|
|
+ resolve();
|
|
|
injectScript(SCRIPT_AFTER_PATH);
|
|
|
observer.disconnect();
|
|
|
}
|