Jump to content
Search Community

good practice for mouse animation when entering / leaving a space

amapic test
Moderator Tag

Recommended Posts

I made here a basic animation of a div which is following the cursor as it enters or leaves a space:

https://codesandbox.io/p/sandbox/eloquent-almeida-wujeen

 

it works quite well (not perfectly). Not to trigger the enter and the leave animation together, I made some control with isActive() and then I launch restart(). But what are actually the good practice about this subject ?

See the Pen by (@) on CodePen

Link to comment
Share on other sites

Hi,

 

A few things, you're not reverting your GSAP Context instance in the return of the useEffect hook, I strongly recommend using that cleanup section to revert your context and remove event listeners.

 

I recommend you to take a look at this example so you can extract some ideas from it:

https://greensock.com/react-advanced#imperative-communication

 

Let us know if you have more questions.

Happy Tweening!

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