js-Extensions-touchJS
- 一个非常简单的原生js touch扩展,用于适配移动端的常用touch操作
- 支持的touch事件:点击tab、双击dbTab、长按longPress、长按终止longPressCancel、滑动swipe,以及具体滑动方向(左left、右right、上up、下down)
- jQuery请使用jQuery插件版本:jQuery-Extensions-touchJS
使用方式
//指定事件名(可省略,但省略后无法指定删除此事件)
touchJS.bind(target,"longPress",()=>{//具体业务},"myLongPress")
//或者指定方法
myLongPress=function(){//具体业务}
touchJS.bind(target,"longPress",myLongPress)
touchJS.bind(target,{
//可通过myLongPress方法名指定删除此事件
longPress:myLongPress,
//无法指定删除
longPressCancel(){//具体业务},
tap(){//具体业务}
})
//删除longPress所有事件,格杀勿论
touchJS.unbind(target,"longPress")
//通过指定事件名确认唯一事件(添加事件时指定)
touchJS.unbind(target,"longPress","myLongPress")
//或者通过指定方法确认唯一事件
touchJS.unbind(target,"longPress",myLongPress)
- 查看所有touch事件(仅限于通过本插件产生的事件方法)
dom对象.jsTouchFnMap