Skip to content

Commit

Permalink
12.0.8
Browse files Browse the repository at this point in the history
- Fixed issue that could cause zero-duration tweens/callbacks at the
very beginning of a timeline not to fire their onReverseComplete if the
playhead lands on a SUPER small value, like 0.000001 seconds.

- Adjusted the behavior of TimelineMax's tweenFromTo() method so that
it seeks to the initial from() spot. That way, events/callbacks are
suppressed which seems like the more natural behavior.
  • Loading branch information
jackdoyle committed Apr 30, 2013
1 parent 9737020 commit 7c0967f
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 22 deletions.
19 changes: 11 additions & 8 deletions src/com/greensock/TimelineLite.as
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* VERSION: 12.0.6
* DATE: 2013-04-03
* VERSION: 12.0.8
* DATE: 2013-04-27
* AS3 (AS2 version is also available)
* UPDATES AND DOCS AT: http://www.greensock.com/timelinelite/
**/
Expand Down Expand Up @@ -276,7 +276,7 @@ tl.add(nested);
**/
public class TimelineLite extends SimpleTimeline {
/** @private **/
public static const version:String = "12.0.6";
public static const version:String = "12.0.8";
/** @private **/
protected static const _paramProps:Array = ["onStartParams","onUpdateParams","onCompleteParams","onReverseCompleteParams","onRepeatParams"];

Expand Down Expand Up @@ -1131,7 +1131,7 @@ tl.add(otherTimeline, "myLabel");
tl.add([tween1, tween2, tween3], "myLabel+=2");
//add an array of tweens so that they are sequenced one-after-the-other with 0.5 seconds inbetween them, starting 2 seconds after the end of the timeline
tl.add([tween1, tween2, tween3], "+=2", "stagger", 0.5);
tl.add([tween1, tween2, tween3], "+=2", "sequence", 0.5);
</listing>
*
* @param value The tween, timeline, callback, or label (or array of them) to add
Expand Down Expand Up @@ -1466,8 +1466,11 @@ myAnimation.seek("myLabel");
if (!_reversed) if (!_hasPausedChild()) {
isComplete = true;
callback = "onComplete";
if (_duration == 0) if (time == 0 || _rawPrevTime < 0) if (_rawPrevTime != time) { //In order to accommodate zero-duration timelines, we must discern the momentum/direction of time in order to render values properly when the "playhead" goes past 0 in the forward direction or lands directly on it, and also when it moves past it in the backward direction (from a postitive time to a negative time).
if (_duration == 0) if (time == 0 || _rawPrevTime < 0) if (_rawPrevTime != time && _first) { //In order to accommodate zero-duration timelines, we must discern the momentum/direction of time in order to render values properly when the "playhead" goes past 0 in the forward direction or lands directly on it, and also when it moves past it in the backward direction (from a postitive time to a negative time).
internalForce = true;
if (_rawPrevTime > 0) {
callback = "onReverseComplete";
}
}
}
_rawPrevTime = time;
Expand All @@ -1481,20 +1484,20 @@ myAnimation.seek("myLabel");
}
if (time < 0) {
_active = false;
if (_duration == 0) if (_rawPrevTime >= 0) { //zero-duration timelines are tricky because we must discern the momentum/direction of time in order to determine whether the starting values should be rendered or the ending values. If the "playhead" of its timeline goes past the zero-duration tween in the forward direction or lands directly on it, the end values should be rendered, but if the timeline's "playhead" moves past it in the backward direction (from a postitive time to a negative time), the starting values must be rendered.
if (_duration == 0) if (_rawPrevTime >= 0 && _first) { //zero-duration timelines are tricky because we must discern the momentum/direction of time in order to determine whether the starting values should be rendered or the ending values. If the "playhead" of its timeline goes past the zero-duration tween in the forward direction or lands directly on it, the end values should be rendered, but if the timeline's "playhead" moves past it in the backward direction (from a postitive time to a negative time), the starting values must be rendered.
internalForce = true;
}
} else if (!_initted) {
internalForce = true;
}
_rawPrevTime = time;
//time = -0.0000001; //to avoid occasional floating point rounding errors in Flash - sometimes child tweens/timelines were not being rendered at the very beginning (their progress might be 0.000000000001 instead of 0 because when Flash performed _time - tween._startTime, floating point errors would return a value that was SLIGHTLY off)
time = 0; //to avoid occasional floating point rounding errors (could cause problems especially with zero-duration tweens at the very beginning of the timeline)

} else {
_totalTime = _time = _rawPrevTime = time;
}

if (_time == prevTime && !force && !internalForce) {
if ((_time == prevTime || !_first) && !force && !internalForce) {
return;
} else if (!_initted) {
_initted = true;
Expand Down
24 changes: 16 additions & 8 deletions src/com/greensock/TimelineMax.as
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* VERSION: 12.0.6
* DATE: 2013-04-03
* VERSION: 12.0.8
* DATE: 2013-04-27
* AS3 (AS2 version is also available)
* UPDATES AND DOCS AT: http://www.greensock.com/timelinemax/
**/
Expand Down Expand Up @@ -361,7 +361,7 @@ tl.add(nested);
**/
public class TimelineMax extends TimelineLite implements IEventDispatcher {
/** @private **/
public static const version:String = "12.0.6";
public static const version:String = "12.0.8";
/** @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 Expand Up @@ -758,6 +758,9 @@ tl.add( myTimeline.tweenFromTo("myLabel2", 0) );
* and it does not automatically resume after the tween completes. If you need to resume playback,
* you can always use an onComplete to call the <code>resume()</code> method.</p>
*
* <p>Like all from-type methods in GSAP, <code>immediateRender</code> is <code>true</code> by default,
* meaning the timeline will immediately jump to the "from" time/label unless you set <code>immediateRender:false</code></p>
*
* @param fromPosition The beginning time in seconds (or frame if the timeline is frames-based) or label from which the timeline should play. For example, <code>myTimeline.tweenTo(0, 5)</code> would play from 0 (the beginning) to the 5-second point whereas <code>myTimeline.tweenFromTo("myLabel1", "myLabel2")</code> would play from "myLabel1" to "myLabel2".
* @param toPosition The destination time in seconds (or frame if the timeline is frames-based) or label to which the timeline should play. For example, <code>myTimeline.tweenTo(0, 5)</code> would play from 0 (the beginning) to the 5-second point whereas <code>myTimeline.tweenFromTo("myLabel1", "myLabel2")</code> would play from "myLabel1" to "myLabel2".
* @param vars An optional vars object that will be passed to the TweenLite instance. This allows you to define an onComplete, ease, delay, or any other TweenLite special property. onInit is the only special property that is not available (<code>tweenFromTo()</code> sets it internally)
Expand All @@ -768,9 +771,11 @@ tl.add( myTimeline.tweenFromTo("myLabel2", 0) );
*/
public function tweenFromTo(fromPosition:*, toPosition:*, vars:Object=null):TweenLite {
vars = vars || {};
vars.startAt = {time:_parseTimeOrLabel(fromPosition)};
fromPosition = _parseTimeOrLabel(fromPosition);
vars.startAt = {onComplete:seek, onCompleteParams:[fromPosition]};
vars.immediateRender = (vars.immediateRender !== false);
var t:TweenLite = tweenTo(toPosition, vars);
return t.duration((Math.abs( t.vars.time - t.vars.startAt.time) / _timeScale) || 0.001) as TweenLite;
return t.duration((Math.abs( t.vars.time - fromPosition) / _timeScale) || 0.001) as TweenLite;
}


Expand All @@ -797,8 +802,11 @@ tl.add( myTimeline.tweenFromTo("myLabel2", 0) );
if (!_reversed) if (!_hasPausedChild()) {
isComplete = true;
callback = "onComplete";
if (_duration == 0) if (time == 0 || _rawPrevTime < 0) if (_rawPrevTime != time) { //In order to accommodate zero-duration timelines, we must discern the momentum/direction of time in order to render values properly when the "playhead" goes past 0 in the forward direction or lands directly on it, and also when it moves past it in the backward direction (from a postitive time to a negative time).
if (_duration == 0) if (time == 0 || _rawPrevTime < 0) if (_rawPrevTime != time && _first) { //In order to accommodate zero-duration timelines, we must discern the momentum/direction of time in order to render values properly when the "playhead" goes past 0 in the forward direction or lands directly on it, and also when it moves past it in the backward direction (from a postitive time to a negative time).
internalForce = true;
if (_rawPrevTime > 0) {
callback = "onReverseComplete";
}
}
}
_rawPrevTime = time;
Expand All @@ -820,7 +828,7 @@ tl.add( myTimeline.tweenFromTo("myLabel2", 0) );
}
if (time < 0) {
_active = false;
if (_duration == 0) if (_rawPrevTime >= 0) { //zero-duration timelines are tricky because we must discern the momentum/direction of time in order to determine whether the starting values should be rendered or the ending values. If the "playhead" of its timeline goes past the zero-duration tween in the forward direction or lands directly on it, the end values should be rendered, but if the timeline's "playhead" moves past it in the backward direction (from a postitive time to a negative time), the starting values must be rendered.
if (_duration == 0) if (_rawPrevTime >= 0 && _first) { //zero-duration timelines are tricky because we must discern the momentum/direction of time in order to determine whether the starting values should be rendered or the ending values. If the "playhead" of its timeline goes past the zero-duration tween in the forward direction or lands directly on it, the end values should be rendered, but if the timeline's "playhead" moves past it in the backward direction (from a postitive time to a negative time), the starting values must be rendered.
internalForce = true;
}
} else if (!_initted) {
Expand Down Expand Up @@ -903,7 +911,7 @@ tl.add( myTimeline.tweenFromTo("myLabel2", 0) );
_locked = false;
}

if (_time == prevTime && !force && !internalForce) {
if ((_time == prevTime || !_first) && !force && !internalForce) {
if (prevTotalTime !== _totalTime) if (_onUpdate != null) if (!suppressEvents) { //so that onUpdate fires even during the repeatDelay - as long as the totalTime changed, we should trigger onUpdate.
_onUpdate.apply(vars.onUpdateScope || this, vars.onUpdateParams);
}
Expand Down
9 changes: 6 additions & 3 deletions src/com/greensock/TweenLite.as
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* VERSION: 12.0.7
* DATE: 2013-04-18
* VERSION: 12.0.8
* DATE: 2013-04-27
* 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.7";
public static const version:String = "12.0.8";

/** 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 @@ -629,6 +629,9 @@ package com.greensock {
if (_duration == 0) { //zero-duration tweens are tricky because we must discern the momentum/direction of time in order to determine whether the starting values should be rendered or the ending values. If the "playhead" of its timeline goes past the zero-duration tween in the forward direction or lands directly on it, the end values should be rendered, but if the timeline's "playhead" moves past it in the backward direction (from a postitive time to a negative time), the starting values must be rendered.
if (time == 0 || _rawPrevTime < 0) if (_rawPrevTime != time) {
force = true;
if (_rawPrevTime > 0) {
callback = "onReverseComplete";
}
}
_rawPrevTime = time;
}
Expand Down
9 changes: 6 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.7
* DATE: 2013-04-18
* VERSION: 12.0.8
* DATE: 2013-04-27
* 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.7";
public static const version:String = "12.0.8";

TweenPlugin.activate([

Expand Down Expand Up @@ -874,6 +874,9 @@ tween.updateTo({x:300, y:0}, false);
if (_duration == 0) { //zero-duration tweens are tricky because we must discern the momentum/direction of time in order to determine whether the starting values should be rendered or the ending values. If the "playhead" of its timeline goes past the zero-duration tween in the forward direction or lands directly on it, the end values should be rendered, but if the timeline's "playhead" moves past it in the backward direction (from a postitive time to a negative time), the starting values must be rendered.
if (time == 0 || _rawPrevTime < 0) if (_rawPrevTime != time) {
force = true;
if (_rawPrevTime > 0) {
callback = "onReverseComplete";
}
}
_rawPrevTime = time;
}
Expand Down

0 comments on commit 7c0967f

Please sign in to comment.