javascript - 有时需要两次点击才能触发一个事件。我该如何解决这个问题?

标签 javascript polymer dart-polymer

我知道这是“设计使然”,但在 Web 应用程序尤其是 Polymer 中处理此问题的最佳实践是什么?

我使用 on-tap,有时在 iOS 等平台上。点击几下即可触发任何事件。这会导致糟糕的用户体验,我们 Web 应用程序开发人员已经在与原生应用程序进行一场艰苦的战斗。

相关:

最佳答案

谢谢大家的帮助!这似乎已经为我解决了:

body {
  -ms-touch-action: none;
  touch-action: none
}

来自 https://developers.google.com/web/fundamentals/input/touch/touchevents/#control-gestures-using-touch-actions :

The CSS property touch-action allows you to control the default touch behavior of an element. In our examples, we use touch-action: none to prevent the browser from doing anything with a users’ touch, allowing us to intercept all of the touch events.

touch-action allows you to disable gestures implemented by a browser. For example, IE10+ supports a double-tap to zoom gesture. By setting a touch-action of pan-x | pan-y | manipulation you prevent the default double-tap behavior. This allows you to implement a double-tap gesture yourself. In the case of IE10+, it also eliminates the 300ms click delay.

关于javascript - 有时需要两次点击才能触发一个事件。我该如何解决这个问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28973421/

相关文章:

button - Dart polymer -捕捉切换事件-纸支架内的按钮。 polymer_20错误

dart - 在 Dart 中使用 Polymer UI 元素

javascript - 如何让 Angular Universal 和 PWA 协同工作?

polymer - 显示 polymer 元素内部的元素

javascript - jquery中如何读取输入的二维数组值?

javascript - polymer 阵列错误

javascript - Polymer this 和 Cytoscape this

templates - Dart:WAITING模板完成

javascript - 为什么 setTimeout 调用会产生不同的结果

javascript - Angular JS 服务不工作