Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
SuperHero

How to add multiple classes in GSAP animation Code

Recommended Posts

Hello There,

 

Could you please guide me to add multiple classes in one line.

 

Here is the code.

.to(".white1", {opacity: 1})
.to(".white2", {opacity: 1})
 .to(".white3", {opacity: 1}) 
.to(".white4", {opacity: 1})

 

--------
 

Example: .to(".white1", ".white2", ".white3", ".white4", {opacity: 1}) - Not sure this is correct code or not.

 

I need to display white colar at same time instead of coming one-by-one.

 

Thanks in advance.

 

Harshal Vanarse.

Share this post


Link to post
Share on other sites

Hey Harshal.

 

There's a couple of ways to do this. The easiest is to use a shared class (assuming you can change the HTML):

.to(".white", {opacity: 1})

The next is to use a more complex selector string:

.to(".white1, .white2, .white3, .white4", {opacity: 1})

Then you can also use an array of values, granted the values are of the same type (DOM element, selector string, etc.):

.to([".white1", ".white2", ".white3", ".white4"], {opacity: 1})

 

Happy tweening :) 

  • Like 3

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.

×