Skip to content

Commit

Permalink
Added check to ensure setPause doesn't register a tween multiple time…
Browse files Browse the repository at this point in the history
…s. Added useTicks action mode.

Signed-off-by: Grant Skinner <info@gskinner.com>
  • Loading branch information
gskinner committed Nov 11, 2011
1 parent aa588a3 commit b1e3da3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/tweenjs/Timeline.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var p = Timeline.prototype;
p.loop = false; p.loop = false;


// private properties: // private properties:
p._paused = false; p._paused = true;
p._tweens = null; p._tweens = null;
p._labels = null; p._labels = null;
p._prevPosition = 0; p._prevPosition = 0;
Expand Down Expand Up @@ -147,6 +147,7 @@ var p = Timeline.prototype;


// //
p.setPaused = function(value) { p.setPaused = function(value) {
if (this._paused == !!value) { return; }
this._paused = !!value; this._paused = !!value;
Tween._register(this, !value); Tween._register(this, !value);
} }
Expand Down
13 changes: 10 additions & 3 deletions src/tweenjs/Tween.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -381,16 +381,22 @@ var p = Tween.prototype;
} }


// TODO: deal with multiple loops? // 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 != 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); } if (this._prevPos != this.duration) { this._runActions(this._prevPos, this.duration); }
this._runActions(0, t); this._runActions(0, t);
} else { } else {
this._runActions(this._prevPos, t); this._runActions(this._prevPos, t);
} }
} }
this._prevPos = t;
this._prevPosition = value;


if (t == this.duration && !this.loop) { if (t == this.duration && !this.loop) {
// ended: // ended:
Expand All @@ -417,6 +423,7 @@ var p = Tween.prototype;
**/ **/
// pauses or plays this tween. // pauses or plays this tween.
p.setPaused = function(value) { p.setPaused = function(value) {
if (this._paused == !!value) { return; }
this._paused = !!value; this._paused = !!value;
Tween._register(this, !value); Tween._register(this, !value);
} }
Expand Down

0 comments on commit b1e3da3

Please sign in to comment.