Skip to content

Commit

Permalink
Apply timeout to requestIdleCallback
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
taehwanno committed Feb 1, 2019
1 parent cd22266 commit ce5dc97
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/internal/extension-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -15,7 +17,7 @@ class ExtensionProxy implements IExtension {

public activate() {
if (!this.isActivated) {
window.requestIdleCallback(this.handleActivate);
window.requestIdleCallback(this.handleActivate, { timeout });
}
}

Expand All @@ -32,7 +34,7 @@ class ExtensionProxy implements IExtension {
this.isActivated = true;
this.extension.activate();
} else {
window.requestIdleCallback(this.handleActivate);
window.requestIdleCallback(this.handleActivate, { timeout });
}
}

Expand Down

0 comments on commit ce5dc97

Please sign in to comment.