Stack scrolling with scroll-snap and position sticky
Asked Answered
U

0

6

I'm using scroll-snap in combination to position: sticky which seemed like an elegant approach to enable a stacking card effect while scrolling.

It works pretty great on desktop but on Safari (iOS12.1) I'm experiencing glitches where sometime the cards scroll all together, skipping content.

The most obvious way to replicate the bug on mobile Safari is to:

  • scroll down to the bottommost screen
  • close (blur) and reopen Safari
  • then trying to scroll back up again

Bug experienced: it's skipping all the screens making the navigation impossible.

I'd like to get it working with only CSS, but I'd be up for any (good) solution. In the end it's meant to work within a ReactJS app.

Demo: https://codepen.io/theo_t/full/BbGoWq

.container {
  width: 100%;
  height: 100vh;
  overflow: scroll;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: y mandatory;
}

.item {
  position: sticky;
  position: -webkit-sticky;
  top: 0;
  scroll-snap-align: start;
  width: 100%;
  height: 100vh;   
} 
Ubiquitarian answered 21/3, 2019 at 20:9 Comment(3)
ever get this working?Mathia
I've never used snap-scroll before and I'm trying to use it right now for full screen pages (with alternating background colors) to snap to fill the screen. It works fine, but the sticky layer sits on top and iOS is so determined to get the snapping animation working quickly that it literally leaves the sticky positioned item behind and it sort of stutters. I'm hoping I can find some kind of 3D transform to get them both to render as one layer. Not sure if that could possibly be related at all to this. Note: I'm using iOS 15 beta.Shoer
@Theo. T did you get the solution as the same issue is coming while using in firefox. I am not able to scroll up after reaching on F section. I can scroll up after removing top:0 but then effect won't come.Refinery

© 2022 - 2024 — McMap. All rights reserved.