简体   繁体   English

响应JavaScript中的单个触摸事件

[英]Respond to individual touch events in javascript

Consider the scenario where a user touches the screen, holding the first finger down. 考虑用户触摸屏幕并按住第一根手指的情况。 The user then taps the screen sequentially in two separate locations with a second finger. 然后,用户用第二根手指在两个单独的位置依次点按屏幕。 I want to respond to this as three independent taps, and all I really care about are the initial tap locations. 我想用三个独立的水龙头来回应这个问题,我真正关心的只是最初的水龙头位置。

I have tried using touchstart, but I can't figure out how to not reuse the first touch. 我尝试使用touchstart,但是我不知道如何不重用第一次触摸。 If I look for changes in the length of event.touches, I don't pick up the second (final) tap. 如果我想更改event.touches的长度,则不会拿起第二个(最终)拍子。

Can someone suggest a strategy for responding to each touch individually? 有人可以提出一种策略来单独响应每个触摸吗? I am guessing it is quite simple, but I can't quite figure it out. 我猜这很简单,但我不太清楚。

If you're using JQuery or Zepto JQTouch is a good plugin that wraps up touch events nicely for you. 如果您使用的是JQuery或Zepto,则JQTouch是一个很好的插件,可以很好地包装触摸事件。 If you're interested in doing this at a lower level, you could always take a look at how they've done it. 如果您对较低级别的操作感兴趣,可以随时查看他们的操作方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM