JakeSidSmith/react-fastclick
关于
为 React 提供快速触摸事件处理。
网站与应用开发实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文React Fastclick 
Instantly make your desktop / hybrid apps more responsive on touch devices.
React Fastclick automatically adds fastclick touch events to elements with onClick attributes (and those that require special functionality, such as inputs) to prevent the delay that occurs on some touch devices.
Installation
Use npm to install react-fastclick
npm install react-fastclick
Usage
Initialize react-fastclick in your main javascript file before any of your components are created, and you're done.
Now any calls to onClick or elements with special functionality, such as inputs, will have fast touch events added automatically - no need to write any additional listeners.
ES6
import initReactFastclick from 'react-fastclick';
initReactFastclick();
ES5
var initReactFastclick = require('react-fastclick');
initReactFastclick();
Notes
- The event triggered on touch devices is a modified
touchendevent. This means that it may have some keys that are unusual for a click event.
In order to simulate a click as best as possible, this event is populated with the following keys / values. All positions are taken from the last know touch position.
{
// Simulate left click
button: 0,
type: 'click',
// Additional key to tell the difference between
// a regular click and a fastclick
fastclick: true,
// From touch positions
clientX,
clientY,
pageX,
pageY,
screenX,
screenY
}
On some devices the elements flicker after being touched. This can be prevented by setting the css property
-webkit-tap-highlight-colorto transparent. Either targethtml, body(to prevent the flickering on all elements) or target the specific element you don't want to flicker e.g.button.html, body { -webkit-tap-highlight-color: transparent; }
Support
React Fastclick 3.x.x has been tested with React 15, but should support older versions also.
探索相关项目
加载中…