e.touches、e.targetTouches 和 e.changedTouches 的变体

发布于 2024-11-29 11:52:52 字数 380 浏览 3 评论 0原文

假设我正在监听 body 元素上的 touchstarttouchmovetouchend

如果我错了,请告诉我,但我认为 e.touchese.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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你怎么这么可爱啊 2024-12-06 11:52:52

我们有以下列表:

  • touches:当前触摸屏幕的每个手指的信息列表
  • targetTouches:与触摸类似,但仅过滤为开始的手指触摸的信息在同一节点内
  • changedTouches:事件中涉及的每个手指的信息列表

为了更好地理解这些列表中可能包含的内容,让我们快速浏览一些示例。它们根据以下规则而变化:

  • 当我按下手指时,所有三个列表都将具有相同的信息。它将在 changedTouches 中,因为放下手指是导致事件发生的原因。
  • 当我放下第二根手指时,touches 将有两个项目,每个手指一个。仅当手指与第一个手指放置在同一节点时,targetTouches 才会有两个项目。 changedTouches 将包含与第二根手指相关的信息,因为它是导致事件的原因
  • 如果我同时放下两个手指,则 changedTouches 中可能有两个项目>,每个手指一个
  • 如果我移动手指,唯一会改变的列表是 changedTouches 并且将包含与已移动的手指(至少一个)相关的信息。
  • 当我抬起手指时,它将从 touchestargetTouches 中删除,并将出现在 changedTouches 中,因为它是导致事件“
  • 删除我的最后一根手指” 的原因会将 touchestargetTouches 留空,并且 changedTouches 将包含最后一个手指的信息

We have the following lists:

  • touches: A list of information for every finger currently touching the screen
  • targetTouches: Like touches, but is filtered to only the information for finger touches that started out within the same node
  • changedTouches: A list of information for every finger involved in the event

To better understand what might be in these lists, let’s go over some examples quickly. They vary according to the following rules:

  • When I put a finger down, all three lists will have the same information. It will be in changedTouches because putting the finger down is what caused the event
  • When I put a second finger down, touches 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 event
  • If I put two fingers down at exactly the same time, it’s possible to have two items in changedTouches, one for each finger
  • If I move my fingers, the only list that will change is changedTouches and will contain information related to as many fingers as have moved (at least one).
  • When I lift a finger, it will be removed from touches, targetTouches and will appear in changedTouches since it’s what caused the event
  • Removing my last finger will leave touches and targetTouches empty, and changedTouches will contain information for the last finger
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文