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.39 KB
/
jquery.ui.touch-punch.min.js
1
2
3
4
5
6
7
8
9
10
11
/*!
* jQuery UI Touch Punch 0.2.3
*
* Copyright 2011–2014, Dave Furfero
* Dual licensed under the MIT or GPL Version 2 licenses.
*
* Depends:
* jquery.ui.widget.js
* jquery.ui.mouse.js
*/
!function(t){if(t.support.touch="ontouchend"in document,t.support.touch){var o,e=t.ui.mouse.prototype,u=e._mouseInit,n=e._mouseDestroy;e._touchStart=function(t){!o&&this._mouseCapture(t.originalEvent.changedTouches[0])&&(o=!0,this._touchMoved=!1,c(t,"mouseover"),c(t,"mousemove"),c(t,"mousedown"))},e._touchMove=function(t){o&&(this._touchMoved=!0,c(t,"mousemove"))},e._touchEnd=function(t){o&&(c(t,"mouseup"),c(t,"mouseout"),this._touchMoved||c(t,"click"),o=!1)},e._mouseInit=function(){var o=this;o.element.bind({touchstart:t.proxy(o,"_touchStart"),touchmove:t.proxy(o,"_touchMove"),touchend:t.proxy(o,"_touchEnd")}),u.call(o)},e._mouseDestroy=function(){var o=this;o.element.unbind({touchstart:t.proxy(o,"_touchStart"),touchmove:t.proxy(o,"_touchMove"),touchend:t.proxy(o,"_touchEnd")}),n.call(o)}}function c(o,e){if(!(o.originalEvent.touches.length>1)){var u=o.originalEvent.changedTouches[0],n=document.createEvent("MouseEvents"),c=t(u.target);c.is("input")||c.is("textarea")||c.is("select")||c.closest('div[contenteditable="true"]').length>0?o.stopPropagation():o.preventDefault(),n.initMouseEvent(e,!0,!0,window,1,u.screenX,u.screenY,u.clientX,u.clientY,!1,!1,!1,!1,0,null),o.target.dispatchEvent(n)}}}(jQuery);