Skip to content

Commit

Permalink
12.0.15
Browse files Browse the repository at this point in the history
- Improved handling of situations where a tween/timeline is added to a timeline that was already finished (it needs to resume playback intuitively).

- Fixed an issue that could cause a timeline's rawTime() to be reported incorrectly in a very rare situation.
  • Loading branch information
jackdoyle committed Sep 3, 2013
1 parent 0ba5781 commit 18c86dd
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 20 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gsap",
"version": "12.0.14",
"version": "12.0.15",
"description": "GreenSock Animation Platform (GSAP) is a suite of high-performance AS3 classes for scripted animation (also available in JavaScript and AS2), including TweenLite, TweenMax, TimelineLite, TimelineMax, various easing equations, and plugins for things like animating along Bezier paths, filters, etc. See http://www.greensock.com/ for details.",
"author": {
"name": "Jack Doyle",
Expand Down
46 changes: 37 additions & 9 deletions src/com/greensock/TimelineLite.as
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* VERSION: 12.0.14
* DATE: 2013-07-27
* VERSION: 12.0.15
* DATE: 2013-09-02
* AS3 (AS2 version is also available)
* UPDATES AND DOCS AT: http://www.greensock.com/timelinelite/
**/
Expand Down Expand Up @@ -268,6 +268,33 @@ var nested = new TimelineLite();
nested.to(mc2, 1, {x:200}));
tl.add(nested);
</listing>
*
* <strong>How do timelines work? What are the mechanics like?</strong>
* <p>Every animation (tween and timeline) is placed on a parent timeline (except the 2 root timelines - there's one for normal tweens and another for "useFrames" ones).
* In a sense, they all have their own playheads (that's what its "time" refers to, or "totalTime" which is identical except that it includes repeats and repeatDelays)
* but generally they're not independent because they're sitting on a timeline whose playhead moves.
* When the parent's playhead moves to a new position, it updates the childrens' too. </p>
*
* <p>When a timeline renders at a particular time, it loops through its children and says "okay, you should render as if your playhead is at ____" and if that child
* is a timeline with children, it does the same to its children, right on down the line. </p>
*
* <p>The only exception is when the tween/timeline is paused in which case its internal playhead acts like it's "locked". So in that case,
* it's possible (likely in fact) that the child's playhead would <strong>not</strong> be synced with the parent's.
* When you unpause it (<code>resume()</code>), it essentially picks it up and moves it so that its internal playhead
* is synchronized with wherever the parent's playhead is at that moment, thus things play perfectly smoothly.
* That is, unless the timeline's <code>smoothChildTiming</code> is to <code>false</code> in which case it won't move -
* its <code>startTime</code> will remain locked to where it was. </p>
*
* <p>So basically, when <code>smoothChildTiming</code> is <code>true</code>, the engine will rearrange things on
* the fly to ensure the playheads line up so that playback is seamless and smooth. The same thing happens when you <code>reverse()</code>
* or alter the <code>timeScale</code>, etc. But sometimes you might not want that behavior - you prefer to have tight
* control over exactly where your tweens line up in the timeline - that's when <code>smoothChildTiming:false</code> is handy.</p>
*
* <p>One more example: let's say you've got a 10-second tween that's just sitting on the root timeline and you're 2-seconds into the tween.
* Let's assume it started at exactly 0 on the root to make this easy, and then when it's at 2-seconds, you do <code>tween.seek(5)</code>.
* The playhead of the root isn't affected - it keeps going exactly as it always did, but in order to make that tween jump to 5 seconds
* and play appropriately, the tween's <code>startTime</code> gets changed to -3. That way, the tween's playhead and the root
* playhead are perfectly aligned. </p>
*
* <p><strong>Copyright 2008-2013, GreenSock. All rights reserved.</strong> This work is subject to the terms in <a href="http://www.greensock.com/terms_of_use.html">http://www.greensock.com/terms_of_use.html</a> or for <a href="http://www.greensock.com/club/">Club GreenSock</a> members, the software agreement that was issued with the membership.</p>
*
Expand All @@ -276,7 +303,7 @@ tl.add(nested);
**/
public class TimelineLite extends SimpleTimeline {
/** @private **/
public static const version:String = "12.0.14";
public static const version:String = "12.0.15";

/** @private **/
protected var _labels:Object;
Expand Down Expand Up @@ -1211,20 +1238,21 @@ tl.add([tween1, tween2, tween3], "+=2", "sequence", 0.5);
} else if (typeof(value) === "function") {
value = TweenLite.delayedCall(0, value);
} else {
trace("Cannot add " + value + " into the TimelineLite/Max: it is neither a tween, timeline, function, nor a String.");
trace("Cannot add " + value + " into the TimelineLite/Max: it is not a tween, timeline, function, or string.");
return this;
}
}

super.add(value, position);

//if the timeline has already ended but the inserted tween/timeline extends the duration, we should enable this timeline again so that it renders properly.
if (_gc) if (!_paused) if (_time === _duration) if (_time < duration()) {
if (_gc) if (!_paused) if (_duration < duration()) {
//in case any of the anscestors had completed but should now be enabled...
var tl:SimpleTimeline = this;
var tl:SimpleTimeline = this,
beforeRawTime:Boolean = (tl.rawTime() > value._startTime); //if the tween is placed on the timeline so that it starts BEFORE the current rawTime, we should align the playhead (move the timeline). This is because sometimes users will create a timeline, let it finish, and much later append a tween and expect it to run instead of jumping to its end state. While technically one could argue that it should jump to its end state, that's not what users intuitively expect.
while (tl._gc && tl._timeline) {
if (tl._timeline.smoothChildTiming) {
tl.totalTime(tl._totalTime, true); //also enables them
if (tl._timeline.smoothChildTiming && beforeRawTime) {
tl.totalTime(tl._totalTime, true); //moves the timeline (shifts its startTime) if necessary, and also enables it.
} else {
tl._enabled(true, false);
}
Expand Down Expand Up @@ -1957,7 +1985,7 @@ myAnimation.totalDuration( 20 ); //adjusts the timeScale so that myAnimation fit
* @return The <code>totalTime</code> of the timeline without capping the number at the <code>totalDuration</code> (max) and zero (minimum)
*/
override public function rawTime():Number {
return (_paused || (_totalTime !== 0 && _totalTime !== _totalDuration)) ? _totalTime : (_timeline.rawTime() - _startTime) * _timeScale;
return _paused ? _totalTime : (_timeline.rawTime() - _startTime) * _timeScale;
}


Expand Down
33 changes: 30 additions & 3 deletions src/com/greensock/TimelineMax.as
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* VERSION: 12.0.14
* DATE: 2013-07-27
* VERSION: 12.0.15
* DATE: 2013-09-02
* AS3 (AS2 version is also available)
* UPDATES AND DOCS AT: http://www.greensock.com/timelinemax/
**/
Expand Down Expand Up @@ -353,6 +353,33 @@ var nested = new TimelineMax();
nested.to(mc2, 1, {x:200}));
tl.add(nested);
</listing>
*
* <strong>How do timelines work? What are the mechanics like?</strong>
* <p>Every animation (tween and timeline) is placed on a parent timeline (except the 2 root timelines - there's one for normal tweens and another for "useFrames" ones).
* In a sense, they all have their own playheads (that's what its "time" refers to, or "totalTime" which is identical except that it includes repeats and repeatDelays)
* but generally they're not independent because they're sitting on a timeline whose playhead moves.
* When the parent's playhead moves to a new position, it updates the childrens' too. </p>
*
* <p>When a timeline renders at a particular time, it loops through its children and says "okay, you should render as if your playhead is at ____" and if that child
* is a timeline with children, it does the same to its children, right on down the line. </p>
*
* <p>The only exception is when the tween/timeline is paused in which case its internal playhead acts like it's "locked". So in that case,
* it's possible (likely in fact) that the child's playhead would <strong>not</strong> be synced with the parent's.
* When you unpause it (<code>resume()</code>), it essentially picks it up and moves it so that its internal playhead
* is synchronized with wherever the parent's playhead is at that moment, thus things play perfectly smoothly.
* That is, unless the timeline's <code>smoothChildTiming</code> is to <code>false</code> in which case it won't move -
* its <code>startTime</code> will remain locked to where it was. </p>
*
* <p>So basically, when <code>smoothChildTiming</code> is <code>true</code>, the engine will rearrange things on
* the fly to ensure the playheads line up so that playback is seamless and smooth. The same thing happens when you <code>reverse()</code>
* or alter the <code>timeScale</code>, etc. But sometimes you might not want that behavior - you prefer to have tight
* control over exactly where your tweens line up in the timeline - that's when <code>smoothChildTiming:false</code> is handy.</p>
*
* <p>One more example: let's say you've got a 10-second tween that's just sitting on the root timeline and you're 2-seconds into the tween.
* Let's assume it started at exactly 0 on the root to make this easy, and then when it's at 2-seconds, you do <code>tween.seek(5)</code>.
* The playhead of the root isn't affected - it keeps going exactly as it always did, but in order to make that tween jump to 5 seconds
* and play appropriately, the tween's <code>startTime</code> gets changed to -3. That way, the tween's playhead and the root
* playhead are perfectly aligned. </p>
*
* <p><strong>Copyright 2008-2013, GreenSock. All rights reserved.</strong> This work is subject to the terms in <a href="http://www.greensock.com/terms_of_use.html">http://www.greensock.com/terms_of_use.html</a> or for <a href="http://www.greensock.com/club/">Club GreenSock</a> members, the software agreement that was issued with the membership.</p>
*
Expand All @@ -361,7 +388,7 @@ tl.add(nested);
**/
public class TimelineMax extends TimelineLite implements IEventDispatcher {
/** @private **/
public static const version:String = "12.0.14";
public static const version:String = "12.0.15";
/** @private **/
protected static var _listenerLookup:Object = {onCompleteListener:TweenEvent.COMPLETE, onUpdateListener:TweenEvent.UPDATE, onStartListener:TweenEvent.START, onRepeatListener:TweenEvent.REPEAT, onReverseCompleteListener:TweenEvent.REVERSE_COMPLETE};
/** @private **/
Expand Down
8 changes: 4 additions & 4 deletions src/com/greensock/TweenLite.as
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* VERSION: 12.0.14
* DATE: 2013-07-27
* VERSION: 12.0.15
* DATE: 2013-09-02
* AS3 (AS2 version is also available)
* UPDATES AND DOCS AT: http://www.greensock.com
**/
Expand Down Expand Up @@ -304,7 +304,7 @@ package com.greensock {
public class TweenLite extends Animation {

/** @private **/
public static const version:String = "12.0.14";
public static const version:String = "12.0.15";

/** Provides An easy way to change the default easing equation. Choose from any of the GreenSock eases in the <code>com.greensock.easing</code> package. @default Power1.easeOut **/
public static var defaultEase:Ease = new Ease(null, null, 1, 1);
Expand Down Expand Up @@ -570,7 +570,7 @@ package com.greensock {

/** @private Loops through the <code>vars</code> properties, captures starting values, triggers overwriting if necessary, etc. **/
protected function _initProps(target:Object, propLookup:Object, siblings:Array, overwrittenProps:Object):Boolean {
var vars = this.vars,
var vars:Object = this.vars,
p:String, i:int, initPlugins:Boolean, plugin:Object, val:Object;
if (target == null) {
return false;
Expand Down
6 changes: 3 additions & 3 deletions src/com/greensock/TweenMax.as
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* VERSION: 12.0.14
* DATE: 2013-07-29
* VERSION: 12.0.15
* DATE: 2013-09-02
* AS3 (AS2 version is also available)
* UPDATES AND DOCS AT: http://www.greensock.com
**/
Expand Down Expand Up @@ -530,7 +530,7 @@ package com.greensock {
*/
public class TweenMax extends TweenLite implements IEventDispatcher {
/** @private **/
public static const version:String = "12.0.14";
public static const version:String = "12.0.15";

TweenPlugin.activate([

Expand Down

0 comments on commit 18c86dd

Please sign in to comment.