Jump to content
Search Community

scrollTrigger - Timeline start position where a previous pin with pinSpacer ends.

beavykins test
Moderator Tag

Recommended Posts

Is it possible to pass in the end position of a previously pinned scrollTrigger element as the start position of another?

 

Basically I have two timelines, the first one has a pin with a pinSpacer and I want to then have another timeline start when the previous one unpins, is that possible? At the moment I have it working by manually calculating the start position in the next timeline but it seems like there is probably a ‘simpler’ way.

 

Thanks!

Link to comment
Share on other sites

Sure! There are a few ways...

let tl = gsap.timeline({
  scrollTrigger: {
    ... 
  }
});
  
let otherTL = gsap.timeline({
  scrollTrigger: {
    start: () => tl.scrollTrigger.end, // function-based value
    ...
  }
});

That assumes you create them in the proper order so the first one gets refreshed before the second one (its start/end values are calculated by the time the following one has to read them). 

 

If you know for sure it's the previous one, you could also do this: 

let otherTL = gsap.timeline({
  scrollTrigger: {
    start: self => self.previous().end
  }
});

I'm just assuming you're using timelines but this same thing works regardless - use it in ScrollTrigger.create() or in a tween or whatever. 

 

Is that what you were looking for? 

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