Jump to content
Search Community

ScrollSmoother | Separat/external rAF control ?

Romann test
Moderator Tag

Go to solution Solved by Rodrigo,

Recommended Posts

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

  • Romann changed the title to ScrollSmoother | Separat/external rAF control ?

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

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

  • Solution

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

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.
×
×
  • Create New...