Jump to content
Search Community

1-pixel scroll delay before pin is activated

Loz Calver test
Moderator Tag

Recommended Posts

Cassie test
This post was recognized by Cassie!

Loz Calver was awarded the badge 'Helpful'

Hi!Ā šŸ˜ƒ

Ā 

Iā€™m having a slight issue with pinning full-screen sections in combination with snapping (using the approach from this demo:Ā ).

Ā 

When the ā€œsnapā€ activates, it scrolls to the exact position where the section takes up 100vh. So far so good, but the section is pinned and it doesnā€™t receive position: fixed; at this point - that is only applied when the user begins scrolling to the next section. This results in a flicker (especially noticeable on mobile devices) as the user starts scrolling so the element moves, then position: fixed; is applied and the element snaps back to its original position.

Ā 

Itā€™s quite a simple page so the flicker isnā€™t obvious, but I can show the issue with the layered pinning demo:Ā 

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

. Steps are:

Ā 

  • Inspect the demo with web inspector
  • Highlight the <section>ONE</section> section
  • Scroll 1/4 of the way down from the initial blue screen - enough to trigger the snap to the next section
  • Allow the snap scrolling to take place - notice that at this point <section>ONE</section> still doesnā€™t have position: fixed; despite it being in the position where the ā€œpinā€ should begin
  • As soon as you begin scrolling down, even 1px, position: fixed;Ā is applied

Ā 

I had hoped that calling ScrollTrigger.refresh() when the snap completes would cause the pin to be applied but it doesnā€™t seem to help. anticipatePin doesnā€™t seem to help either.

Ā 

For now Iā€™m working around it by using { start: 'bottom-=1 bottom' } instead of { start: 'bottom bottom' } (in my project Iā€™m using bottom instead of top in case the section is taller than the userā€™s viewport)

Ā 

Thanks!

Ā 

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

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