Jump to content
Search Community

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

Michael Heuberger test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

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
Link to comment
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 2
Link to comment
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.
  • Create New...