Stack scrolling with scroll-snap and position sticky

≯℡__Kan透↙ 提交于 2021-02-10 05:24:51

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!