FastClick


处理移动端 click 事件 300 毫秒延迟, 由 FT Labs 开发(项目地址)。

为什么存在延迟?

根据 Google 开发者文档

...mobile browsers will wait approximately 300ms from the time that you tap the button to fire the click event. The reason for this is that the browser is waiting to see if you are actually performing a double tap.

从点击屏幕上的元素到触发元素的 click 事件,移动浏览器会有大约 300 毫秒的等待时间。为什么这么设计呢? 因为它想看看你是不是要进行双击(double tap)操作。

兼容性

不应用 FastClick 的场景

<meta name="viewport" content="width=device-width, initial-scale=1">

使用方法

Amaze UI 默认已经初始化 FastClick。

如有需要,用户可以通过 $.AMUI.FastClick 调用。

jQuery / Zepto.js:

$(function() {
  $.AMUI.FastClick.attach(document.body);
});

CommonJS:

var attachFastClick = require('fastclick');
attachFastClick(document.body);

Licence