Jump to content
GreenSock

Jonny

Targeting nested classes in 'this', using GSAP

Recommended Posts

Hello,

 

As you will see from my codepen, I have multiple elements, which I want to apply a Greensock tween (actually eventually it will be a timeline) when the 'onmouseover' event is triggered.

 

It is all working well, but it applies the Tweening to all elements, - i only want it to happen to the specific one i'm hovering over.

I don't want to use different id's etc, because I will ultimately have multiple elements.

The mouseover is targeting all the classes it finds a match to, not just the nested one in 'this' svg.....

 

Essentially I want my tween to look like this, - I believe the logic to be correct but the syntax is not. (Bold is the part that is the problem):

    TweenMax.to( this > + '.logoCircle', 0.75, {alpha:0, delay:0})
 

Thanks in advance for your help.

 

Regards

Jonny

See the Pen OxVwZp by JonnyPS (@JonnyPS) on CodePen

Link to comment
Share on other sites

Thanks for the demo. jQuery's find() is one way

 

TweenMax.to($(this).find('.logoCircle'), 0.75, {alpha:0, delay:0})

 

See the Pen PJqdOe?editors=0010 by GreenSock (@GreenSock) on CodePen

 

  • Like 1
Link to comment
Share on other sites

Thanks Carl.

 

I'm using vanilla Javascript but 'this.querySelectorAll('.logoCircle')' worked equally as well :)

 

Regards,

Jonny

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