mpizenberg / elm-pep

Minimalist pointer events polyfill
Mozilla Public License 2.0
15 stars 5 forks source link

Mouse emulation on touch device doubles the pointer events #2

Open mpizenberg opened 7 years ago

mpizenberg commented 7 years ago

On touch devices, a "tap" on the touch surface will generate an emulated mouse click few millisecond later. This behavior is to reduce the potential non usability of websites that do not take into account touch interactions.

In our case, this is an issue since it doubles the number of pointer events generated. An example of this problem is testable with this JS fiddle : https://jsfiddle.net/6aw0z9hL/1/ Try a "tap" with either a touch device (smartphone/tablet) or firefox in responsive mode with touch activated.

I read that event.preventDefault() should prevent this emulated mouse event from happening but it is not the case in the example above.

robx commented 6 years ago

For reference, jQuery's pointer events polyfill seems to do some manual deduplication here: https://github.com/jquery/PEP/blob/master/src/touch.js#L11

So it seems likely that the emulated mouse event can't easily be disabled.