mpizenberg / elm-pointer-events

Mouse, Touch, Pointer, Wheel and Drag events in elm
https://package.elm-lang.org/packages/mpizenberg/elm-pointer-events/latest
Mozilla Public License 2.0
68 stars 8 forks source link

Touch events prevent default behavior such as scrolling #19

Open Dzhyrma opened 5 years ago

Dzhyrma commented 5 years ago

I am using elm 0.19 and library version 3.1.0. I've assigned touch event on a sidebar to figure out when a left swipe occurs, but I've realized that scrolling is no longer working (only on mobile devices).

Right now I am using this: Touch.onWithOptions "touchstart" { stopPropagation = False, preventDefault = False } instead of: Touch.onStart to fix the problem. I think the default behavior shouldn't prevent default touch actions

mpizenberg commented 5 years ago

Hi @Dzhyrma, from my own experience, people who started using this library often did so because they needed access to coordinates of events, in the context of a drawing app or similar. Otherwise, creating one's own event listener is quite simple:

Html.Events.on "touchstart" (Decode.succeed SomebodyTouchedThatMsg)

In that context, it can be very surprising when touch or pointer events get cancelled because a touch action (swipe, scroll, ...) was detected by the browser. It's super hard to take decisions with very few data points so I prioritized use cases similar to mine. That's the reason why I defaulted to prevent default. Let me know if you don't find this convincing ^^!

Sorry for the delayed answer, I've been busy these days and don't have much time for personal projects.