From 4b17f802b6f9b3baf9b6a794c5c5c1fb103aa4d7 Mon Sep 17 00:00:00 2001 From: Chetan Surpur Date: Sat, 22 Aug 2015 23:02:49 -0700 Subject: [PATCH 1/2] Option to animate immediately --- src/Animator.js | 12 ++++++++---- src/Stage.js | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Animator.js b/src/Animator.js index 251be8b..eabec4d 100644 --- a/src/Animator.js +++ b/src/Animator.js @@ -54,7 +54,7 @@ MathBox.Animator.prototype = { } // Stop all animations on the given keys - animator.stop(this, stop); + animator.stop(this, stop, true); } // Pass through to Attributes @@ -84,11 +84,11 @@ MathBox.Animator.prototype = { /** * Stop all animations on an object. */ - stop: function (object, keys) { - // Dequeue all animations, applying instantly. + stop: function (object, keys, apply) { + // Dequeue all animations, applying if requested. _.each(keys || object.__queue, function (queue, key) { while (object.__queue[key]) { - this.dequeue(object, key, true); + this.dequeue(object, key, apply); } }.bind(this)); }, @@ -105,6 +105,10 @@ MathBox.Animator.prototype = { this.attach(object); _.each(attributes, function (value, key) { + if (options.immediately) { + this.stop(object, [key], false); + } + // Init queue if necessary. var queue = object.__queue[key] = object.__queue[key] || []; diff --git a/src/Stage.js b/src/Stage.js index 1f874e8..14e25f2 100644 --- a/src/Stage.js +++ b/src/Stage.js @@ -477,8 +477,8 @@ MathBox.Stage.prototype = _.extend(MathBox.Stage.prototype, { var animator = this.animator; _.each(this.select(selector, true), function (primitive) { - animator.stop(primitive, keys); - primitive.style && animator.stop(primitive.style, keys); + animator.stop(primitive, keys, true); + primitive.style && animator.stop(primitive.style, keys, true); }); return this; From ffaae7efaf3162ff0758e8c5e5aad9cd561e78f0 Mon Sep 17 00:00:00 2001 From: Chetan Surpur Date: Sat, 22 Aug 2015 23:12:18 -0700 Subject: [PATCH 2/2] Fix bug with incorrect parameter order in callback --- src/Animator.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Animator.js b/src/Animator.js index eabec4d..7162cf2 100644 --- a/src/Animator.js +++ b/src/Animator.js @@ -74,7 +74,7 @@ MathBox.Animator.prototype = { factor = factor || 4; // Reduce - _.each(keys || object.__queue, function (queue, key) { + _.each(keys || object.__queue, function (key) { _.each(object.__queue[key], function (op) { op.hurry(factor); }); @@ -86,7 +86,7 @@ MathBox.Animator.prototype = { */ stop: function (object, keys, apply) { // Dequeue all animations, applying if requested. - _.each(keys || object.__queue, function (queue, key) { + _.each(keys || object.__queue, function (key) { while (object.__queue[key]) { this.dequeue(object, key, apply); }