Jump to content
Search Community

Same tween on multiple elements in timelinelite

ohem test
Moderator Tag

Go to solution Solved by Diaco,

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

Hi, this is a pretty basic question... I'm still getting familiar with GSAP & code-based animation in general.


I was just wondering, if I'm doing the same tween on a few elements (for example, if a couple things are fading in at the same time), is there any difference between doing this:

tl.from("#copy4, #cta", 0.5, {autoAlpha:0}, "+=1.5");


tl.from(["#copy4","#cta"], 0.5, {autoAlpha:0}, "+=1.5");

Both ways seem to work fine, but I wasn't sure if one is better/more standard than the other?  I was doing it with an array at first, but then I realized that I could probably simplify things.  Just wasn't sure if there was any reason why that might not be a good idea?


Thanks for any insight!  These forums are great.

  • Like 1
Link to comment
Share on other sites

To add to Diacos great advice!


If you are trying to animate the same two elements, why not just use a class selector. You would just add the same class on both of your elements #copy4 and #cta


Like this:

// html
<div id="copy4" class="myelements"></div>
<div id="cta" class="myelements"></div>


// js gsap
tl.to(".myelements", 0.5, {autoAlpha:0}, "+=1.5");

Is that what you were looking for?



  • Like 3
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...