Skip to content

Commit

Permalink
Added position config prop to Tween and Timeline. Timeline immediatel…
Browse files Browse the repository at this point in the history
…y synchs added Tweens. Timeline checks for unchanged position before updating.

Signed-off-by: Grant Skinner <info@gskinner.com>
  • Loading branch information
gskinner committed Jan 18, 2012
1 parent 37bc6f4 commit d79affb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/tweenjs/Timeline.js
Expand Up @@ -47,6 +47,7 @@
* <LI> useTicks: uses ticks for all durations instead of milliseconds.</LI>
* <LI> ignoreGlobalPause: sets the ignoreGlobalPause property on this tween.</LI>
* <LI> paused: indicates whether to start the tween paused.</LI>
* <LI> position: indicates the initial position for this timeline</LI>
* </UL>
* @constructor
**/
Expand Down Expand Up @@ -139,6 +140,7 @@ var p = Timeline.prototype;
if (tweens) { this.addTween.apply(this, tweens); }
this.setLabels(labels);
if (!props||!props.paused) { Tween._register(this,true); }
if (props&&props.position!=null) { this.setPosition(props.position, Tween.NONE); }
}

// public methods:
Expand All @@ -161,6 +163,7 @@ var p = Timeline.prototype;
tween._paused = false;
tween._useTicks = this._useTicks;
if (tween.duration > this.duration) { this.duration = tween.duration; }
tween.setPosition(this._prevPos, Tween.NONE);
return tween;
}

Expand Down Expand Up @@ -234,6 +237,7 @@ var p = Timeline.prototype;
p.setPosition = function(value, actionsMode) {
var t = this.loop ? value%this.duration : value;
var end = !this.loop && value >= this.duration;
if (t == this._prevPos) { return end; }
this._prevPosition = value;
this._prevPos = t; // in case an action changes the current frame.
for (var i=0, l=this._tweens.length; i<l; i++) {
Expand Down
4 changes: 3 additions & 1 deletion src/tweenjs/Tween.js
Expand Up @@ -35,7 +35,7 @@
* @module TweenJS
**/

// TODO: possibly add a END actionsMode (only runs actions that == position)
// TODO: possibly add a END actionsMode (only runs actions that == position)?
// TODO: evaluate a way to decouple paused from tick registration.
(function(window) {
/**
Expand Down Expand Up @@ -109,6 +109,7 @@ var p = Tween.prototype;
* <LI> ignoreGlobalPause: sets the ignoreGlobalPause property on this tween.</LI>
* <LI> override: if true, Tween.removeTweens(target) will be called to remove any other tweens with the same target.
* <LI> paused: indicates whether to start the tween paused.</LI>
* <LI> position: indicates the initial position for this timeline</LI>
* </UL>
**/
Tween.get = function(target, props) {
Expand Down Expand Up @@ -333,6 +334,7 @@ var p = Tween.prototype;
this._actions = [];
this._catalog = [];
if (!props||!props.paused) { Tween._register(this,true); }
if (props&&props.position!=null) { this.setPosition(props.position, Tween.NONE); }
}

// public methods:
Expand Down

0 comments on commit d79affb

Please sign in to comment.