https://github.com/bh-lay/toucher
:point_up_2: 面向移动端的手势类库
https://github.com/bh-lay/toucher
javascript touches
Last synced: 12 months ago
JSON representation
:point_up_2: 面向移动端的手势类库
- Host: GitHub
- URL: https://github.com/bh-lay/toucher
- Owner: bh-lay
- License: apache-2.0
- Created: 2014-05-25T07:50:24.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2022-05-19T05:19:05.000Z (almost 4 years ago)
- Last Synced: 2025-03-30T18:11:07.852Z (about 1 year ago)
- Topics: javascript, touches
- Language: JavaScript
- Homepage: http://bh-lay.github.io/toucher
- Size: 598 KB
- Stars: 261
- Watchers: 19
- Forks: 157
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
#toucher是什么
toucher是一个面向移动端web开发,通过监听原生事件模拟手势事件的库。
####[使用案例](http://bh-lay.github.io/toucher/)、[demo/图像预览](http://bh-lay.github.io/toucher/swiper/)、[实现原理](http://bh-lay.com/blog/14e212bdbeb)
#目前支持哪些事件
基本事件
* singleTap:轻击
* doubleTap:双击
* longTap:长按
* swipeUp:上划
* swipeRight:右划
* swipeDown:下划
* swipeleft:左划
高级事件
* swipeStart:滑动开始
* swipe:滑动(阻止浏览器默认事件,滑动过程效果更佳)
* swipeEnd:滑动结束
#说明
目前尚不支持双指操作的事件,此类事件可能会在下次大的更新之后作为补充加入进来。
事件触发时不阻止浏览器默认事件,若要用于拖动操作,或滑动更为细腻,可在swipe事件中使用“return false;”阻止浏览器默认事件!
#DEMO
请使用移动设备或使用调试工具模拟移动设备查看 [demo/案例](http://bh-lay.github.io/toucher/)、[demo/图像预览](http://bh-lay.github.io/toucher/swiper/)
#如何使用
接口提供了链式调用的实现,及事件委托(仅支持class)。
```javascript
var myTouch = util.toucher(document.getElementById('touchBox'));
myTouch.on('singleTap',function(e){
//
}).on('longTap',function(e){
//
}).on('singleTap','.checkA',function(e){
console.log(this,e);
return false
});
```