Skip to content

Commit

Permalink
Fix Element animate to properly queue subsequent animations (Addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
Meiguro committed Feb 28, 2016
1 parent c3c6b9c commit 2b93281
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/js/ui/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,12 @@ StageElement.prototype.animate = function(field, value, duration) {
duration = value;
}
var animateDef = myutil.toObject(field, value);
function animate() {
this.queue(function() {
this._animate(animateDef, duration);
util2.copy(animateDef, this.state);
}
if (this._queue.length === 0) {
animate.call(this);
} else {
this.queue(animate);
});
if (!this.state.animating) {
this.dequeue();
}
return this;
};
Expand All @@ -98,8 +96,12 @@ StageElement.prototype.queue = function(callback) {

StageElement.prototype.dequeue = function() {
var callback = this._queue.shift();
if (!callback) { return; }
callback.call(this, this.dequeue.bind(this));
if (callback) {
this.state.animating = true;
callback.call(this, this.dequeue.bind(this));
} else {
this.state.animating = false;
}
};

StageElement.emitAnimateDone = function(id) {
Expand Down

0 comments on commit 2b93281

Please sign in to comment.