Jump to content
GreenSock

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

Buggy Cursor Animation

Go to solution Solved by GreenSock,

Recommended Posts

Hi there,

 

I'm trying to animate a cursor in React using gsap. The goal is to animate the cursor on mouseEnter and mouseLeave. It's mostly working fine, but if you move the cursor too fast, the mouseEnter animation takes over the cursor, and I'm not sure why this is happening. Any help would be greatly appreciated. Here's my code to check out: https://codesandbox.io/s/hungry-hypatia-e9169

 

 

thanks!

Link to comment
Share on other sites

  • Solution

It looks to me like the problem is the fact that you're creating conflicting tweens and the "mouseEnter" animation is LONGER (0.3) than the "mouseLeave" (0.2), thus if you move fast enough, you could create a situation where the "mouseLeave" animation ends BEFORE the "mouseEnter" one does, thus the "mouseEnter" renders last. 

 

By default, overwrite is false. 

 

You could simply set overwrite:"auto" but if you want absolute best performance you could manage that overwriting manually like this: 

https://codesandbox.io/s/beautiful-leavitt-7o2tw?file=/src/App.js

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