问题
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;
}
来源:https://stackoverflow.com/questions/55288542/stack-scrolling-with-scroll-snap-and-position-sticky