【问题标题】:how to use touchmove to complement mousemove for androids如何使用 touchmove 来补充 android 的 mousemove
【发布时间】:2013-05-27 14:22:30
【问题描述】:

在尝试补充使用鼠标移入也可以在智能手机上工作的工作功能时,我应该注意哪些差异。

到目前为止,我已经了解到在我的 android 上我得到了

  • touchmove 安装了 mousemove,
  • touchstart 设置为 mousedown,
  • touchend insted of mouseup
  • event.touches[0].pageX insted of event.clientX
  • event.touches[0].pageY insted of event.clientY

但这还不够,代码仍然不正常,我还需要学习什么才能让它工作?

例子: http://paint.puggan.se/paint/paint_201305311921.html

当您从同一组中的一个点拖动到另一个点时,它会在它们之间添加一条黄线。 在仍然将其绘制到最近的蓝线时,如果您拖动关闭或停止(鼠标向上),它会添加黄线。

以上在我的电脑上使用 Firefox 中的鼠标可以正常工作。

以上在我的android上不起作用,我可以看到蓝线,但看不到任何黄线

【问题讨论】:

  • 我不太喜欢 Javascript,但这可能是因为您对缩放级别进行了硬编码吗?
  • 缩放级别硬编码在哪里?如果你指的是我的 javascript var zoom,它只是为缩放画布的变量选择的名称,android 仍然可以正常缩放

标签: javascript android touch touchstart touchmove


【解决方案1】:

学到了另一个不同之处,现在它可以工作了。

touchend触发时,列表event.touches为空, 因此 event.touches[0] 失败。

上述示例的工作版本 http://paint.puggan.se/paint/paint_201306011919.html

【讨论】:

  • 嗨,我也遇到了同样的问题。我已经将所有的 touchmove 替换为 mousemove,将 touchstart 替换为 mousedown,将 touchend 替换为 mouseup。但它在我的 android webview 中仍然不起作用,我找不到任何帮助。所以我希望你能告诉我如何解决它。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-10-06
  • 2023-03-07
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多