Share Posted April 4, 2016 When I have two tweens which I want to run concurrently, I've been taking the following approach (concatting a string for the `position`), but feel there must be a better way. var tl = new TimelineLite({ paused: true }); var $box = jQuery(".box"); var duration = 2; tl.add(TweenLite.to($box, duration, { ease: 'Bounce.easeOut', width: 100 })); tl.add(TweenLite.to($box, duration, { // don't want bounce-ease on this property height: 300 }), '-=' + duration); Any suggestions very welcome! See the Pen bpYVpv by jezmck (@jezmck) on CodePen Link to comment Share on other sites More sharing options...
Share Posted April 4, 2016 When I want more than one tween to start at the same point, I create a label for that point in time and use that as the position parameter: tl.add("StartPoint"); tl.to($box, duration, { ease: 'Bounce.easeOut', width: 100 }, "StartPoint"); tl.to($box, duration, { // don't want bounce-ease on this property height: 300 }, "StartPoint"); Note that you can use convenience methods, like .to(), from(), etc, just like in TweenMax to build your timelines. You don't need to .add() each Tween in the Timeline. Also, you can chain those methods. The bellow will produce the same results as the code above: tl.add("StartPoint") .to($box, duration, {ease: 'Bounce.easeOut', width: 100}, "StartPoint") .to($box, duration, {height: 300}, "StartPoint"); Make sure you add ";" only in the last call. 7 Link to comment Share on other sites More sharing options...
Share Posted April 4, 2016 Hi and welcome to the GreenSock forums. Professor Schooff created this video tutorial for the position parameter. Also there's a very handy codepen in it so you can play with. http://greensock.com/position-parameter 4 Link to comment Share on other sites More sharing options...
Author Share Posted April 5, 2016 Awesome, thanks both. Link to comment Share on other sites More sharing options...
Share Posted April 5, 2016 Smart tip @Dipscom i was always playing with negative delays (which are really hell to use that way) so this makes my life more pretty 3 Link to comment Share on other sites More sharing options...
Share Posted April 5, 2016 Thanks Oscar. I should have mentioned that the .add() method also accepts a position parameter, so, you can have a bunch of Tweens starting at the same time that overlaps another tween in the timeline. tl.to(box, dur, {...}) .to(square, dur, {...}) .add("StartPoint", "-="+dur) .to(rectangle, dur, {...}, "StartPoint") .to(triangle, dur, {...}, "StartPoint"); 4 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now