Jump to content
Search Community

ScrollTriger kill() would jump down

kristiankoo test
Moderator Tag

Recommended Posts

Well, you could just set once: true on your ScrollTrigger but you're going to run into logic issues because you're pinning which involves adding a wrapper with padding so that it puts enough space in there to accommodate the duration of the pinning. So if you don't want it to run backwards when scrolling up, you'll either have a bunch of extra space at the top OR you'll get the jump OR you could sorta fake it by adjusting the scroll position when the pin spacer gets removed so it's a the same spot, but your scrollbar would obviously change size suddenly. For example, you could handle it all in the onLeave: 

See the Pen bGrLXdQ?editors=0010 by GreenSock (@GreenSock) on CodePen

  • Like 4
Link to comment
Share on other sites

  • 1 year later...

Jack's code is exactly what I was looking for today.

 

One small additional thing that may help someone in a similar spot, I had other scrollTriggers further down the page that were impacted when the pin-spacer was removed. I added ScrollTrigger.refresh() at the end of the onLeave function to make it all work as expected.

 

The more I use scrollTrigger the more I appreciate the immense amount of thought and effort that went into its development. Huge thanks Jack and everyone at GSAP :)

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