Jump to content
Search Community

Enlarge on hover, reduce on leave

PinkMeNow 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

There were several problems. First, you were using document.getElementsByClassName(".st1") which returns a NodeList (like an Array), but you were treating it like it'd return a single element (by appending .addEventListener(....)). You can't addEventListener() to a NodeList/Array. 

 

Also, you used the wrong selector text. It should simply be "st1", not ".st1" because you're using getElementsByClassName(). I'd recommend switching to document.querySelectorAll() which is more flexible and you can use that selector text (".st1"). 

 

You had logic that'd cause things to grow when the mouse LEAVES them (instead of when it rolls over them). I assume that behavior was inverted, based on what you said in your question. 

 

I wasn't sure if you wanted each piece to animate independently, but here's a fork:

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

 

Does that help? 

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