blizve0 Posted October 28, 2021 Share Posted October 28, 2021 Thankfully no errors for me today, I just wanted to know if their are some Performance Boost tips possible for this GSAP Cursor Position Setter Animation. If someone can let me know this is optimal enough or push me in some other direction if not. See the Pen gOxxYXz by blitzve0 (@blitzve0) on CodePen Link to comment Share on other sites More sharing options...
Solution OSUblake Posted October 28, 2021 Solution Share Posted October 28, 2021 Hi @blizve0 Have you check out our React guides? The Imperative Communication section talks about how using React mechanisms, like changing state can be bad for performance as it causes re-renders. I think it would make more sense to put everything inside a single effect... useEffect(() => { const onMove = ({ x, y }) => { gsap.to(".cursor", { duration: (i) => 1.8 - i * 0.2, stagger: 0.05, x, y }) } window.addEventListener("mousemove", onMove); return () => window.removeEventListener("mousemove", onMove) }, []); 1 1 Link to comment Share on other sites More sharing options...
blizve0 Posted October 29, 2021 Author Share Posted October 29, 2021 Oh Ok Means I should set the co-ordinates directly to gsap without using states for exporting cursor data Sure I'll make the changes Thanks 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