alvsys Posted March 15, 2022 Share Posted March 15, 2022 Hi! I am using ScrollTrigger in React and I am experiencing the following problem: When I update any React State and I use scrub:1(or any number), the animation is reset and it is possible to see it jumping. This doesn't happen when scrubis set to true I've tried different methods available in the guides and read many forum topics but I haven't had success. I wonder if this is possible keep the position when there is a re-render? I'd appreciate any help Thanks in advance See the Pen WNdbVZL by alvsys (@alvsys) on CodePen Link to comment Share on other sites More sharing options...
Solution OSUblake Posted March 15, 2022 Solution Share Posted March 15, 2022 Welcome to the forums @alvsys Your useEffect needs an empty array on the end, otherwise it will recreate the animation on every state change. Be sure to check out our React guide. 1 Link to comment Share on other sites More sharing options...
alvsys Posted March 15, 2022 Author Share Posted March 15, 2022 Hi @OSUblake, thank you very much! now it works like charm, I checked lots of times for days and I couldn't see that detail newbie mistake, I put the focus in the wrong stuff. Much appreciated 🙏 Cheers! 1 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