Jump to content
Search Community

Scrolltrigger refresh(true) after a specific time.

ashirrr test
Moderator Tag

Recommended Posts

I have read that Scrolltrigger.refresh(true) maximum waits for 200ms to refresh with its 'safe' parameter. Is there a way to specify the time period i.e Scrolltrigger.refresh(500) or something?
image.png.35c1420a94055cccc6f456cc83f51313.png

Link to comment
Share on other sites

Hi @ashirrr welcome to the forum!

 

As far as I know, this is not possible, but you can use gsap.delayedCall(0.5, myFunction) https://gsap.com/docs/v3/GSAP/gsap.delayedCall()/ and then then in myFunction call ScrollTrigger.refresh();

 

If you still need help please provide a minimal demo and also explain what you're trying to do, so that we can prevent the classic xyproblem.info

 

Hope it helps and happy tweening! 

  • Like 1
Link to comment
Share on other sites

Yeah @mvaneijgen is right that is not possible.

 

The number you're seeing there (200ms) refers to the internal debouncing feature ScrollTrigger has in order to not run all the logic of the refresh method if the refresh method was called less than 200ms before.

 

For example let say that you manually call the refresh method somewhere in your code, with a button click. If the user resized the window 150ms before that button click ScrollTrigger will check that the previous refresh call timer is running soto speak so it'll restart said timer and wait for another 200ms to run all the refresh logic.

 

Here is a simple explanation of how debouncing works:

https://www.freecodecamp.org/news/javascript-debounce-example/

 

Hopefully this clear things up.

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...