Romann Posted October 24, 2023 Share Posted October 24, 2023 is it possible to control SmoothScroller request animation frame (updates) externally ? I have react app and i need to sychnronyze better SmoothScroller with other animations i have going, and i would like to do smoothscroller animation/position calculation togetehr with my other animation. Link to comment Share on other sites More sharing options...
GreenSock Posted October 25, 2023 Share Posted October 25, 2023 Hi @Romann! Thanks for being a Club GSAP member. 💚 I'm a bit confused by your request - do you have a minimal demo that illustrates what you're trying to do? ScrollSmoother is already driven by requestAnimationFrame and it has an onUpdate, so I'm curious what else you'd need or what you're trying to do exactly that you can't already do with the existing API. And ScrollSmoother is synchronized with all of GSAP of course, so you shouldn't need to do anything special to synchronize things. Link to comment Share on other sites More sharing options...
Romann Posted October 25, 2023 Author Share Posted October 25, 2023 I think, i am looking for a way how to disable ScrollSmoother raf, and animate it in my custom function, the problem i have is synchronization of the dom elements animation with my canvas 3d elements, basically i need to combine request animatioin frame so dom elements and 3d elements are animated in one spot. Nothing wrong with ScrollSmoother, it is perfect. Link to comment Share on other sites More sharing options...
Solution Rodrigo Posted October 25, 2023 Solution Share Posted October 25, 2023 Hi, As Jack mentions ScrollSmoother has an onUpdate callback (like Tween and Timeline instances do) that should be the place to plug your logic. That would be the first thing I'd try in order to update other things: onUpdate Function - a function to call after each time the SmoothScroller updates the position of the content. Keep in mind that you can also keep track of the ScrollSmoother instance's progress as well if you want to use RAF: https://gsap.com/docs/v3/Plugins/ScrollSmoother/progress But honestly, since GSAP ticker already uses RAF it seems like a redundancy and using GSAP Ticker also guarantees that every GSAP instance, ScrollSmoother instance will be 100% in sync as well. Hopefully this helps. Happy Tweening! Link to comment Share on other sites More sharing options...
Romann Posted October 25, 2023 Author Share Posted October 25, 2023 i think i figured this out, i was using state to pass scroll position instead of reference . Thank you ! 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