Skip to content

Commit

Permalink
fix(animationFrame): req/cancel animationFrame has to be called withi…
Browse files Browse the repository at this point in the history
…n the context of root.
  • Loading branch information
trxcllnt authored and benlesh committed Jan 13, 2016
1 parent e637b78 commit 30a11ee
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/util/AnimationFrame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ export class RequestAnimationFrameDefinition {
requestAnimationFrame: (cb: () => void) => number;
constructor(root: any) {
if (root.requestAnimationFrame) {
this.cancelAnimationFrame = root.cancelAnimationFrame;
this.requestAnimationFrame = root.requestAnimationFrame;
this.cancelAnimationFrame = root.cancelAnimationFrame.bind(root);
this.requestAnimationFrame = root.requestAnimationFrame.bind(root);
} else if (root.mozRequestAnimationFrame) {
this.cancelAnimationFrame = root.mozCancelAnimationFrame;
this.requestAnimationFrame = root.mozRequestAnimationFrame;
this.cancelAnimationFrame = root.mozCancelAnimationFrame.bind(root);
this.requestAnimationFrame = root.mozRequestAnimationFrame.bind(root);
} else if (root.webkitRequestAnimationFrame) {
this.cancelAnimationFrame = root.webkitCancelAnimationFrame;
this.requestAnimationFrame = root.webkitRequestAnimationFrame;
this.cancelAnimationFrame = root.webkitCancelAnimationFrame.bind(root);
this.requestAnimationFrame = root.webkitRequestAnimationFrame.bind(root);
} else if (root.msRequestAnimationFrame) {
this.cancelAnimationFrame = root.msCancelAnimationFrame;
this.requestAnimationFrame = root.msRequestAnimationFrame;
this.cancelAnimationFrame = root.msCancelAnimationFrame.bind(root);
this.requestAnimationFrame = root.msRequestAnimationFrame.bind(root);
} else if (root.oRequestAnimationFrame) {
this.cancelAnimationFrame = root.oCancelAnimationFrame;
this.requestAnimationFrame = root.oRequestAnimationFrame;
this.cancelAnimationFrame = root.oCancelAnimationFrame.bind(root);
this.requestAnimationFrame = root.oRequestAnimationFrame.bind(root);
} else {
this.cancelAnimationFrame = root.clearTimeout;
this.cancelAnimationFrame = root.clearTimeout.bind(root);
this.requestAnimationFrame = function(cb) { return root.setTimeout(cb, 1000 / 60); };
}
}
Expand Down

0 comments on commit 30a11ee

Please sign in to comment.