Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
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")
 
  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×