1.0.0 • Published 7 years ago
touch-actionjs v1.0.0
touch-action.js
A javascript library for gestures
Install
npm install touch-actionjs
// or
yarn add touch-actionjs
Usage
import TouchAction from 'touch-actionjs'
const ta = new TouchAction('.box')
const onTap = function(e) {}
ta.on('tap', onTap)
ta.off('tap', onTap)
Api
on(eventType, handler)
- 绑定事件
eventType: String
handler: Function
off(eventType, handler)
- 移除事件
eventType: String
handler: Function
eventType
- 事件类型
value: tap|dbTap|press|pan|pinch|rotate|swipe
eventObject
- 扩展的事件对象
touchEvent
事件对象的扩展,添加了direction
(swipe的方向)、dx
(x方向上移动的距离)、dy
(y方向上移动的距离)、scale
(缩放大小)、angle
(旋转角度)、eventType
(事件类型)
1.0.0
7 years ago