hasancruk / cruk-carousel

Experimental carousel web component.
MIT License
1 stars 0 forks source link

Write `scrollend` polyfill for Safari #2

Closed hasancruk closed 10 months ago

hasancruk commented 10 months ago

Try and write a simple polyfill that listens for the scroll event and then emits the scrollend event after a set debounce.

Resources

hasanhaja commented 10 months ago

How is apple doing this on their own site?

https://www.apple.com/uk/macbook-pro/

hasancruk commented 10 months ago

Looks like they are just doing it with scroll event:

image
hasancruk commented 10 months ago

Debouncing logic:

hasancruk commented 10 months ago

A simple polyfill kinda works: https://github.com/hasancruk/cruk-carousel/commit/c2a6c1ad3ea878c9d3885f8b23bcd07afd354750

But it doesn't handle things like touch event start and stop correctly. I like the scrollyfills implementation, so I'm going to copy and paste that into the code.

hasancruk commented 10 months ago

That polyfill handles touch events on mobile a lot better but on desktop it's about the same. Scrollend performs way better on something like Firefox or Chrome.