forked from alexgibson/tap.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjquery.tap.js
35 lines (31 loc) · 1.03 KB
/
jquery.tap.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*!
* jQuery special event "tap" using tap.js
* Released under MIT license
*/
(function ($) {
'use strict';
$.event.special.tap = (function () {
// Fallback to click events in old IE
if (!document.addEventListener) return { bindType: 'click', delegateType: 'click' };
var Tap = window.Tap;
var dataKey = 'tap.js';
return {
setup: function () {
$.data(this, dataKey, new Tap(this));
},
teardown: function () {
var tap = $.data(this, dataKey);
if (tap && tap.destroy) {
tap.destroy();
$.removeData(this, dataKey);
}
},
add: function (handleObj) {
this.addEventListener('tap', handleObj.handler, false);
},
remove: function (handleObj) {
this.removeEventListener('tap', handleObj.handler, false);
}
};
}());
}(window.jQuery));