From ce5dc97bbe4d4d94b46fc00630d4d2a4e0a01198 Mon Sep 17 00:00:00 2001 From: Taehwan Noh Date: Fri, 1 Feb 2019 10:34:57 +0900 Subject: [PATCH] Apply timeout to requestIdleCallback Since there is a delay in initialization when the first post on the screen is a video, it forces timeout to be executed within that time. --- src/internal/extension-proxy.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/internal/extension-proxy.ts b/src/internal/extension-proxy.ts index e149876..e544af3 100644 --- a/src/internal/extension-proxy.ts +++ b/src/internal/extension-proxy.ts @@ -2,6 +2,8 @@ import bind from './bind'; import Extension, { IExtension } from './extension'; import postElement from './post-element'; +const timeout = 2000; + class ExtensionProxy implements IExtension { private executionCount: number; private extension: Extension; @@ -15,7 +17,7 @@ class ExtensionProxy implements IExtension { public activate() { if (!this.isActivated) { - window.requestIdleCallback(this.handleActivate); + window.requestIdleCallback(this.handleActivate, { timeout }); } } @@ -32,7 +34,7 @@ class ExtensionProxy implements IExtension { this.isActivated = true; this.extension.activate(); } else { - window.requestIdleCallback(this.handleActivate); + window.requestIdleCallback(this.handleActivate, { timeout }); } }