From 572a1ecc49bac99dab71ab08cbf3b62379476b0e Mon Sep 17 00:00:00 2001 From: Zion Orent Date: Mon, 19 Dec 2016 09:00:04 -0500 Subject: [PATCH] Fixing JS error mentioned in issue 459 See https://github.com/taye/interact.js/issues/188#issuecomment-260472151 and https://github.com/taye/interact.js/issues/459 for more information. --- dist/interact.js | 2 +- dist/interact.min.js | 249 ++++++++++++++++++++------------------- dist/interact.min.js.map | 10 +- interact.js | 2 +- 4 files changed, 132 insertions(+), 131 deletions(-) diff --git a/dist/interact.js b/dist/interact.js index ffbd05d6c..8efa3ceb6 100644 --- a/dist/interact.js +++ b/dist/interact.js @@ -1748,7 +1748,7 @@ // set the startCoords if there was no prepared action if (!this.prepared.name) { - this.setEventXY(this.startCoords); + this.setEventXY(this.startCoords, this.pointers); } this.prepared.name = action.name; diff --git a/dist/interact.min.js b/dist/interact.min.js index a3dcff69d..f39dee901 100644 --- a/dist/interact.min.js +++ b/dist/interact.min.js @@ -1,124 +1,125 @@ -/* interact.js v1.2.6 | https://raw.github.com/taye/interact.js/master/LICENSE */ (function(F){function ma(){}function t(a){if(!a||"object"!==typeof a)return!1;var b=V(a)||q;return/object|function/.test(typeof b.Element)?a instanceof b.Element:1===a.nodeType&&"string"===typeof a.nodeName}function Ba(a){return a===q||!(!a||!a.Window)&&a instanceof a.Window}function da(a){return z(a)&&void 0!==typeof a.length&&A(a.splice)}function z(a){return!!a&&"object"===typeof a}function A(a){return"function"===typeof a}function K(a){return"number"===typeof a}function H(a){return"boolean"=== -typeof a}function N(a){return"string"===typeof a}function ea(a){if(!N(a))return!1;Q.querySelector(a);return!0}function x(a,b){for(var c in b)a[c]=b[c];return a}function ra(a,b){for(var c in b){var d=!1,e;for(e in Ca)if(0===c.indexOf(e)&&Ca[e].test(c)){d=!0;break}d||(a[c]=b[c])}return a}function sa(a,b){a.page=a.page||{};a.page.x=b.page.x;a.page.y=b.page.y;a.client=a.client||{};a.client.x=b.client.x;a.client.y=b.client.y;a.timeStamp=b.timeStamp}function Ta(a,b,c){a.page.x=c.page.x-b.page.x;a.page.y= -c.page.y-b.page.y;a.client.x=c.client.x-b.client.x;a.client.y=c.client.y-b.client.y;a.timeStamp=(new Date).getTime()-b.timeStamp;b=Math.max(a.timeStamp/1E3,.001);a.page.speed=fa(a.page.x,a.page.y)/b;a.page.vx=a.page.x/b;a.page.vy=a.page.y/b;a.client.speed=fa(a.client.x,a.page.y)/b;a.client.vx=a.client.x/b;a.client.vy=a.client.y/b}function Ua(a){return a instanceof q.Event||ga&&q.Touch&&a instanceof q.Touch}function ta(a,b,c){c=c||{};a=a||"page";c.x=b[a+"X"];c.y=b[a+"Y"];return c}function Da(a,b){b= -b||{};Va&&Ua(a)?(ta("screen",a,b),b.x+=q.scrollX,b.y+=q.scrollY):ta("page",a,b);return b}function Wa(a,b){b=b||{};Va&&Ua(a)?ta("screen",a,b):ta("client",a,b);return b}function O(a){return K(a.pointerId)?a.pointerId:a.identifier}function Ea(a){return a instanceof nb?a.correspondingUseElement:a}function V(a){if(Ba(a))return a;a=a.ownerDocument||a;return a.defaultView||a.parentWindow||q}function Fa(a){return(a=a instanceof Xa?a.getBoundingClientRect():a.getClientRects()[0])&&{left:a.left,right:a.right, -top:a.top,bottom:a.bottom,width:a.width||a.right-a.left,height:a.height||a.bottom-a.top}}function ua(a){var b,c=Fa(a);!ob&&c&&(b=(b=V(a))||q,a=b.scrollX||b.document.documentElement.scrollLeft,b=b.scrollY||b.document.documentElement.scrollTop,c.left+=a,c.right+=a,c.top+=b,c.bottom+=b);return c}function Ga(a){var b=[];da(a)?(b[0]=a[0],b[1]=a[1]):"touchend"===a.type?1===a.touches.length?(b[0]=a.touches[0],b[1]=a.changedTouches[0]):0===a.touches.length&&(b[0]=a.changedTouches[0],b[1]=a.changedTouches[1]): -(b[0]=a.touches[0],b[1]=a.touches[1]);return b}function Ya(a){for(var b={pageX:0,pageY:0,clientX:0,clientY:0,screenX:0,screenY:0},c,d=0;db?d+=360+d/360|0:-135>b&&(d+=180+d/360|0));return d}function na(a,b){var c=a?a.options.origin:D.origin;"parent"===c?c=L(b):"self"===c?c=a.getRect(b):ea(c)&&(c=Ka(b,c)||{x:0,y:0});A(c)&&(c=c(a&&b));t(c)&&(c=ua(c));c.x="x"in c?c.x:c.left;c.y="y"in -c?c.y:c.top;return c}function Za(a,b,c,d){var e=1-a;return e*e*b+2*e*a*c+a*a*d}function Y(a,b){for(;b;){if(b===a)return!0;b=b.parentNode}return!1}function Ka(a,b){for(var c=L(a);t(c);){if(R(c,b))return c;c=L(c)}return null}function L(a){if((a=a.parentNode)&&a instanceof $a)for(;(a=a.host)&&a&&a instanceof $a;);return a}function va(a,b){return a._context===b.ownerDocument||Y(a._context,b)}function Z(a,b,c){return(a=a.options.ignoreFrom)&&t(c)?N(a)?La(c,a,b):t(a)?Y(a,c):!1:!1}function aa(a,b,c){return(a= -a.options.allowFrom)?t(c)?N(a)?La(c,a,b):t(a)?Y(a,c):!1:!1:!0}function ab(a,b){if(!b)return!1;var c=b.options.drag.axis;return"xy"===a||"xy"===c||c===a}function Ma(a,b){var c=a.options;/^resize/.test(b)&&(b="resize");return c[b].snap&&c[b].snap.enabled}function Na(a,b){var c=a.options;/^resize/.test(b)&&(b="resize");return c[b].restrict&&c[b].restrict.enabled}function ha(a,b,c){for(var d=a.options,e=d[c.name].max,d=d[c.name].maxPerElement,h=0,f=0,g=0,k=0,y=r.length;k=wa||n.target===a&&(f+=u===c.name|0,f>=e||n.element===b&&(g++,u!==c.name||g>=d))))return!1}return 0(new Date).getTime()-db)return}if(c=bb(b,b.type,d))c._updateEventTargets(d,e),c[a](b,b,d,e)}}}function G(a,b,c,d,e,h){var f,g,k=a.target,y=a.snapStatus,n=a.restrictStatus,u=a.pointers,E=(k&&k.options||D).deltaSource,eb=E+"X",l=E+"Y",ia=k?k.options:D,w=na(k,e),m="start"===d,p="end"===d;f=m?a.startCoords:a.curCoords;e=e||a.element;g=x({},f.page);f=x({},f.client);g.x-=w.x;g.y-=w.y;f.x-=w.x;f.y-=w.y;var I=ia[c].snap&&ia[c].snap.relativePoints;!Ma(k,c)||m&&I&&I.length||(this.snap={range:y.range, -locked:y.locked,x:y.snappedX,y:y.snappedY,realX:y.realX,realY:y.realY,dx:y.dx,dy:y.dy},y.locked&&(g.x+=y.dx,g.y+=y.dy,f.x+=y.dx,f.y+=y.dy));!Na(k,c)||m&&ia[c].restrict.elementRect||!n.restricted||(g.x+=n.dx,g.y+=n.dy,f.x+=n.dx,f.y+=n.dy,this.restrict={dx:n.dx,dy:n.dy});this.pageX=g.x;this.pageY=g.y;this.clientX=f.x;this.clientY=f.y;this.x0=a.startCoords.page.x-w.x;this.y0=a.startCoords.page.y-w.y;this.clientX0=a.startCoords.client.x-w.x;this.clientY0=a.startCoords.client.y-w.y;this.ctrlKey=b.ctrlKey; -this.altKey=b.altKey;this.shiftKey=b.shiftKey;this.metaKey=b.metaKey;this.button=b.button;this.buttons=b.buttons;this.target=e;this.t0=a.downTimes[0];this.type=c+(d||"");this.interaction=a;this.interactable=k;e=a.inertiaStatus;e.active&&(this.detail="inertia");h&&(this.relatedTarget=h);p?"client"===E?(this.dx=f.x-a.startCoords.client.x,this.dy=f.y-a.startCoords.client.y):(this.dx=g.x-a.startCoords.page.x,this.dy=g.y-a.startCoords.page.y):m?this.dy=this.dx=0:"inertiastart"===d?(this.dx=a.prevEvent.dx, -this.dy=a.prevEvent.dy):"client"===E?(this.dx=f.x-a.prevEvent.clientX,this.dy=f.y-a.prevEvent.clientY):(this.dx=g.x-a.prevEvent.pageX,this.dy=g.y-a.prevEvent.pageY);a.prevEvent&&"inertia"===a.prevEvent.detail&&!e.active&&ia[c].inertia&&ia[c].inertia.zeroResumeDelta&&(e.resumeDx+=this.dx,e.resumeDy+=this.dy,this.dx=this.dy=0);"resize"===c&&a.resizeAxes?ia.resize.square?("y"===a.resizeAxes?this.dx=this.dy:this.dy=this.dx,this.axes="xy"):(this.axes=a.resizeAxes,"x"===a.resizeAxes?this.dy=0:"y"===a.resizeAxes&& -(this.dx=0)):"gesture"===c&&(this.touches=[u[0],u[1]],m?(this.distance=Ia(u,E),this.box=Ha(u),this.scale=1,this.ds=0,this.angle=Ja(u,void 0,E),this.da=0):p||b instanceof G?(this.distance=a.prevEvent.distance,this.box=a.prevEvent.box,this.scale=a.prevEvent.scale,this.ds=this.scale-1,this.angle=a.prevEvent.angle,this.da=this.angle-a.gesture.startAngle):(this.distance=Ia(u,E),this.box=Ha(u),this.scale=this.distance/a.gesture.startDistance,this.angle=Ja(u,a.gesture.prevAngle,E),this.ds=this.scale-a.gesture.prevScale, -this.da=this.angle-a.gesture.prevAngle));m?(this.timeStamp=a.downTimes[0],this.velocityY=this.velocityX=this.speed=this.duration=this.dt=0):"inertiastart"===d?(this.timeStamp=a.prevEvent.timeStamp,this.dt=a.prevEvent.dt,this.duration=a.prevEvent.duration,this.speed=a.prevEvent.speed,this.velocityX=a.prevEvent.velocityX,this.velocityY=a.prevEvent.velocityY):(this.timeStamp=(new Date).getTime(),this.dt=this.timeStamp-a.prevEvent.timeStamp,this.duration=this.timeStamp-a.downTimes[0],b instanceof G?(b= -this[eb]-a.prevEvent[eb],l=this[l]-a.prevEvent[l],c=this.dt/1E3,this.speed=fa(b,l)/c,this.velocityX=b/c,this.velocityY=l/c):(this.speed=a.pointerDelta[E].speed,this.velocityX=a.pointerDelta[E].vx,this.velocityY=a.pointerDelta[E].vy));(p||"inertiastart"===d)&&600this.timeStamp-a.prevEvent.timeStamp&&(d=180*Math.atan2(a.prevEvent.velocityY,a.prevEvent.velocityX)/Math.PI,0>d&&(d+=360),p=112.5<=d&&247.5>d,l=202.5<=d&&337.5>d,this.swipe={up:l,down:!l&&22.5<=d&&157.5>d,left:p,right:!p&& -(292.5<=d||67.5>d),angle:d,speed:a.prevEvent.speed,velocity:{x:a.prevEvent.velocityX,y:a.prevEvent.velocityY}})}function fb(){this.originalEvent.preventDefault()}function gb(a){var b="";"drag"===a.name&&(b=za.drag);if("resize"===a.name)if(a.axis)b=za[a.name+a.axis];else if(a.edges){for(var b="resize",c=["top","bottom","left","right"],d=0;4>d;d++)a.edges[c[d]]&&(b+=c[d]);b=za[b]}return b}function hb(a,b,c){a=this.getRect(c);var d=!1,e=null,h=null,f,g=x({},b.curCoords.page),e=this.options;if(!a)return null; -if(S.resize&&e.resize.enabled)if(d=e.resize,f={left:!1,right:!1,top:!1,bottom:!1},z(d.edges)){for(var k in f){var y=f,n=k,u;a:{u=k;var E=d.edges[k],l=g,m=b._eventTarget,p=c,w=a,ya=d.margin||pa;if(E){if(!0===E){var q=K(w.width)?w.width:w.right-w.left,I=K(w.height)?w.height:w.bottom-w.top;0>q&&("left"===u?u="right":"right"===u&&(u="left"));0>I&&("top"===u?u="bottom":"bottom"===u&&(u="top"));if("left"===u){u=l.x<(0<=q?w.left:w.right)+ya;break a}if("top"===u){u=l.y<(0<=I?w.top:w.bottom)+ya;break a}if("right"=== -u){u=l.x>(0<=q?w.right:w.left)-ya;break a}if("bottom"===u){u=l.y>(0<=I?w.bottom:w.top)-ya;break a}}u=t(m)?t(E)?E===m:La(m,E,p):!1}else u=!1}y[n]=u}f.left=f.left&&!f.right;f.top=f.top&&!f.bottom;d=f.left||f.right||f.top||f.bottom}else c="y"!==e.resize.axis&&g.x>a.right-pa,a="x"!==e.resize.axis&&g.y>a.bottom-pa,d=c||a,h=(c?"x":"")+(a?"y":"");e=d?"resize":S.drag&&e.drag.enabled?"drag":null;S.gesture&&2<=b.pointerIds.length&&!b.dragging&&!b.resizing&&(e="gesture");return e?{name:e,axis:h,edges:f}:null} -function W(a,b){if(!z(a))return null;var c=a.name,d=b.options;return("resize"===c&&d.resize.enabled||"drag"===c&&d.drag.enabled||"gesture"===c&&d.gesture.enabled)&&S[c]?a:null}function qa(a,b){var c={},d=P[a.type],e=Ea(a.path?a.path[0]:a.target),h=e;b=b?!0:!1;for(var f in a)c[f]=a[f];c.originalEvent=a;for(c.preventDefault=fb;t(h);){for(f=0;fthis.pointerIds.length&&(f=null),this.prepared.name=f.name,this.prepared.axis=f.axis,this.prepared.edges=f.edges,this.snapStatus.snappedX=this.snapStatus.snappedY=this.restrictStatus.restrictedX=this.restrictStatus.restrictedY=NaN,this.downTimes[h]=(new Date).getTime(),this.downTargets[h]=c,ra(this.downPointer,a),sa(this.prevCoords,this.startCoords),this.pointerWasMoved=!1,this.checkAndPreventDefault(b,g,this.element)))}},setModifications:function(a, -b){var c=this.target,d=!0,e=Ma(c,this.prepared.name)&&(!c.options[this.prepared.name].snap.endOnly||b),c=Na(c,this.prepared.name)&&(!c.options[this.prepared.name].restrict.endOnly||b);e?this.setSnapping(a):this.snapStatus.locked=!1;c?this.setRestriction(a):this.restrictStatus.restricted=!1;e&&this.snapStatus.locked&&!this.snapStatus.changed?d=c&&this.restrictStatus.restricted&&this.restrictStatus.changed:c&&this.restrictStatus.restricted&&!this.restrictStatus.changed&&(d=!1);return d},setStartOffsets:function(a, -b,c){a=b.getRect(c);var d=na(b,c);c=b.options[this.prepared.name].snap;b=b.options[this.prepared.name].restrict;var e,h;a?(this.startOffset.left=this.startCoords.page.x-a.left,this.startOffset.top=this.startCoords.page.y-a.top,this.startOffset.right=a.right-this.startCoords.page.x,this.startOffset.bottom=a.bottom-this.startCoords.page.y,e="width"in a?a.width:a.right-a.left,h="height"in a?a.height:a.bottom-a.top):this.startOffset.left=this.startOffset.top=this.startOffset.right=this.startOffset.bottom= -0;this.snapOffsets.splice(0);d=c&&"startCoords"===c.offset?{x:this.startCoords.page.x-d.x,y:this.startCoords.page.y-d.y}:c&&c.offset||{x:0,y:0};if(a&&c&&c.relativePoints&&c.relativePoints.length)for(var f=0;fQa);d||this.pointerIsDown&&!this.pointerWasMoved||(this.pointerIsDown&&clearTimeout(this.holdTimers[h]),this.collectEventTargets(a,b,c,"move"));if(this.pointerIsDown)if(d&&this.pointerWasMoved&&!e)this.checkAndPreventDefault(b,this.target,this.element);else if(Ta(this.pointerDelta,this.prevCoords,this.curCoords),this.prepared.name){if(this.pointerWasMoved&&(!this.inertiaStatus.active||a instanceof G&&/inertiastart/.test(a.type))){if(!this.interacting()&&(Ta(this.pointerDelta, -this.prevCoords,this.curCoords),"drag"===this.prepared.name)){f=Math.abs(f);g=Math.abs(g);d=this.target.options.drag.axis;var k=f>g?"x":fk.bottom&&(b=k.top,k.top=k.bottom,k.bottom=b),k.left>k.right&&(b=k.left,k.left=k.right,k.right=b))):(k.top=Math.min(g.top,f.bottom),k.bottom=Math.max(g.bottom,f.top),k.left=Math.min(g.left,f.right),k.right=Math.max(g.right,f.left));k.width=k.right-k.left;k.height=k.bottom-k.top;for(var q in k)l[q]=k[q]-n[q];a.edges=this.prepared.edges;a.rect=k;a.deltaRect=l}this.target.fire(a); -return a},gestureStart:function(a){a=new G(this,a,"gesture","start",this.element);a.ds=0;this.gesture.startDistance=this.gesture.prevDistance=a.distance;this.gesture.startAngle=this.gesture.prevAngle=a.angle;this.gesture.scale=1;this.gesturing=!0;this.target.fire(a);return a},gestureMove:function(a){if(!this.pointerIds.length)return this.prevEvent;a=new G(this,a,"gesture","move",this.element);a.ds=a.scale-this.gesture.scale;this.target.fire(a);this.gesture.prevAngle=a.angle;this.gesture.prevDistance= -a.distance;Infinity===a.scale||null===a.scale||void 0===a.scale||isNaN(a.scale)||(this.gesture.scale=a.scale);return a},pointerHold:function(a,b,c){this.collectEventTargets(a,b,c,"hold")},pointerUp:function(a,b,c,d){var e=this.mouse?0:v(this.pointerIds,O(a));clearTimeout(this.holdTimers[e]);this.collectEventTargets(a,b,c,"up");this.collectEventTargets(a,b,c,"tap");this.pointerEnd(a,b,c,d);this.removePointer(a)},pointerCancel:function(a,b,c,d){var e=this.mouse?0:v(this.pointerIds,O(a));clearTimeout(this.holdTimers[e]); -this.collectEventTargets(a,b,c,"cancel");this.pointerEnd(a,b,c,d);this.removePointer(a)},ie8Dblclick:function(a,b,c){this.prevTap&&b.clientX===this.prevTap.clientX&&b.clientY===this.prevTap.clientY&&c===this.prevTap.target&&(this.downTargets[0]=c,this.downTimes[0]=(new Date).getTime(),this.collectEventTargets(a,b,c,"tap"))},pointerEnd:function(a,b,c,d){var e,h=this.target,f=h&&h.options,g=f&&this.prepared.name&&f[this.prepared.name].inertia;e=this.inertiaStatus;if(this.interacting()){if(e.active&& -!e.ending)return;var k=(new Date).getTime(),l=!1,m=!1,n=!1,p=Ma(h,this.prepared.name)&&f[this.prepared.name].snap.endOnly,q=Na(h,this.prepared.name)&&f[this.prepared.name].restrict.endOnly,r=0,t=0,f=this.dragging?"x"===f.drag.axis?Math.abs(this.pointerDelta.client.vx):"y"===f.drag.axis?Math.abs(this.pointerDelta.client.vy):this.pointerDelta.client.speed:this.pointerDelta.client.speed,m=(l=g&&g.enabled&&"gesture"!==this.prepared.name&&b!==e.startEvent)&&50>k-this.curCoords.timeStamp&&f>g.minSpeed&& -f>g.endSpeed;l&&!m&&(p||q)&&(g={},g.snap=g.restrict=g,p&&(this.setSnapping(this.curCoords.page,g),g.locked&&(r+=g.dx,t+=g.dy)),q&&(this.setRestriction(this.curCoords.page,g),g.restricted&&(r+=g.dx,t+=g.dy)),r||t)&&(n=!0);if(m||n){sa(e.upCoords,this.curCoords);this.pointers[0]=e.startEvent=new G(this,b,this.prepared.name,"inertiastart",this.element);e.t0=k;h.fire(e.startEvent);m?(e.vx0=this.pointerDelta.client.vx,e.vy0=this.pointerDelta.client.vy,e.v0=f,this.calcInertia(e),b=x({},this.curCoords.page), -h=na(h,this.element),b.x=b.x+e.xe-h.x,b.y=b.y+e.ye-h.y,h={useStatusXY:!0,x:b.x,y:b.y,dx:0,dy:0,snap:null},h.snap=h,r=t=0,p&&(b=this.setSnapping(this.curCoords.page,h),b.locked&&(r+=b.dx,t+=b.dy)),q&&(h=this.setRestriction(this.curCoords.page,h),h.restricted&&(r+=h.dx,t+=h.dy)),e.modifiedXe+=r,e.modifiedYe+=t,e.i=T(this.boundInertiaFrame)):(e.smoothEnd=!0,e.xe=r,e.ye=t,e.sx=e.sy=0,e.i=T(this.boundSmoothEndFrame));e.active=!0;return}(p||q)&&this.pointerMove(a,b,c,d,!0)}this.dragging?(e=new G(this,b, -"drag","end",this.element),q=this.getDrop(e,b,this.element),this.dropTarget=q.dropzone,this.dropElement=q.element,q=this.getDropEvents(b,e),q.leave&&this.prevDropTarget.fire(q.leave),q.enter&&this.dropTarget.fire(q.enter),q.drop&&this.dropTarget.fire(q.drop),q.deactivate&&this.fireActiveDrops(q.deactivate),h.fire(e)):this.resizing?(e=new G(this,b,"resize","end",this.element),h.fire(e)):this.gesturing&&(e=new G(this,b,"gesture","end",this.element),h.fire(e));this.stop(b)},collectDrops:function(a){var b= -[],c=[],d;a=a||this.element;for(d=0;dk),g["double"]=l,this.tapTime=g.timeStamp);for(a=0;ah.innerWidth-p.margin, -a=a.clientY>h.innerHeight-p.margin):(h=Fa(h),d=a.clientXh.right-p.margin,a=a.clientY>h.bottom-p.margin);p.x=c?1:d?-1:0;p.y=a?1:b?-1:0;p.isScrolling||(p.margin=e.margin,p.speed=e.speed,p.start(this))}},_updateEventTargets:function(a,b){this._eventTarget=a;this._curEventTarget=b}};G.prototype={preventDefault:ma,stopImmediatePropagation:function(){this.immediatePropagationStopped=this.propagationStopped=!0},stopPropagation:function(){this.propagationStopped= -!0}};for(var m={},lb="dragStart dragMove resizeStart resizeMove gestureStart gestureMove pointerOver pointerOut pointerHover selectorDown pointerDown pointerMove pointerUp pointerCancel pointerEnd addPointer removePointer recordPointer autoScrollMove".split(" "),Ra=0,Sa=lb.length;Rah.left&&k.xh.top&&k.y=h.left&&f<=h.right&&l>=h.top&&l<=h.bottom;K(g)&&(f=Math.max(0,Math.min(h.right,k.right)-Math.max(h.left,k.left))*Math.max(0,Math.min(h.bottom,k.bottom)-Math.max(h.top,k.top))/(k.width*k.height)>=g);this.options.drop.checker&&(f=this.options.drop.checker(a,b,f,this,e,c,d));return f},dropChecker:function(a){return A(a)?(this.options.drop.checker=a,this): -null===a?(delete this.options.getRect,this):this.options.drop.checker},accept:function(a){return t(a)||ea(a)?(this.options.drop.accept=a,this):null===a?(delete this.options.drop.accept,this):this.options.drop.accept},resizable:function(a){return z(a)?(this.options.resize.enabled=!1===a.enabled?!1:!0,this.setPerAction("resize",a),this.setOnEvents("resize",a),/^x$|^y$|^xy$/.test(a.axis)?this.options.resize.axis=a.axis:null===a.axis&&(this.options.resize.axis=D.resize.axis),H(a.preserveAspectRatio)? -this.options.resize.preserveAspectRatio=a.preserveAspectRatio:H(a.square)&&(this.options.resize.square=a.square),this):H(a)?(this.options.resize.enabled=a,this):this.options.resize},squareResize:function(a){return H(a)?(this.options.resize.square=a,this):null===a?(delete this.options.resize.square,this):this.options.resize.square},gesturable:function(a){return z(a)?(this.options.gesture.enabled=!1===a.enabled?!1:!0,this.setPerAction("gesture",a),this.setOnEvents("gesture",a),this):H(a)?(this.options.gesture.enabled= -a,this):this.options.gesture},autoScroll:function(a){z(a)?a=x({actions:["drag","resize"]},a):H(a)&&(a={actions:["drag","resize"],enabled:a});return this.setOptions("autoScroll",a)},snap:function(a){a=this.setOptions("snap",a);return a===this?this:a.drag},setOptions:function(a,b){var c=b&&da(b.actions)?b.actions:["drag"],d;if(z(b)||H(b)){for(d=0;dD){l/=D;t/=D;x=l*l+t*t;for(B=2;Bb?d+=360+d/360|0:-135>b&&(d+=180+d/360|0));return d}function na(a,b){var c=a?a.options.origin:G.origin;"parent"===c?c=M(b):"self"===c?c=a.getRect(b):fa(c)&&(c=Ia(b,c)||{x:0,y:0});x(c)&&(c=c(a&&b));t(c)&&(c=ua(c));c.x="x"in c?c.x:c.left;c.y="y"in c?c.y:c.top;return c}function Xa(a,b,c, +d){var e=1-a;return e*e*b+2*e*a*c+a*a*d}function aa(a,b){for(;b;){if(b===a)return!0;b=b.parentNode}return!1}function Ia(a,b){for(var c=M(a);t(c);){if(S(c,b))return c;c=M(c)}return null}function M(a){if((a=a.parentNode)&&a instanceof Ya)for(;(a=a.host)&&a&&a instanceof Ya;);return a}function va(a,b){return a._context===b.ownerDocument||aa(a._context,b)}function ba(a,b,c){return(a=a.options.ignoreFrom)&&t(c)?O(a)?Ja(c,a,b):t(a)?aa(a,c):!1:!1}function ca(a,b,c){return(a=a.options.allowFrom)?t(c)?O(a)? +Ja(c,a,b):t(a)?aa(a,c):!1:!1:!0}function Za(a,b){if(!b)return!1;var c=b.options.drag.axis;return"xy"===a||"xy"===c||c===a}function Ka(a,b){var c=a.options;/^resize/.test(b)&&(b="resize");return c[b].snap&&c[b].snap.enabled}function La(a,b){var c=a.options;/^resize/.test(b)&&(b="resize");return c[b].restrict&&c[b].restrict.enabled}function ia(a,b,c){for(var d=a.options,e=d[c.name].max,d=d[c.name].maxPerElement,f=0,g=0,h=0,k=0,u=y.length;k=wa||p.target===a&&(g+=r===c.name|0,g>=e||p.element===b&&(h++,r!==c.name||h>=d))))return!1}return 0(new Date).getTime()-bb)return}if(c= +$a(b,b.type,d))c._updateEventTargets(d,e),c[a](b,b,d,e)}}}function H(a,b,c,d,e,f){var g,h,k=a.target,u=a.snapStatus,p=a.restrictStatus,r=a.pointers,z=(k&&k.options||G).deltaSource,n=z+"X",l=z+"Y",t=k?k.options:G,X=na(k,e),q="start"===d,m="end"===d;g=q?a.startCoords:a.curCoords;e=e||a.element;h=C({},g.page);g=C({},g.client);h.x-=X.x;h.y-=X.y;g.x-=X.x;g.y-=X.y;var ja=t[c].snap&&t[c].snap.relativePoints;!Ka(k,c)||q&&ja&&ja.length||(this.snap={range:u.range,locked:u.locked,x:u.snappedX,y:u.snappedY,realX:u.realX, +realY:u.realY,dx:u.dx,dy:u.dy},u.locked&&(h.x+=u.dx,h.y+=u.dy,g.x+=u.dx,g.y+=u.dy));!La(k,c)||q&&t[c].restrict.elementRect||!p.restricted||(h.x+=p.dx,h.y+=p.dy,g.x+=p.dx,g.y+=p.dy,this.restrict={dx:p.dx,dy:p.dy});this.pageX=h.x;this.pageY=h.y;this.clientX=g.x;this.clientY=g.y;this.x0=a.startCoords.page.x-X.x;this.y0=a.startCoords.page.y-X.y;this.clientX0=a.startCoords.client.x-X.x;this.clientY0=a.startCoords.client.y-X.y;this.ctrlKey=b.ctrlKey;this.altKey=b.altKey;this.shiftKey=b.shiftKey;this.metaKey= +b.metaKey;this.button=b.button;this.buttons=b.buttons;this.target=e;this.t0=a.downTimes[0];this.type=c+(d||"");this.interaction=a;this.interactable=k;e=a.inertiaStatus;e.active&&(this.detail="inertia");f&&(this.relatedTarget=f);m?"client"===z?(this.dx=g.x-a.startCoords.client.x,this.dy=g.y-a.startCoords.client.y):(this.dx=h.x-a.startCoords.page.x,this.dy=h.y-a.startCoords.page.y):q?this.dy=this.dx=0:"inertiastart"===d?(this.dx=a.prevEvent.dx,this.dy=a.prevEvent.dy):"client"===z?(this.dx=g.x-a.prevEvent.clientX, +this.dy=g.y-a.prevEvent.clientY):(this.dx=h.x-a.prevEvent.pageX,this.dy=h.y-a.prevEvent.pageY);a.prevEvent&&"inertia"===a.prevEvent.detail&&!e.active&&t[c].inertia&&t[c].inertia.zeroResumeDelta&&(e.resumeDx+=this.dx,e.resumeDy+=this.dy,this.dx=this.dy=0);"resize"===c&&a.resizeAxes?t.resize.square?("y"===a.resizeAxes?this.dx=this.dy:this.dy=this.dx,this.axes="xy"):(this.axes=a.resizeAxes,"x"===a.resizeAxes?this.dy=0:"y"===a.resizeAxes&&(this.dx=0)):"gesture"===c&&(this.touches=[r[0],r[1]],q?(this.distance= +Ga(r,z),this.box=Fa(r),this.scale=1,this.ds=0,this.angle=Ha(r,void 0,z),this.da=0):m||b instanceof H?(this.distance=a.prevEvent.distance,this.box=a.prevEvent.box,this.scale=a.prevEvent.scale,this.ds=this.scale-1,this.angle=a.prevEvent.angle,this.da=this.angle-a.gesture.startAngle):(this.distance=Ga(r,z),this.box=Fa(r),this.scale=this.distance/a.gesture.startDistance,this.angle=Ha(r,a.gesture.prevAngle,z),this.ds=this.scale-a.gesture.prevScale,this.da=this.angle-a.gesture.prevAngle));q?(this.timeStamp= +a.downTimes[0],this.velocityY=this.velocityX=this.speed=this.duration=this.dt=0):"inertiastart"===d?(this.timeStamp=a.prevEvent.timeStamp,this.dt=a.prevEvent.dt,this.duration=a.prevEvent.duration,this.speed=a.prevEvent.speed,this.velocityX=a.prevEvent.velocityX,this.velocityY=a.prevEvent.velocityY):(this.timeStamp=(new Date).getTime(),this.dt=this.timeStamp-a.prevEvent.timeStamp,this.duration=this.timeStamp-a.downTimes[0],b instanceof H?(b=this[n]-a.prevEvent[n],l=this[l]-a.prevEvent[l],c=this.dt/ +1E3,this.speed=ga(b,l)/c,this.velocityX=b/c,this.velocityY=l/c):(this.speed=a.pointerDelta[z].speed,this.velocityX=a.pointerDelta[z].vx,this.velocityY=a.pointerDelta[z].vy));(m||"inertiastart"===d)&&600this.timeStamp-a.prevEvent.timeStamp&&(d=180*Math.atan2(a.prevEvent.velocityY,a.prevEvent.velocityX)/Math.PI,0>d&&(d+=360),m=112.5<=d&&247.5>d,l=202.5<=d&&337.5>d,this.swipe={up:l,down:!l&&22.5<=d&&157.5>d,left:m,right:!m&&(292.5<=d||67.5>d),angle:d,speed:a.prevEvent.speed,velocity:{x:a.prevEvent.velocityX, +y:a.prevEvent.velocityY}})}function cb(){this.originalEvent.preventDefault()}function db(a){var b="";"drag"===a.name&&(b=ya.drag);if("resize"===a.name)if(a.axis)b=ya[a.name+a.axis];else if(a.edges){for(var b="resize",c=["top","bottom","left","right"],d=0;4>d;d++)a.edges[c[d]]&&(b+=c[d]);b=ya[b]}return b}function eb(a,b,c){var d=this.getRect(c),e=!1,f=null,g,h=C({},b.curCoords.page);a=this.options;if(!d)return null;if(T.resize&&a.resize.enabled)if(e=a.resize,g={left:!1,right:!1,top:!1,bottom:!1},v(e.edges)){for(var k in g){var u= +g,p=k,r;a:{r=k;var z=e.edges[k],l=h,n=b._eventTarget,q=c,m=d,x=e.margin||pa;if(z){if(!0===z){var w=D(m.width)?m.width:m.right-m.left,ja=D(m.height)?m.height:m.bottom-m.top;0>w&&("left"===r?r="right":"right"===r&&(r="left"));0>ja&&("top"===r?r="bottom":"bottom"===r&&(r="top"));if("left"===r){r=l.x<(0<=w?m.left:m.right)+x;break a}if("top"===r){r=l.y<(0<=ja?m.top:m.bottom)+x;break a}if("right"===r){r=l.x>(0<=w?m.right:m.left)-x;break a}if("bottom"===r){r=l.y>(0<=ja?m.bottom:m.top)-x;break a}}r=t(n)? +t(z)?z===n:Ja(n,z,q):!1}else r=!1}u[p]=r}g.left=g.left&&!g.right;g.top=g.top&&!g.bottom;e=g.left||g.right||g.top||g.bottom}else c="y"!==a.resize.axis&&h.x>d.right-pa,d="x"!==a.resize.axis&&h.y>d.bottom-pa,e=c||d,f=(c?"x":"")+(d?"y":"");a=e?"resize":T.drag&&a.drag.enabled?"drag":null;T.gesture&&2<=b.pointerIds.length&&!b.dragging&&!b.resizing&&(a="gesture");return a?{name:a,axis:f,edges:g}:null}function Y(a,b){if(!v(a))return null;var c=a.name,d=b.options;return("resize"===c&&d.resize.enabled||"drag"=== +c&&d.drag.enabled||"gesture"===c&&d.gesture.enabled)&&T[c]?a:null}function qa(a,b){var c={},d=Q[a.type],e=Ca(a.path?a.path[0]:a.target),f=e;b=b?!0:!1;for(var g in a)c[g]=a[g];c.originalEvent=a;for(c.preventDefault=cb;t(f);){for(g=0;gthis.pointerIds.length&&(g=null),this.prepared.name=g.name,this.prepared.axis=g.axis,this.prepared.edges=g.edges,this.snapStatus.snappedX=this.snapStatus.snappedY=this.restrictStatus.restrictedX=this.restrictStatus.restrictedY= +NaN,this.downTimes[f]=(new Date).getTime(),this.downTargets[f]=c,ra(this.downPointer,a),sa(this.prevCoords,this.startCoords),this.pointerWasMoved=!1,this.checkAndPreventDefault(b,h,this.element)))}},setModifications:function(a,b){var c=this.target,d=!0,e=Ka(c,this.prepared.name)&&(!c.options[this.prepared.name].snap.endOnly||b),c=La(c,this.prepared.name)&&(!c.options[this.prepared.name].restrict.endOnly||b);e?this.setSnapping(a):this.snapStatus.locked=!1;c?this.setRestriction(a):this.restrictStatus.restricted= +!1;e&&this.snapStatus.locked&&!this.snapStatus.changed?d=c&&this.restrictStatus.restricted&&this.restrictStatus.changed:c&&this.restrictStatus.restricted&&!this.restrictStatus.changed&&(d=!1);return d},setStartOffsets:function(a,b,c){a=b.getRect(c);var d=na(b,c);c=b.options[this.prepared.name].snap;b=b.options[this.prepared.name].restrict;var e,f;a?(this.startOffset.left=this.startCoords.page.x-a.left,this.startOffset.top=this.startCoords.page.y-a.top,this.startOffset.right=a.right-this.startCoords.page.x, +this.startOffset.bottom=a.bottom-this.startCoords.page.y,e="width"in a?a.width:a.right-a.left,f="height"in a?a.height:a.bottom-a.top):this.startOffset.left=this.startOffset.top=this.startOffset.right=this.startOffset.bottom=0;this.snapOffsets.splice(0);d=c&&"startCoords"===c.offset?{x:this.startCoords.page.x-d.x,y:this.startCoords.page.y-d.y}:c&&c.offset||{x:0,y:0};if(a&&c&&c.relativePoints&&c.relativePoints.length)for(var g=0;gOa);d||this.pointerIsDown&&!this.pointerWasMoved||(this.pointerIsDown&&clearTimeout(this.holdTimers[f]),this.collectEventTargets(a,b,c,"move"));if(this.pointerIsDown)if(d&&this.pointerWasMoved&&!e)this.checkAndPreventDefault(b,this.target,this.element);else if(Ra(this.pointerDelta, +this.prevCoords,this.curCoords),this.prepared.name){if(this.pointerWasMoved&&(!this.inertiaStatus.active||a instanceof H&&/inertiastart/.test(a.type))){if(!this.interacting()&&(Ra(this.pointerDelta,this.prevCoords,this.curCoords),"drag"===this.prepared.name)){g=Math.abs(g);h=Math.abs(h);d=this.target.options.drag.axis;var k=g>h?"x":gk.bottom&&(b=k.top,k.top=k.bottom,k.bottom=b),k.left>k.right&&(b=k.left,k.left=k.right,k.right=b))):(k.top=Math.min(h.top,g.bottom),k.bottom=Math.max(h.bottom,g.top),k.left=Math.min(h.left,g.right),k.right= +Math.max(h.right,g.left));k.width=k.right-k.left;k.height=k.bottom-k.top;for(var n in k)l[n]=k[n]-m[n];a.edges=this.prepared.edges;a.rect=k;a.deltaRect=l}this.target.fire(a);return a},gestureStart:function(a){a=new H(this,a,"gesture","start",this.element);a.ds=0;this.gesture.startDistance=this.gesture.prevDistance=a.distance;this.gesture.startAngle=this.gesture.prevAngle=a.angle;this.gesture.scale=1;this.gesturing=!0;this.target.fire(a);return a},gestureMove:function(a){if(!this.pointerIds.length)return this.prevEvent; +a=new H(this,a,"gesture","move",this.element);a.ds=a.scale-this.gesture.scale;this.target.fire(a);this.gesture.prevAngle=a.angle;this.gesture.prevDistance=a.distance;Infinity===a.scale||null===a.scale||void 0===a.scale||isNaN(a.scale)||(this.gesture.scale=a.scale);return a},pointerHold:function(a,b,c){this.collectEventTargets(a,b,c,"hold")},pointerUp:function(a,b,c,d){var e=this.mouse?0:A(this.pointerIds,P(a));clearTimeout(this.holdTimers[e]);this.collectEventTargets(a,b,c,"up");this.collectEventTargets(a, +b,c,"tap");this.pointerEnd(a,b,c,d);this.removePointer(a)},pointerCancel:function(a,b,c,d){var e=this.mouse?0:A(this.pointerIds,P(a));clearTimeout(this.holdTimers[e]);this.collectEventTargets(a,b,c,"cancel");this.pointerEnd(a,b,c,d);this.removePointer(a)},ie8Dblclick:function(a,b,c){this.prevTap&&b.clientX===this.prevTap.clientX&&b.clientY===this.prevTap.clientY&&c===this.prevTap.target&&(this.downTargets[0]=c,this.downTimes[0]=(new Date).getTime(),this.collectEventTargets(a,b,c,"tap"))},pointerEnd:function(a, +b,c,d){var e,f=this.target,g=f&&f.options,h=g&&this.prepared.name&&g[this.prepared.name].inertia;e=this.inertiaStatus;if(this.interacting()){if(e.active&&!e.ending)return;var k=(new Date).getTime(),l,p=!1,r=Ka(f,this.prepared.name)&&g[this.prepared.name].snap.endOnly,m=La(f,this.prepared.name)&&g[this.prepared.name].restrict.endOnly,n=0,q=0,g=this.dragging?"x"===g.drag.axis?Math.abs(this.pointerDelta.client.vx):"y"===g.drag.axis?Math.abs(this.pointerDelta.client.vy):this.pointerDelta.client.speed: +this.pointerDelta.client.speed,h=(l=h&&h.enabled&&"gesture"!==this.prepared.name&&b!==e.startEvent)&&50>k-this.curCoords.timeStamp&&g>h.minSpeed&&g>h.endSpeed;l&&!h&&(r||m)&&(l={},l.snap=l.restrict=l,r&&(this.setSnapping(this.curCoords.page,l),l.locked&&(n+=l.dx,q+=l.dy)),m&&(this.setRestriction(this.curCoords.page,l),l.restricted&&(n+=l.dx,q+=l.dy)),n||q)&&(p=!0);if(h||p){sa(e.upCoords,this.curCoords);this.pointers[0]=e.startEvent=new H(this,b,this.prepared.name,"inertiastart",this.element);e.t0= +k;f.fire(e.startEvent);h?(e.vx0=this.pointerDelta.client.vx,e.vy0=this.pointerDelta.client.vy,e.v0=g,this.calcInertia(e),b=C({},this.curCoords.page),f=na(f,this.element),b.x=b.x+e.xe-f.x,b.y=b.y+e.ye-f.y,f={useStatusXY:!0,x:b.x,y:b.y,dx:0,dy:0,snap:null},f.snap=f,n=q=0,r&&(b=this.setSnapping(this.curCoords.page,f),b.locked&&(n+=b.dx,q+=b.dy)),m&&(f=this.setRestriction(this.curCoords.page,f),f.restricted&&(n+=f.dx,q+=f.dy)),e.modifiedXe+=n,e.modifiedYe+=q,e.i=U(this.boundInertiaFrame)):(e.smoothEnd= +!0,e.xe=n,e.ye=q,e.sx=e.sy=0,e.i=U(this.boundSmoothEndFrame));e.active=!0;return}(r||m)&&this.pointerMove(a,b,c,d,!0)}this.dragging?(e=new H(this,b,"drag","end",this.element),m=this.getDrop(e,b,this.element),this.dropTarget=m.dropzone,this.dropElement=m.element,m=this.getDropEvents(b,e),m.leave&&this.prevDropTarget.fire(m.leave),m.enter&&this.dropTarget.fire(m.enter),m.drop&&this.dropTarget.fire(m.drop),m.deactivate&&this.fireActiveDrops(m.deactivate),f.fire(e)):this.resizing?(e=new H(this,b,"resize", +"end",this.element),f.fire(e)):this.gesturing&&(e=new H(this,b,"gesture","end",this.element),f.fire(e));this.stop(b)},collectDrops:function(a){var b=[],c=[],d;a=a||this.element;for(d=0;dk),h["double"]=l,this.tapTime=h.timeStamp);for(a=0;af.innerWidth-m.margin,a=a.clientY>f.innerHeight-m.margin):(f=Da(f),d=a.clientXf.right-m.margin,a=a.clientY>f.bottom-m.margin);m.x=c?1:d?-1:0;m.y=a?1:b?-1:0;m.isScrolling||(m.margin=e.margin,m.speed=e.speed,m.start(this))}},_updateEventTargets:function(a,b){this._eventTarget=a;this._curEventTarget=b}};H.prototype={preventDefault:I,stopImmediatePropagation:function(){this.immediatePropagationStopped=this.propagationStopped=!0},stopPropagation:function(){this.propagationStopped= +!0}};for(var q={},ib="dragStart dragMove resizeStart resizeMove gestureStart gestureMove pointerOver pointerOut pointerHover selectorDown pointerDown pointerMove pointerUp pointerCancel pointerEnd addPointer removePointer recordPointer autoScrollMove".split(" "),Pa=0,Qa=ib.length;Paf.left&&k.xf.top&&k.y=f.left&&g<=f.right&&l>=f.top&&l<=f.bottom;D(h)&&(g=Math.max(0,Math.min(f.right,k.right)-Math.max(f.left,k.left))*Math.max(0,Math.min(f.bottom,k.bottom)-Math.max(f.top,k.top))/(k.width*k.height)>=h);this.options.drop.checker&&(g=this.options.drop.checker(a,b,g,this,e,c,d));return g},dropChecker:function(a){return x(a)?(this.options.drop.checker=a,this): +null===a?(delete this.options.getRect,this):this.options.drop.checker},accept:function(a){return t(a)||fa(a)?(this.options.drop.accept=a,this):null===a?(delete this.options.drop.accept,this):this.options.drop.accept},resizable:function(a){return v(a)?(this.options.resize.enabled=!1===a.enabled?!1:!0,this.setPerAction("resize",a),this.setOnEvents("resize",a),/^x$|^y$|^xy$/.test(a.axis)?this.options.resize.axis=a.axis:null===a.axis&&(this.options.resize.axis=G.resize.axis),J(a.preserveAspectRatio)? +this.options.resize.preserveAspectRatio=a.preserveAspectRatio:J(a.square)&&(this.options.resize.square=a.square),this):J(a)?(this.options.resize.enabled=a,this):this.options.resize},squareResize:function(a){return J(a)?(this.options.resize.square=a,this):null===a?(delete this.options.resize.square,this):this.options.resize.square},gesturable:function(a){return v(a)?(this.options.gesture.enabled=!1===a.enabled?!1:!0,this.setPerAction("gesture",a),this.setOnEvents("gesture",a),this):J(a)?(this.options.gesture.enabled= +a,this):this.options.gesture},autoScroll:function(a){v(a)?a=C({actions:["drag","resize"]},a):J(a)&&(a={actions:["drag","resize"],enabled:a});return this.setOptions("autoScroll",a)},snap:function(a){a=this.setOptions("snap",a);return a===this?this:a.drag},setOptions:function(a,b){var c=b&&B(b.actions)?b.actions:["drag"],d;if(v(b)||J(b)){for(d=0;d