Jump to content

Search In
  • More options...
Find results that contain...
Find results in...

Question about ScrollTrigger.refresh()

Go to solution Solved by akapowl,

Recommended Posts

Is that ScrollTrigger.refresh() only effect on ScrollTrigger.create() instances? But not on scrollTrigger inside gasp.to?

Link to comment
Share on other sites

  • Solution

Hello @flim


That's quite testable - short answer: it does aso work on scrollTrigger inside a gsap.to()


Click the body to change the height of the .bg in this following example and see how the markers adjust because of the .refresh() that is being called.


See the Pen 16cfd8e6cedfd6ef69c32da5664e1895 by akapowl (@akapowl) on CodePen


  • Like 1
  • Thanks 1
Link to comment
Share on other sites

I want to set the scroller-start position calculated by the height of header.

See the Pen gOxrmKP by fredlim (@fredlim) on CodePen


I am newbie in JS and GSAP, many thanks for your help :)



Link to comment
Share on other sites

Hi flim!


You just need to add invalidateOnRefresh: true to your ScrollTrigger, and put the calculation inside the start function. ScrollTrigger will fire that function on refresh so you don't have to add resize listeners.


See the Pen PoKzoJy by GreenSock (@GreenSock) on CodePen


  • Like 2
  • Thanks 1
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.