Jump to content
Search Community

ScrollTrigger scroller with pin issue

Vasyl Shvets test
Moderator Tag

Recommended Posts

I don't know why it is happening, but it has to do with you hacking the browser scrollbar. If you just let the browser handle the scroll there are no white bars appearing on the top or bottom of the black background. (I assume that is what you mean by twitching

 

See the Pen rNrBNOP?editors=0010 by mvaneijgen (@mvaneijgen) on CodePen

  • Like 1
Link to comment
Share on other sites

Yeah, that looks to me like a side effect of using a custom scroller and the browser handles scrolling on a separate thread that isn't synchronized with the main (JS) thread, thus the browser paints the scrolled page (the way it things it should be) and THEN it executes JavaScript a few milliseconds later at which point ScrollTrigger adjusts the pin position to be where it's supposed to be based on the scroll position. Whenever you use a custom scroller (not the body/html/root), ScrollTrigger uses a pinType: "transform" to solve various other problems (like if you use position: fixed on something inside an element that has a transform or anything else that creates a new stacking context, it'll treat that container as the reference point rather than the viewport). But in your case, you could just set pinType: "fixed" and use normalizeScroll() to force the scrolling to happen on the main thread: 

 

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

 

But like @mvaneijgen said, it's probably easier/cleaner to just not use a custom scroller like that (if you can). 

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