Jump to content
Search Community

Add new class not working?

ShadowHax test
Moderator Tag

Recommended Posts

Hello All!

This should be pretty straight forward, but I'm having trouble adding a new class.

I've attached my CodePen example.  Can anyone point me in the right direction to what I am doing wrong?

 

The example should change all the box colors from Blue to Green, then add the .blackBox class to the third box, then change all boxes without the .blackBox class to Red, leaving the third box Black.

 

Any input would be greatly helpful!

See the Pen jObbedy by lithiumhax (@lithiumhax) on CodePen

Link to comment
Share on other sites

Thank-you so much for the tips!!!

I can style the 3rd box without using the class, I guess I'm trying to figure out the best way to use .not on the boxes.

I thought I could maybe just add the .blackBox class to the third box, then use .not('.blackBox') to change them all but the third to Red.

I'm probably doing a terrible job explaining myself lol, but thank-you for all the help.

Link to comment
Share on other sites

26 minutes ago, ZachSaucier said:

I think this is the effect you're going for? 

 

I think GSAP caches the target references when tweens are initialized, so you should wait to create the new tween until after the className has been changed. 

 

Very helpful!  Thank-you!

 

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...