Share Posted November 17, 2021 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 More sharing options...
Solution Solution Share Posted November 17, 2021 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 More sharing options...
Author Share Posted November 17, 2021 This is works great! Thank you so much! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now