ckrack / scrollsnap-polyfill

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

Does not support decimal values for scroll-snap-destination #22

Open Oromis opened 7 years ago

Oromis commented 7 years ago

Nice polyfill, but whenever I try to use decimal values as scroll-snap-destination, it does not do anything at all. It would be very nice if the polyfill supported them, e.g. for 3-column horizontal scrolling sliders.

e.g., using

 scroll-snap-destination: 0% 33.33%;

fails for me.

As I see it, the fix is pretty easy, just replace the regex in function parseSnapCoordValue() from

/(\d+)(px|%) (\d+)(px|%)/g

to

/(\d+(?:\.\d*)?)(px|%) (\d+(?:\.\d*))(px|%)/g

I you are interested, I will submit a pull request.