Michael Heuberger

How can I run multiple Tweens in parallel in a Timeline?

Recommended Posts

Hello everyone

 

How can I run both Tweens in parallel?

 

.setTween(new TimelineMax()
.add(TweenMax.fromTo('#intro', .5, { backgroundPosition: "50% 0vh" }, { backgroundPosition: "50% 20vh" }))
.add(TweenMax.to('#intro p.hint', .5, {autoAlpha: 0}))
)
 
Been searching for clues in their APIs but found none. Thanks for a quick hint!
 
- Michael

Share this post


Link to post
Share on other sites

To have tweens run in parallel you need to insert them at the same point in time in the timeline.

Where a tween is inserted into a timeline is controlled via the position parameter.

You can read about this parameter in great  detail in the TimelineLite.to() docs. The position parameter is used in many other methods like from(), staggerFrom(), staggerTo(), call() and more.

 

In your example, you can have the second tween start at the same time as the first tween by adding it at a time of 0 like this

 

.add(TweenMax.fromTo('#intro', .5, { backgroundPosition: "50% 0vh" }, { backgroundPosition: "50% 20vh" }))
.add(TweenMax.to('#intro p.hint', .5, {autoAlpha: 0}), 0)

 

this example shows you how to have two tweens start at a time of 0 AND where a label is placed

 

var tl = new TimelineLite()

tl.to("#redBox", 1, {x:550})
//add second tween at time of 0 seconds
  .to("#blueBox", 1, {rotation:360}, 0)
  
//add a label called "end" at a time of 2 seconds
  .add("end", 2)

// add two tweens at the "end" label
  .to("#redBox", 3, {scale:2, opacity:0}, "end")
  .to("#blueBox", 3, {scale:2, rotation:0, opacity:0}, "end")
 
  • Thanks 1

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.