!function(t){"function"==typeof define&&define.amd?define(["jquery"],t):t(jQuery)}(function(t,e){var n=6,a=t.event.add,i=t.event.remove,o=function(e,n,a){t.event.trigger(n,a,e)},r=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t,e){return window.setTimeout(function(){t()},25)},u={textarea:!0,input:!0,select:!0,button:!0},c={move:"mousemove",cancel:"mouseup dragstart",end:"mouseup"},d={move:"touchmove",cancel:"touchend",end:"touchend"};function m(t){var e=t,n=!1,a=!1;function i(t){n?(e(),r(i),a=!0,n=!1):a=!1}this.kick=function(t){n=!0,a||i()},this.end=function(t){var i=e;t&&(a?(e=n?function(){i(),t()}:t,n=!0):t())}}function f(){return!0}function s(){return!1}function v(t){t.preventDefault()}function p(t){u[t.target.tagName.toLowerCase()]||t.preventDefault()}function g(t,e){var n,a;if(t.identifiedTouch)return t.identifiedTouch(e);for(n=-1,a=t.length;++n<a;)if(t[n].identifier===e)return t[n]}function h(t,e){var n=g(t.changedTouches,e.identifier);if(n&&(n.pageX!==e.pageX||n.pageY!==e.pageY))return n}function l(t){S(t,t.data,t,Y)}function X(t){Y()}function Y(){i(document,c.move,l),i(document,c.cancel,X)}function w(t){var e=t.data,n=h(t,e);n&&S(t,e,n,T)}function y(t){var e=t.data;g(t.changedTouches,e.identifier)&&T(e.identifier)}function T(t){i(document,"."+t,w),i(document,"."+t,y)}function S(t,e,a,i){var r=a.pageX-e.startX,u=a.pageY-e.startY;r*r+u*u<n*n||function(t,e,n,a,i,r){var u,c;e.target;u=t.targetTouches,c=t.timeStamp-e.timeStamp,e.type="movestart",e.distX=a,e.distY=i,e.deltaX=a,e.deltaY=i,e.pageX=n.pageX,e.pageY=n.pageY,e.velocityX=a/c,e.velocityY=i/c,e.targetTouches=u,e.finger=u?u.length:1,e._handled=k,e._preventTouchmoveDefault=function(){t.preventDefault()},o(e.target,e),r(e.identifier)}(t,e,a,r,u,i)}function k(){return this._handled=f,!1}function _(t){t._handled()}function q(t){var e=t.data.timer;t.data.touch=t,t.data.timeStamp=t.timeStamp,e.kick()}function A(t){var e=t.data.event,n=t.data.timer;i(document,c.move,q),i(document,c.end,A),R(e,n,function(){setTimeout(function(){i(e.target,"click",s)},0)})}function D(t){var e=t.data.event,n=t.data.timer,a=h(t,e);a&&(t.preventDefault(),e.targetTouches=t.targetTouches,t.data.touch=a,t.data.timeStamp=t.timeStamp,n.kick())}function F(t){var e=t.data.event,n=t.data.timer;g(t.changedTouches,e.identifier)&&(!function(t){i(document,"."+t.identifier,D),i(document,"."+t.identifier,F)}(e),R(e,n))}function R(t,e,n){e.end(function(){return t.type="moveend",o(t.target,t),n&&n()})}t.event.special.movestart={setup:function(t,e,n){return a(this,"movestart.move",_),!0},teardown:function(t){return i(this,"dragstart drag",v),i(this,"mousedown touchstart",p),i(this,"movestart",_),!0},add:function(t){"move"!==t.namespace&&"moveend"!==t.namespace&&(a(this,"dragstart."+t.guid+" drag."+t.guid,v,e,t.selector),a(this,"mousedown."+t.guid,p,e,t.selector))},remove:function(t){"move"!==t.namespace&&"moveend"!==t.namespace&&(i(this,"dragstart."+t.guid+" drag."+t.guid),i(this,"mousedown."+t.guid))},_default:function(t){var n,i;t._handled()&&(n={target:t.target,startX:t.startX,startY:t.startY,pageX:t.pageX,pageY:t.pageY,distX:t.distX,distY:t.distY,deltaX:t.deltaX,deltaY:t.deltaY,velocityX:t.velocityX,velocityY:t.velocityY,timeStamp:t.timeStamp,identifier:t.identifier,targetTouches:t.targetTouches,finger:t.finger},i={event:n,timer:new m(function(e){!function(t,e,n,a){var i=n-t.timeStamp;t.type="move",t.distX=e.pageX-t.startX,t.distY=e.pageY-t.startY,t.deltaX=e.pageX-t.pageX,t.deltaY=e.pageY-t.pageY,t.velocityX=.3*t.velocityX+.7*t.deltaX/i,t.velocityY=.3*t.velocityY+.7*t.deltaY/i,t.pageX=e.pageX,t.pageY=e.pageY}(n,i.touch,i.timeStamp),o(t.target,n)}),touch:e,timeStamp:e},t.identifier===e?(a(t.target,"click",s),a(document,c.move,q,i),a(document,c.end,A,i)):(t._preventTouchmoveDefault(),a(document,d.move+"."+t.identifier,D,i),a(document,d.end+"."+t.identifier,F,i)))}},t.event.special.move={setup:function(){a(this,"movestart.move",t.noop)},teardown:function(){i(this,"movestart.move",t.noop)}},t.event.special.moveend={setup:function(){a(this,"movestart.moveend",t.noop)},teardown:function(){i(this,"movestart.moveend",t.noop)}},a(document,"mousedown.move",function(t){var e;(function(t){return 1===t.which&&!t.ctrlKey&&!t.altKey})(t)&&(e={target:t.target,startX:t.pageX,startY:t.pageY,timeStamp:t.timeStamp},a(document,c.move,l,e),a(document,c.cancel,X,e))}),a(document,"touchstart.move",function(t){var e,n;u[t.target.tagName.toLowerCase()]||(n={target:(e=t.changedTouches[0]).target,startX:e.pageX,startY:e.pageY,timeStamp:t.timeStamp,identifier:e.identifier},a(document,d.move+"."+e.identifier,w,n),a(document,d.cancel+"."+e.identifier,y,n))}),"function"==typeof Array.prototype.indexOf&&function(t,e){for(var n=["changedTouches","targetTouches"],a=n.length;a--;)-1===t.event.props.indexOf(n[a])&&t.event.props.push(n[a])}(t)});