diff options
Diffstat (limited to 'lib/fastdom.js')
-rw-r--r-- | lib/fastdom.js | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/fastdom.js b/lib/fastdom.js index 036a2dc..a5f98ad 100644 --- a/lib/fastdom.js +++ b/lib/fastdom.js @@ -197,14 +197,16 @@ * by the number of frames * specified. * - * @param {Function} fn * @param {Number} frames + * @param {Function} fn * @api public */ - FastDom.prototype.defer = function(fn, frames) { + FastDom.prototype.defer = function(frames, fn, ctx) { + if (frames < 0) return; + (function wrapped() { if (frames-- === 0) { - try { fn(); } catch (e) { + try { fn.call(ctx); } catch (e) { if (this.onError) this.onError(e); } } else { @@ -266,4 +268,4 @@ window['fastdom'] = fastdom; } -})(window.fastdom);
\ No newline at end of file +})(window.fastdom); |