1 | # zepto.touch [![npm package](https://img.shields.io/npm/v/zepto.touch.svg?style=flat-square)](https://www.npmjs.com/package/zepto.touch)
|
2 |
|
3 | a zepto/jquery touch events plugin, it provides touch events like `tap`,`doubleTap`,`longTap`,`swipe`,`swipeLeft`,`swipeRight`,`swipeUp`,`swipeDown`.
|
4 |
|
5 | # installation
|
6 |
|
7 | use npm:
|
8 |
|
9 | npm install zepto.touch
|
10 |
|
11 | use bower:
|
12 |
|
13 | bower install zepto.touch
|
14 |
|
15 | # usage
|
16 |
|
17 | the api is the same as zepto/jquery events, but it also provides setting method, you must write the setting method `$.fn.touch` before the touch events, eg:
|
18 |
|
19 | $('ul').touch({
|
20 | swipeMove: function (e, direction, distance, duration) {
|
21 | console.log(e, direction, distance, duration);
|
22 | }
|
23 | }).on('swipe', 'li', function (e, direction) {
|
24 | console.log(e, direction);
|
25 | }).on('tap.test', function (e) {
|
26 | console.log('tap.test');
|
27 | }).on('tap', function (e) {
|
28 | console.log('tap');
|
29 | $(this).off('tap.test');
|
30 | });
|
31 |
|
32 | # options
|
33 |
|
34 | $.fn.touch.defaults = {
|
35 | fingers: 1,
|
36 | threshold: 75,
|
37 | longTapThreshold: 500,
|
38 | doubleTapThreshold: 200,
|
39 | excludedElements: 'label, button, input, select, textarea, .noTouch',
|
40 | pageScroll: true,
|
41 | swipeMove: null
|
42 | };
|