【问题标题】:JS - why touchEvent.identifier in Chrome is always zero?JS - 为什么 Chrome 中的 touchEvent.identifier 总是为零?
【发布时间】:2016-05-18 20:44:21
【问题描述】:

我正在玩触摸事件,我实现了一个为每个手指创建和移动一个圆圈的演示。在 iOS Safari 上没问题,但 Android Chrome 总是返回“0”作为触摸标识符 (https://developer.mozilla.org/en-US/docs/Web/API/Touch/identifier)。它是一个错误、“反用户跟踪”隐私选择,还是其他什么?是否有解决方法来识别触摸?

谢谢。

【问题讨论】:

    标签: javascript android google-chrome multi-touch


    【解决方案1】:

    这似乎是由于对 W3C 规范的解读与 Apple 在 iOS Safari 中使用的不同。 当只有一根手指触摸屏幕时,Android Chrome 会为触摸提供 0 标识符。当两根手指接触时,它会赋予它们 0 和 1 的标识符,依此类推。这实际上符合 W3C 规范的措辞:

    identifier of type long, readonly
    An identification number for each touch point. When a touch point becomes active, it must be assigned an identifier that is distinct from any other active touch point. While the touch point remains active, all events that refer to it must assign it the same identifier.

    请注意,它只必须相对于任何其他活动的接触点是唯一的,这意味着它可以与以前不再活动的接触点相同。这远不如 Apple 实现有用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-19
      • 1970-01-01
      • 1970-01-01
      • 2021-09-13
      相关资源
      最近更新 更多