contao-components / swipe

JavaScript touch slider with additional dot menu
5 stars 2 forks source link

Make eventlisteners passive #8

Open 0xhtml opened 1 year ago

0xhtml commented 1 year ago

Chrome DevTools suggest marking the eventlisteners on touch, scroll etc. events as passive, as long as the listeners don't need to cancel the event, to improve performance. I would think that doing so might slightly improve performance and would at least silence the devtools complaining.

leofeyer commented 1 year ago

Can you create a pull request with the necessary changes?

0xhtml commented 1 year ago

I implemented the passive event listeners https://github.com/0xhtml/swipe/commit/5d7883cdb6a3605057e69706c0dfe2f9931650f9 and the chrome devtools no longer complain. However, there seems to be a bug in Firefox with the non-passive touchmove event listener that is registered inside the now passive touchstart event listener: As far as I can tell is the cancellation of scrolling is not working even though the touchmove event is registered as non-passive and therefore should be cancelable. Works in chrome though.

0xhtml commented 1 year ago

Reported the bug to Mozilla: https://bugzilla.mozilla.org/show_bug.cgi?id=1839095