Chrome's hidden CSS scroll-snap threshold and how to change it

后端 未结 3 1381
借酒劲吻你
借酒劲吻你 2021-02-12 13:19

I have a container:

scroll-snap-points-y: repeat(100%);
snap-type: mandatory;
snap-type: y mandatory;

And three children:

heigh         


        
3条回答
  •  没有蜡笔的小新
    2021-02-12 13:30

    Based on the Chromium Bugs discussion around scroll-snap in general, it appears that the intent is to determine momentum (difficult with a scroll, slightly easier with a swipe) but the implementation is a bit wonky.

    The suggestion is to utilize scroll-snap-stop: always to override that momentum intent (which you've done). However, it also mentions that scroll-margin and scroll-padding may impact the movement from one snap point to the next.

    CSS Snap Scrolling from Google

    You might also want to look at the Overscroll-behavior API in conjunction with snap-scroll.

提交回复
热议问题