Jump to content
Search Community

How to get the start value of a ScrollTrigger. Eg tl.scrollTrigger.start equals 0?

mvaneijgen
Moderator Tag

Go to solution Solved by akapowl,

Recommended Posts

Posted

I want to get the start value in pixels of a specific ScrollTrigger, so what I did was log the timeline, then saw there was a scrollTrigger object. Within that object I saw the property start, but when I log tl.scrollTrigger.start I get 0. Am I missing something? 

Screenshot 2023-02-21 at 12.21.27.jpg

See the Pen MWqKLww?editors=1111 by mvaneijgen (@mvaneijgen) on CodePen.

  • Solution
Posted

 

Hey Mitchel.

 

ScrollTriggers associated with timelines must wait 1 tick to do their calculations, so you could e.g. use a delaydCall to get what you need.

 

See the Pen wvEMNLa by akapowl (@akapowl) on CodePen.

 

You can find a more thorough explanation by Jack in this recent thread (among others).

 

 

  • Like 4
  • Thanks 1
Posted

Thanks Paul! I was reality stomped on this one! Thanks again! 

  • Like 4
Posted

Good to see even the experts get tripped up sometimes ?

  • Haha 1
Posted

Yep, exactly right. Also, you don't HAVE to wait 1 tick. The whole point is that there's no way for GSAP to know when you're done populating your timeline, so it has to wait a tick but since YOU know when you're done populating your timeline, you can manually trigger the refresh() at that point: 

See the Pen MWqyeRB?editors=1010 by GreenSock (@GreenSock) on CodePen.

  • Like 4

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