-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjquery.touchable.min.js
executable file
·7 lines (7 loc) · 1.37 KB
/
jquery.touchable.min.js
1
2
3
4
5
6
7
/*
jquery.touchable.js (c) 2011 ofk
Released under the MIT License.
*/
(function(b){"ontouchstart"in window&&b.each({touchstart:["mousedown",function(a){var c=a.originalEvent;if(c&&c.touches){var d=c.touches;if(d.length===1)arguments[0]=a=new b.Event("mousedown",d[0]),a.originalEvent=c,b.data(this,"*touchable*identifier",d[0].identifier),b.data(this,"*touchable*"+a.type,a),b.event.handle.apply(this,arguments)}}],touchmove:["mousemove",function(a){var c=a.originalEvent;if(c&&c.touches){var d=c.touches;if(d.length){for(var f=-1,g=b.data(this,"*touchable*identifier"),e=
0,h=d.length;e<h;++e)if(d[e].identifier===g){f=e;break}if(f!==-1)arguments[0]=a=new b.Event("mousemove",d[f]),a.originalEvent=c,b.data(this,"*touchable*"+a.type,a),b.event.handle.apply(this,arguments)}}}],touchend:["mouseup",function(a){var c=a.originalEvent;if(c&&c.touches){for(var d=c.touches,f=b.data(this,"*touchable*identifier"),g=0,e=d.length;g<e;++g)if(d[g].identifier===f)return;arguments[0]=a=b.data(this,"*touchable*mousemove")||b.data(this,"*touchable*mousedown")||a;a.type="mouseup";a.originalEvent=
c;b.removeData(this,"*touchable*mousemove");b.removeData(this,"*touchable*mousedown");b.removeData(this,"*touchable*identifier");b.event.handle.apply(this,arguments)}}]},function(a,c){b.event.special[c[0]]={setup:function(){b.event.add(this,a,c[1])},teardown:function(){b.event.remove(this,a,c[1])}}})})(jQuery);