forked from furf/jquery-ui-touch-punch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jquery.ui.touch-punch.min.js
11 lines (11 loc) · 1.37 KB
/
jquery.ui.touch-punch.min.js
1
2
3
4
5
6
7
8
9
10
11
/*!
* jQuery UI Touch Punch 0.1.1
*
* Copyright 2010, Dave Furfero
* Dual licensed under the MIT or GPL Version 2 licenses.
*
* Depends:
* jquery.ui.widget.js
* jquery.ui.mouse.js
*/
(function($){$.support.touch=typeof Touch==='object';if(!$.support.touch){return}var d=$.ui.mouse.prototype,_mouseInit=d._mouseInit,_mouseDown=d._mouseDown,_mouseUp=d._mouseUp,mouseEvents={touchstart:'mousedown',touchmove:'mousemove',touchend:'mouseup'};function makeMouseEvent(a){var b=a.originalEvent.changedTouches[0];return $.extend(a,{type:mouseEvents[a.type],which:1,pageX:b.pageX,pageY:b.pageY,screenX:b.screenX,screenY:b.screenY,clientX:b.clientX,clientY:b.clientY})}d._mouseInit=function(){var b=this;b.element.bind('touchstart.'+b.widgetName,function(a){return b._mouseDown(makeMouseEvent(a))});_mouseInit.call(b)};d._mouseDown=function(b){var c=this,ret=_mouseDown.call(c,b);c.started=true;c._touchMoveDelegate=function(a){if(!!c.started){return c._mouseMove(makeMouseEvent(a))}else{return true}};c._touchEndDelegate=function(a){return c._mouseUp(makeMouseEvent(a))};$(document).bind('touchmove.'+c.widgetName,c._touchMoveDelegate).bind('touchend.'+c.widgetName,c._touchEndDelegate);return ret};d._mouseUp=function(a){var b=this;b.started=false;$(document).unbind('touchmove.'+b.widgetName,b._touchMoveDelegate).unbind('touchend.'+b.widgetName,b._touchEndDelegate);return _mouseUp.call(b,a)}})(jQuery);