From 7faffc2de7993bfbb86fa9c573596e26a34f1e69 Mon Sep 17 00:00:00 2001 From: cacaodev Date: Fri, 6 May 2016 18:16:12 +0200 Subject: [PATCH] Use cancelAnimationFrame when available --- AppKit/CoreAnimation/CPAnimationContext.j | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/AppKit/CoreAnimation/CPAnimationContext.j b/AppKit/CoreAnimation/CPAnimationContext.j index f39bf912c..797a7cfdf 100644 --- a/AppKit/CoreAnimation/CPAnimationContext.j +++ b/AppKit/CoreAnimation/CPAnimationContext.j @@ -612,6 +612,7 @@ CFRunLoopRemoveObserver = function(runloop, observer, mode) var FrameUpdater = function(anIdentifier) { this._identifier = anIdentifier; + this._requestId = null; this._duration = 0; this._stop = false; this._targets = []; @@ -636,11 +637,15 @@ var FrameUpdater = function(anIdentifier) FrameUpdater.prototype.start = function() { - window.requestAnimationFrame(this._updateFunction); + this._requestId = window.requestAnimationFrame(this._updateFunction); }; FrameUpdater.prototype.stop = function() { + // window.cancelAnimationFrame support is Chrome 24, Firefox 23, IE 10, Opera 15, Safari 6.1 + if (window.cancelAnimationFrame) + window.cancelAnimationFrame(this._requestId); + this._stop = true; };