返回首頁 

Greasy Fork is available in English.

jQuery-Extensions-touchJS

jQuery-Extensions-touchJS是一个非常简单的jQuery touch扩展,用于适配移动端的常用touch操作(点击tab、双击dbTab、长按longPress、长按终止longPressCancel、滑动swipe以及具体滑动方向left、right、up、down)

Fra og med 30.11.2022. Se den nyeste version.

Dette script bør ikke installeres direkte. Det er et bibliotek, som andre scripts kan inkludere med metadirektivet // @require https://update.greasyfork.org/scripts/454450/1123113/jQuery-Extensions-touchJS.js

Skaber
tutu辣么可#
Version
1.4
Oprettet
08.11.2022
Opdateret
30.11.2022
Size
5,25 kB
Licens
N/A

jQuery-Extensions-touchJS

  • 一个非常简单的jQuery touch扩展,用于适配移动端的常用touch操作
  • 支持的touch事件:点击tab、双击dbTab、长按longPress、长按终止longPressCancel、滑动swipe,以及具体滑动方向(左left、右right、上up、下down)

使用方式

  • 添加单个事件(以长按为例)
//指定事件名(可省略,但省略后无法指定删除此事件)$(selector).touch("longPress",()=>{//具体业务},"myLongPress")//或者指定方法myLongPress=function(){//具体业务}$(selector).touch("longPress",myLongPress)
  • 批量添加事件(以长按、长按取消、点击为例)
$(selector).touch({//可通过myLongPress方法名指定删除此事件longPress:myLongPress,//无法指定删除longPressCancel(){//具体业务},tap(){//具体业务}})
  • 删除指定类型的所有事件(以长按为例)
//删除longPress所有事件,格#勿论$.unbindTouch("longPress")
  • 删除指定方法对应的事件(以长按为例)
//通过指定事件名确认唯一事件(添加事件时指定)$(selector).unbindTouch("longPress","myLongPress")//或者通过指定方法确认唯一事件$(selector).unbindTouch("longPress",myLongPress)
  • 查看所有touch事件(仅限于通过本插件产生的事件方法)
$(selector)[0].jQueryTouchFnMap