JQuery.tap.js
/** * Author:sergey Bondarenko (br0ken) * e-mail:broken@propeople.com.ua * GITHUB:HTTPS://GITHUB.COM/BR0KEN-/JTAP *
Updated:may, 2014 * version:0.2.8 * (function ($, _) {' Use strict ';
/** * @param (object) Ev-extending object, which contain event properties.
*-(String) Start-start event depending of @isTap.
*-(String) End-start event depending of @isTap.
* * var ev = {start: ' Touchstart MouseDown ', end: ' Touchend MouseUp '};
$.event.special[_] = {setup:function () {$ (). Off (' click '). On (Ev.start + ' + ev.end, function (e) {
/** * Adding JQuery event to @ev object depending of @isTap. * Attention:value of this property would change two time * per Event:first time-on start, second-
On end. * * ev. E = e.originalevent.changedtouches?
E.originalevent.changedtouches[0]: E; }. On (Ev.start, function (e) {/** * function stop if evenT is simulate by mouse.
*/if (E.which && E.which!== 1) {return;
/** * Extend @ev object from event properties of initial phase.
* * Ev.target = E.target;
Ev.time = new Date (). GetTime (); Ev. X = ev.
E.pagex; Ev. Y = ev.
E.pagey; }. On (Ev.end, function (e) {/** * Compare property values of initial phase with properties * This, final, phase.
Execute event If values would be * within the acceptable and set new properties for event. */if (Ev.target = = E.target && (new Date (). GetTime ()-Ev.time) < 750) &&am
P (EV. X = = ev. E.pagex && ev. Y = = ev.
E.pagey)) {E.type = _; E.pagex = ev.
E.pagex; E.pagey = ev.
E.pagey;
$.event.dispatch.call (this, e);
}
});
},/** * disassembling event. * * Remove:Function () {$ (this). Off (Ev.start, false). Off (Ev.end, false);
}
}; $.fn[_] = function (FN) {return THIS[FN?
' On ': ' Trigger '] (_, FN);
}; }) (JQuery, ' tap ');
DEMO
Reference http://www.cnblogs.com/shenbin/archive/2013/03/21/2973858.html
<! DOCTYPE html>