define(["Ti/_/declare","Ti/_/lang"],function(e,n){function t(e){var n;return h?(n=c(e),h=null,{draggingcancel:n}):void 0}function c(e){var n=e.changedTouches[0].clientX,t=e.changedTouches[0].clientY,c=n-h.x,r=t-h.y;return[{x:n,y:t,distanceX:c,distanceY:r,distance:Math.sqrt(Math.pow(c,2)+Math.pow(r,2))}]}var h,r=25;return n.setObject("Ti._.Gestures.Drag",{processTouchStartEvent:function(e){if(1==e.touches.length&&1==e.changedTouches.length){var n,r;return h={x:n=e.changedTouches[0].clientX,y:r=e.changedTouches[0].clientY},{draggingstart:c(e)}}return h?t(e):void 0},processTouchEndEvent:function(e){if(h){var n,o=Math.sqrt(Math.pow(e.changedTouches[0].clientX-h.x,2)+Math.pow(e.changedTouches[0].clientY-h.y,2));return 0===e.touches.length&&1===e.changedTouches.length&&o>r?(n=c(e),h=null,{draggingend:n}):t(e)}},processTouchMoveEvent:function(e){return h?1==e.touches.length&&1==e.changedTouches.length?{dragging:c(e)}:t(e):void 0},processTouchCancelEvent:function(e){return h&&t(e)}})});