ckrack / scrollsnap-polyfill

A polyfill for CSS scroll snapping
MIT License
217 stars 35 forks source link

Pick the nearest element in the direction of scrolling #5

Open frankier opened 8 years ago

frankier commented 8 years ago

I think this behaviour is best generally. When compared to Firefox's implementation, Firefox will always scroll to the next in the direction if you press a button on the scrollbar, but if you drag it will snap to the current nearest. In our case, we can't tell which happened, so I think going to the nearest in the direction of scrolling is a reasonable option.

ckrack commented 8 years ago

While I agree with the behaviour, there is a bug that prevents one from scrolling back to the previous element, when using snap-coords.

Reproduce: See demo/coordinates.html Scroll to element 2 Scroll back to element 1 It snaps back to element 2

Expected: snap to element 1.

@frankier: do you want to fix it yourself?

frankier commented 8 years ago

Hi, I'm probably not going to fix this since my fix works fine for my own purpose. Please just treat this PR as a bug report in that case. Thanks.