I'm trying to understand how a tween's invalidate() function works. According to the docs, if you invalidate() and restart() a tween, the timeline will take the new parameters of the tween, right?
I tried to build a simple example to understand this behavior, but what ends up happening is really confusing. Here's what I have. (I'm using KineticJS)
var t1 = new TimelineMax({paused:true, onUpdate:stageUpdate, onUpdateScope:stage});
var tweenX = TweenMax.fromTo(rect, 1, {setX:100}, {setX:500});
var tweenY = TweenMax.fromTo(rect, 1, {setY:100}, {setY:0});
t1.add(tweenX,0);
t1.add(tweenY,1);
When I add these tweens to the timeline, they work as expected.
Now, I have a function where I'm trying to update the way tweenY works. So, I update the parameters, invalidate the tween and the timeline and restart the timeline.
function updateTween() {
tweenY.invalidate();
tweenY = TweenMax.fromTo(rect, 1, {setY:100}, {setY:200});
t1.seek(0).invalidate();
t1.restart();
}
However, the behavior is really confusing.
Original behavior: 'rect' moves right to x:500, then moves up to y:0.
After updating the tween, what I thought would happen: 'rect' moves right to x:500, then moves down to y:200.
What actually happens: 'rect' moves diagonally to x:500, y:200, then moves up to y:0
I built a codepen to show this: http://codepen.io/anon/pen/fLAkd
Can someone help me understand this please?