multiple touches: touchend event fired only when a touchmove occurs

后端 未结 4 2161
忘掉有多难
忘掉有多难 2021-02-19 23:38

I would like to add some multitouch features to my javascript application when it is accessed from an ios device (and maybe android later).

I want to provide a shift

4条回答
  •  一整个雨季
    2021-02-20 00:28

    Okay this is a headache. Yes, there are two known issues. First of all, Safari sometimes doesn't bother firing the touchEnd event unless there is a touchMove somewhere, even if the touchMove doesn't really do much.

    second, Chrome Mobile is a lovely experience as well, as on many Android devices the touchEnd event does not fire at all, regardless of what you do. So from my experience:

    • Implement a touchStart event which registers the start coordinate, etc
    • Implmenet a touchMove event which does the exact same thing as the touchEnd, but make sure the callback doesn't fire more than once. Use a boolean flag defined in a higher scope or something like that.
    • Implement the normal touchEnd event which should only fire if touchMove hasn't already fired the callback, using the same boolean flag defined in a higher scope.

提交回复
热议问题