Permalink
Browse files

Added check to ensure setPause doesn't register a tween multiple time…

…s. Added useTicks action mode.

Signed-off-by: Grant Skinner <info@gskinner.com>
  • Loading branch information...
1 parent aa588a3 commit b1e3da39b44857e003865b19916a7fb01ce7261d @gskinner gskinner committed Nov 11, 2011
Showing with 12 additions and 4 deletions.
  1. +2 −1 src/tweenjs/Timeline.js
  2. +10 −3 src/tweenjs/Tween.js
View
@@ -52,7 +52,7 @@ var p = Timeline.prototype;
p.loop = false;
// private properties:
- p._paused = false;
+ p._paused = true;
p._tweens = null;
p._labels = null;
p._prevPosition = 0;
@@ -147,6 +147,7 @@ var p = Timeline.prototype;
//
p.setPaused = function(value) {
+ if (this._paused == !!value) { return; }
this._paused = !!value;
Tween._register(this, !value);
}
View
@@ -381,16 +381,22 @@ var p = Tween.prototype;
}
// TODO: deal with multiple loops?
+ var prevPos = this._prevPos;
+ var prevPosition = this._prevPosition;
+ // set these in advance in case an action modifies position.
+ this._prevPos = t;
+ this._prevPosition = value;
if (actionsMode != 0 && this._actions.length > 0) {
- if (actionsMode == 2 && t<this._prevPos) {
+ if (this._useTicks) {
+ // only run the actions we landed on.
+ this._runActions(t,t);
+ } else if (actionsMode == 2 && t<this._prevPos) {
if (this._prevPos != this.duration) { this._runActions(this._prevPos, this.duration); }
this._runActions(0, t);
} else {
this._runActions(this._prevPos, t);
}
}
- this._prevPos = t;
- this._prevPosition = value;
if (t == this.duration && !this.loop) {
// ended:
@@ -417,6 +423,7 @@ var p = Tween.prototype;
**/
// pauses or plays this tween.
p.setPaused = function(value) {
+ if (this._paused == !!value) { return; }
this._paused = !!value;
Tween._register(this, !value);
}

0 comments on commit b1e3da3

Please sign in to comment.