e.touches、e.targetTouches 和 e.changedTouches 的变体
假设我正在监听 body
元素上的 touchstart
、touchmove
和 touchend
。
如果我错了,请告诉我,但我认为 e.touches
与 e.targetTouches
相同?如果是这样,e.changedTouches
与它们的关系如何变化?
我的意思是,在某一给定时刻进行一次触摸,我会获取触摸事件并解析它。根据我的经验,所有三个触摸变量都是相同的。
我必须将解析后的数据发送到服务器,并且发送三次相同的字符串是相当多余的,是否有任何方法可以将它们发送一次并以编程方式在服务器上重现触摸事件?
Let's say I am listening for touchstart
, touchmove
and touchend
on the body
element.
Let me know if I'm wrong, but I think e.touches
is the same as e.targetTouches
? If so, how e.changedTouches
varies in relation with them?
I mean, given one touch at one given moment, I fetch the touchevent and parse it. In my experience all three touch variables are the same.
I have to send the parsed data to the server and it's quite redundant to send three times the same exact string, isn't there any way to send them once and programatically reproduce the touchevent on the server?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我们有以下列表:
touches
:当前触摸屏幕的每个手指的信息列表targetTouches
:与触摸类似,但仅过滤为开始的手指触摸的信息在同一节点内changedTouches
:事件中涉及的每个手指的信息列表为了更好地理解这些列表中可能包含的内容,让我们快速浏览一些示例。它们根据以下规则而变化:
changedTouches
中,因为放下手指是导致事件发生的原因。touches
将有两个项目,每个手指一个。仅当手指与第一个手指放置在同一节点时,targetTouches
才会有两个项目。changedTouches
将包含与第二根手指相关的信息,因为它是导致事件的原因changedTouches
中可能有两个项目>,每个手指一个changedTouches
并且将包含与已移动的手指(至少一个)相关的信息。touches
、targetTouches
中删除,并将出现在changedTouches
中,因为它是导致事件“touches
和targetTouches
留空,并且changedTouches
将包含最后一个手指的信息We have the following lists:
touches
: A list of information for every finger currently touching the screentargetTouches
: Like touches, but is filtered to only the information for finger touches that started out within the same nodechangedTouches
: A list of information for every finger involved in the eventTo better understand what might be in these lists, let’s go over some examples quickly. They vary according to the following rules:
changedTouches
because putting the finger down is what caused the eventtouches
will have two items, one for each finger.targetTouches
will have two items only if the finger was placed in the same node as the first finger.changedTouches
will have the information related to the second finger, because it’s what caused the eventchangedTouches
, one for each fingerchangedTouches
and will contain information related to as many fingers as have moved (at least one).touches
,targetTouches
and will appear inchangedTouches
since it’s what caused the eventtouches
andtargetTouches
empty, andchangedTouches
will contain information for the last finger