diff --git a/Sortable.js b/Sortable.js index fabc497..b7dcc5f 100644 --- a/Sortable.js +++ b/Sortable.js @@ -526,14 +526,15 @@ _css(ghostEl, 'display', 'none'); } - var target = document.elementFromPoint(touchEvt.clientX, touchEvt.clientY), - i = touchDragOverListeners.length; + var target = document.elementFromPoint(touchEvt.clientX, touchEvt.clientY); + var parent = target; + var i = touchDragOverListeners.length; if (target && target.shadowRoot) { target = target.shadowRoot.elementFromPoint(touchEvt.clientX, touchEvt.clientY); + parent = target; } - var parent = target; if (parent) { do { if (parent[expando]) { diff --git a/Sortable.min.js b/Sortable.min.js index 59064d3..4eced30 100644 --- a/Sortable.min.js +++ b/Sortable.min.js @@ -1,3 +1,3 @@ /*! Sortable 1.6.1 - MIT | git://github.com/rubaxa/Sortable.git */ -!function(t){"use strict";"function"==typeof define&&define.amd?define(t):"undefined"!=typeof module&&void 0!==module.exports?module.exports=t():window.Sortable=t()}(function(){"use strict";function t(t,e){if(!t||!t.nodeType||1!==t.nodeType)throw"Sortable: `el` must be HTMLElement, and not "+{}.toString.call(t);this.el=t,this.options=e=b({},e),t[z]=this;var n={group:Math.random(),sort:!0,disabled:!1,store:null,handle:null,scroll:!0,scrollSensitivity:30,scrollSpeed:10,draggable:/[uo]l/i.test(t.nodeName)?"li":">*",ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,setData:function(t,e){t.setData("Text",e.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0}};for(var o in n)!(o in e)&&(e[o]=n[o]);ct(e);for(var i in this)"_"===i.charAt(0)&&"function"==typeof this[i]&&(this[i]=this[i].bind(this));this.nativeDraggable=!e.forceFallback&&et,r(t,"mousedown",this._onTapStart),r(t,"touchstart",this._onTapStart),r(t,"pointerdown",this._onTapStart),this.nativeDraggable&&(r(t,"dragover",this),r(t,"dragenter",this)),lt.push(this._onDragOver),e.store&&this.sort(e.store.get(this))}function e(t,e){"clone"!==t.lastPullMode&&(e=!0),x&&x.state!==e&&(s(x,"display",e?"none":""),e||x.state&&(t.options.group.revertClone?(N.insertBefore(x,k),t._animate(C,x)):N.insertBefore(x,C)),x.state=e)}function n(t,e,n){if(t){n=n||Q;do{if(">*"===e&&t.parentNode===n||m(t,e))return t}while(t=o(t))}return null}function o(t){var e=t.host;return e&&e.nodeType?e:t.parentNode}function i(t){t.dataTransfer&&(t.dataTransfer.dropEffect="move"),t.preventDefault()}function r(t,e,n){t.addEventListener(e,n,tt)}function a(t,e,n){t.removeEventListener(e,n,tt)}function l(t,e,n){if(t)if(t.classList)t.classList[n?"add":"remove"](e);else{var o=(" "+t.className+" ").replace(V," ").replace(" "+e+" "," ");t.className=(o+(n?" "+e:"")).replace(V," ")}}function s(t,e,n){var o=t&&t.style;if(o){if(void 0===n)return Q.defaultView&&Q.defaultView.getComputedStyle?n=Q.defaultView.getComputedStyle(t,""):t.currentStyle&&(n=t.currentStyle),void 0===e?n:n[e];e in o||(e="-webkit-"+e),o[e]=n+("string"==typeof n?"":"px")}}function c(t,e,n){if(t){var o=t.getElementsByTagName(e),i=0,r=o.length;if(n)for(;i5||e.clientX-(n.left+n.width)>5}function g(t){for(var e=t.tagName+t.className+t.src+t.href+t.textContent,n=e.length,o=0;n--;)o+=e.charCodeAt(n);return o.toString(36)}function v(t,e){var n=0;if(!t||!t.parentNode)return-1;for(;t&&(t=t.previousElementSibling);)"TEMPLATE"===t.nodeName.toUpperCase()||">*"!==e&&!m(t,e)||n++;return n}function m(t,e){if(t){var n=(e=e.split(".")).shift().toUpperCase(),o=new RegExp("\\s("+e.join("|")+")(?=\\s)","g");return!(""!==n&&t.nodeName.toUpperCase()!=n||e.length&&((" "+t.className+" ").match(o)||[]).length!=e.length)}return!1}function _(t,e){var n,o;return function(){void 0===n&&(n=arguments,o=this,J(function(){1===n.length?t.call(o,n[0]):t.apply(o,n),n=void 0},e))}}function b(t,e){if(t&&e)for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}function D(t){return $&&$.dom?$.dom(t).cloneNode(!0):K?K(t).clone(!0)[0]:t.cloneNode(!0)}function y(t){for(var e=t.getElementsByTagName("input"),n=e.length;n--;){var o=e[n];o.checked&&at.push(o)}}function w(t){return J(t,0)}function T(t){return clearTimeout(t)}if("undefined"==typeof window||!window.document)return function(){throw new Error("Sortable.js requires a window with a document")};var C,S,E,x,N,k,B,Y,X,O,I,R,A,M,P,L,F,U,j,H,W={},V=/\s+/g,q=/left|right|inline/,z="Sortable"+(new Date).getTime(),G=window,Q=G.document,Z=G.parseInt,J=G.setTimeout,K=G.jQuery||G.Zepto,$=G.Polymer,tt=!1,et="draggable"in Q.createElement("div"),nt=function(t){return!navigator.userAgent.match(/(?:Trident.*rv[ :]?11\.|msie)/i)&&(t=Q.createElement("x"),t.style.cssText="pointer-events:auto","auto"===t.style.pointerEvents)}(),ot=!1,it=Math.abs,rt=Math.min,at=[],lt=[],st=_(function(t,e,n){if(n&&e.scroll){var o,i,r,a,l,s,c=n[z],d=e.scrollSensitivity,h=e.scrollSpeed,u=t.clientX,f=t.clientY,p=window.innerWidth,g=window.innerHeight;if(X!==n&&(Y=e.scroll,X=n,O=e.scrollFn,!0===Y)){Y=n;do{if(Y.offsetWidth-1:i==t)}}var n={},o=t.group;o&&"object"==typeof o||(o={name:o}),n.name=o.name,n.checkPull=e(o.pull,!0),n.checkPut=e(o.put),n.revertClone=o.revertClone,t.group=n};t.prototype={constructor:t,_onTapStart:function(t){var e,o=this,i=this.el,r=this.options,a=r.preventOnFilter,l=t.type,s=t.touches&&t.touches[0],c=(s||t).target,h=t.target.shadowRoot&&t.path&&t.path[0]||c,u=r.filter;if(y(i),!C&&!(/mousedown|pointerdown/.test(l)&&0!==t.button||r.disabled)&&!h.isContentEditable&&(c=n(c,r.draggable,i))&&B!==c){if(e=v(c,r.draggable),"function"==typeof u){if(u.call(this,t,c,this))return d(o,h,"filter",c,i,i,e),void(a&&t.preventDefault())}else if(u&&(u=u.split(",").some(function(t){if(t=n(h,t.trim(),i))return d(o,t,"filter",c,i,i,e),!0})))return void(a&&t.preventDefault());r.handle&&!n(h,r.handle,i)||this._prepareDragStart(t,s,c,e)}},_prepareDragStart:function(t,e,n,o){var i,a=this,s=a.el,h=a.options,f=s.ownerDocument;n&&!C&&n.parentNode===s&&(U=t,N=s,S=(C=n).parentNode,k=C.nextSibling,B=n,L=h.group,M=o,this._lastX=(e||t).clientX,this._lastY=(e||t).clientY,C.style["will-change"]="all",i=function(){a._disableDelayedDrag(),C.draggable=a.nativeDraggable,l(C,h.chosenClass,!0),a._triggerDragStart(t,e),d(a,N,"choose",C,N,N,M)},h.ignore.split(",").forEach(function(t){c(C,t.trim(),u)}),r(f,"mouseup",a._onDrop),r(f,"touchend",a._onDrop),r(f,"touchcancel",a._onDrop),r(f,"pointercancel",a._onDrop),r(f,"selectstart",a),h.delay?(r(f,"mouseup",a._disableDelayedDrag),r(f,"touchend",a._disableDelayedDrag),r(f,"touchcancel",a._disableDelayedDrag),r(f,"mousemove",a._disableDelayedDrag),r(f,"touchmove",a._disableDelayedDrag),r(f,"pointermove",a._disableDelayedDrag),a._dragStartTimer=J(i,h.delay)):i())},_disableDelayedDrag:function(){var t=this.el.ownerDocument;clearTimeout(this._dragStartTimer),a(t,"mouseup",this._disableDelayedDrag),a(t,"touchend",this._disableDelayedDrag),a(t,"touchcancel",this._disableDelayedDrag),a(t,"mousemove",this._disableDelayedDrag),a(t,"touchmove",this._disableDelayedDrag),a(t,"pointermove",this._disableDelayedDrag)},_triggerDragStart:function(t,e){(e=e||("touch"==t.pointerType?t:null))?(U={target:C,clientX:e.clientX,clientY:e.clientY},this._onDragStart(U,"touch")):this.nativeDraggable?(r(C,"dragend",this),r(N,"dragstart",this._onDragStart)):this._onDragStart(U,!0);try{Q.selection?w(function(){Q.selection.empty()}):window.getSelection().removeAllRanges()}catch(t){}},_dragStarted:function(){if(N&&C){var e=this.options;l(C,e.ghostClass,!0),l(C,e.dragClass,!1),t.active=this,d(this,N,"start",C,N,N,M)}else this._nulling()},_emulateDragOver:function(){if(j){if(this._lastX===j.clientX&&this._lastY===j.clientY)return;this._lastX=j.clientX,this._lastY=j.clientY,nt||s(E,"display","none");var t=Q.elementFromPoint(j.clientX,j.clientY),e=lt.length;t&&t.shadowRoot&&(t=t.shadowRoot.elementFromPoint(j.clientX,j.clientY));var n=t;if(n)do{if(n[z]){for(;e--;)lt[e]({clientX:j.clientX,clientY:j.clientY,target:t,rootEl:n});break}t=n}while(n=n.parentNode);nt||s(E,"display","")}},_onTouchMove:function(e){if(U){var n=this.options,o=n.fallbackTolerance,i=n.fallbackOffset,r=e.touches?e.touches[0]:e,a=r.clientX-U.clientX+i.x,l=r.clientY-U.clientY+i.y,c=e.touches?"translate3d("+a+"px,"+l+"px,0)":"translate("+a+"px,"+l+"px)";if(!t.active){if(o&&rt(it(r.clientX-this._lastX),it(r.clientY-this._lastY))C.offsetWidth,T=i.offsetHeight>C.offsetHeight,B=(y?(o.clientX-a.left)/b:(o.clientY-a.top)/D)>.5,Y=i.nextElementSibling,X=!1;if(y){var O=C.offsetTop,M=i.offsetTop;X=O===M?i.previousElementSibling===C&&!w||B&&w:i.previousElementSibling===C||C.previousElementSibling===i?(o.clientY-a.top)/D>.5:M>O}else m||(X=Y!==C&&!T||B&&T);var P=h(N,c,C,r,i,a,o,X);!1!==P&&(1!==P&&-1!==P||(X=1===P),ot=!0,J(f,30),e(g,v),C.contains(c)||(X&&!Y?c.appendChild(C):i.parentNode.insertBefore(C,X?Y:i)),S=C.parentNode,this._animate(r,C),this._animate(a,i))}}},_animate:function(t,e){var n=this.options.animation;if(n){var o=e.getBoundingClientRect();1===t.nodeType&&(t=t.getBoundingClientRect()),s(e,"transition","none"),s(e,"transform","translate3d("+(t.left-o.left)+"px,"+(t.top-o.top)+"px,0)"),e.offsetWidth,s(e,"transition","all "+n+"ms"),s(e,"transform","translate3d(0,0,0)"),clearTimeout(e.animated),e.animated=J(function(){s(e,"transition",""),s(e,"transform",""),e.animated=!1},n)}},_offUpEvents:function(){var t=this.el.ownerDocument;a(Q,"touchmove",this._onTouchMove),a(Q,"pointermove",this._onTouchMove),a(t,"mouseup",this._onDrop),a(t,"touchend",this._onDrop),a(t,"pointerup",this._onDrop),a(t,"touchcancel",this._onDrop),a(t,"pointercancel",this._onDrop),a(t,"selectstart",this)},_onDrop:function(e){var n=this.el,o=this.options;clearInterval(this._loopId),clearInterval(W.pid),clearTimeout(this._dragStartTimer),T(this._cloneId),T(this._dragStartId),a(Q,"mouseover",this),a(Q,"mousemove",this._onTouchMove),this.nativeDraggable&&(a(Q,"drop",this),a(n,"dragstart",this._onDragStart)),this._offUpEvents(),e&&(H&&(e.preventDefault(),!o.dropBubble&&e.stopPropagation()),E&&E.parentNode&&E.parentNode.removeChild(E),N!==S&&"clone"===t.active.lastPullMode||x&&x.parentNode&&x.parentNode.removeChild(x),C&&(this.nativeDraggable&&a(C,"dragend",this),u(C),C.style["will-change"]="",l(C,this.options.ghostClass,!1),l(C,this.options.chosenClass,!1),d(this,N,"unchoose",C,S,N,M),N!==S?(P=v(C,o.draggable))>=0&&(d(null,S,"add",C,S,N,M,P),d(this,N,"remove",C,S,N,M,P),d(null,S,"sort",C,S,N,M,P),d(this,N,"sort",C,S,N,M,P)):C.nextSibling!==k&&(P=v(C,o.draggable))>=0&&(d(this,N,"update",C,S,N,M,P),d(this,N,"sort",C,S,N,M,P)),t.active&&(null!=P&&-1!==P||(P=M),d(this,N,"end",C,S,N,M,P),this.save()))),this._nulling()},_nulling:function(){N=C=S=E=k=x=B=Y=X=U=j=H=P=I=R=F=L=t.active=null,at.forEach(function(t){t.checked=!0}),at.length=0},handleEvent:function(t){switch(t.type){case"drop":case"dragend":this._onDrop(t);break;case"dragover":case"dragenter":C&&(this._onDragOver(t),i(t));break;case"mouseover":this._onDrop(t);break;case"selectstart":t.preventDefault()}},toArray:function(){for(var t,e=[],o=this.el.children,i=0,r=o.length,a=this.options;i*",ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,setData:function(t,e){t.setData("Text",e.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0}};for(var o in n)!(o in e)&&(e[o]=n[o]);ct(e);for(var i in this)"_"===i.charAt(0)&&"function"==typeof this[i]&&(this[i]=this[i].bind(this));this.nativeDraggable=!e.forceFallback&&et,r(t,"mousedown",this._onTapStart),r(t,"touchstart",this._onTapStart),r(t,"pointerdown",this._onTapStart),this.nativeDraggable&&(r(t,"dragover",this),r(t,"dragenter",this)),lt.push(this._onDragOver),e.store&&this.sort(e.store.get(this))}function e(t,e){"clone"!==t.lastPullMode&&(e=!0),x&&x.state!==e&&(s(x,"display",e?"none":""),e||x.state&&(t.options.group.revertClone?(N.insertBefore(x,k),t._animate(C,x)):N.insertBefore(x,C)),x.state=e)}function n(t,e,n){if(t){n=n||Q;do{if(">*"===e&&t.parentNode===n||m(t,e))return t}while(t=o(t))}return null}function o(t){var e=t.host;return e&&e.nodeType?e:t.parentNode}function i(t){t.dataTransfer&&(t.dataTransfer.dropEffect="move"),t.preventDefault()}function r(t,e,n){t.addEventListener(e,n,tt)}function a(t,e,n){t.removeEventListener(e,n,tt)}function l(t,e,n){if(t)if(t.classList)t.classList[n?"add":"remove"](e);else{var o=(" "+t.className+" ").replace(V," ").replace(" "+e+" "," ");t.className=(o+(n?" "+e:"")).replace(V," ")}}function s(t,e,n){var o=t&&t.style;if(o){if(void 0===n)return Q.defaultView&&Q.defaultView.getComputedStyle?n=Q.defaultView.getComputedStyle(t,""):t.currentStyle&&(n=t.currentStyle),void 0===e?n:n[e];e in o||(e="-webkit-"+e),o[e]=n+("string"==typeof n?"":"px")}}function c(t,e,n){if(t){var o=t.getElementsByTagName(e),i=0,r=o.length;if(n)for(;i5||e.clientX-(n.left+n.width)>5}function g(t){for(var e=t.tagName+t.className+t.src+t.href+t.textContent,n=e.length,o=0;n--;)o+=e.charCodeAt(n);return o.toString(36)}function v(t,e){var n=0;if(!t||!t.parentNode)return-1;for(;t&&(t=t.previousElementSibling);)"TEMPLATE"===t.nodeName.toUpperCase()||">*"!==e&&!m(t,e)||n++;return n}function m(t,e){if(t){var n=(e=e.split(".")).shift().toUpperCase(),o=new RegExp("\\s("+e.join("|")+")(?=\\s)","g");return!(""!==n&&t.nodeName.toUpperCase()!=n||e.length&&((" "+t.className+" ").match(o)||[]).length!=e.length)}return!1}function _(t,e){var n,o;return function(){void 0===n&&(n=arguments,o=this,J(function(){1===n.length?t.call(o,n[0]):t.apply(o,n),n=void 0},e))}}function b(t,e){if(t&&e)for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}function D(t){return $&&$.dom?$.dom(t).cloneNode(!0):K?K(t).clone(!0)[0]:t.cloneNode(!0)}function y(t){for(var e=t.getElementsByTagName("input"),n=e.length;n--;){var o=e[n];o.checked&&at.push(o)}}function w(t){return J(t,0)}function T(t){return clearTimeout(t)}if("undefined"==typeof window||!window.document)return function(){throw new Error("Sortable.js requires a window with a document")};var C,S,E,x,N,k,B,Y,X,O,I,R,A,M,P,L,F,U,j,H,W={},V=/\s+/g,q=/left|right|inline/,z="Sortable"+(new Date).getTime(),G=window,Q=G.document,Z=G.parseInt,J=G.setTimeout,K=G.jQuery||G.Zepto,$=G.Polymer,tt=!1,et="draggable"in Q.createElement("div"),nt=function(t){return!navigator.userAgent.match(/(?:Trident.*rv[ :]?11\.|msie)/i)&&(t=Q.createElement("x"),t.style.cssText="pointer-events:auto","auto"===t.style.pointerEvents)}(),ot=!1,it=Math.abs,rt=Math.min,at=[],lt=[],st=_(function(t,e,n){if(n&&e.scroll){var o,i,r,a,l,s,c=n[z],d=e.scrollSensitivity,h=e.scrollSpeed,u=t.clientX,f=t.clientY,p=window.innerWidth,g=window.innerHeight;if(X!==n&&(Y=e.scroll,X=n,O=e.scrollFn,!0===Y)){Y=n;do{if(Y.offsetWidth-1:i==t)}}var n={},o=t.group;o&&"object"==typeof o||(o={name:o}),n.name=o.name,n.checkPull=e(o.pull,!0),n.checkPut=e(o.put),n.revertClone=o.revertClone,t.group=n};t.prototype={constructor:t,_onTapStart:function(t){var e,o=this,i=this.el,r=this.options,a=r.preventOnFilter,l=t.type,s=t.touches&&t.touches[0],c=(s||t).target,h=t.target.shadowRoot&&t.path&&t.path[0]||c,u=r.filter;if(y(i),!C&&!(/mousedown|pointerdown/.test(l)&&0!==t.button||r.disabled)&&!h.isContentEditable&&(c=n(c,r.draggable,i))&&B!==c){if(e=v(c,r.draggable),"function"==typeof u){if(u.call(this,t,c,this))return d(o,h,"filter",c,i,i,e),void(a&&t.preventDefault())}else if(u&&(u=u.split(",").some(function(t){if(t=n(h,t.trim(),i))return d(o,t,"filter",c,i,i,e),!0})))return void(a&&t.preventDefault());r.handle&&!n(h,r.handle,i)||this._prepareDragStart(t,s,c,e)}},_prepareDragStart:function(t,e,n,o){var i,a=this,s=a.el,h=a.options,f=s.ownerDocument;n&&!C&&n.parentNode===s&&(U=t,N=s,S=(C=n).parentNode,k=C.nextSibling,B=n,L=h.group,M=o,this._lastX=(e||t).clientX,this._lastY=(e||t).clientY,C.style["will-change"]="all",i=function(){a._disableDelayedDrag(),C.draggable=a.nativeDraggable,l(C,h.chosenClass,!0),a._triggerDragStart(t,e),d(a,N,"choose",C,N,N,M)},h.ignore.split(",").forEach(function(t){c(C,t.trim(),u)}),r(f,"mouseup",a._onDrop),r(f,"touchend",a._onDrop),r(f,"touchcancel",a._onDrop),r(f,"pointercancel",a._onDrop),r(f,"selectstart",a),h.delay?(r(f,"mouseup",a._disableDelayedDrag),r(f,"touchend",a._disableDelayedDrag),r(f,"touchcancel",a._disableDelayedDrag),r(f,"mousemove",a._disableDelayedDrag),r(f,"touchmove",a._disableDelayedDrag),r(f,"pointermove",a._disableDelayedDrag),a._dragStartTimer=J(i,h.delay)):i())},_disableDelayedDrag:function(){var t=this.el.ownerDocument;clearTimeout(this._dragStartTimer),a(t,"mouseup",this._disableDelayedDrag),a(t,"touchend",this._disableDelayedDrag),a(t,"touchcancel",this._disableDelayedDrag),a(t,"mousemove",this._disableDelayedDrag),a(t,"touchmove",this._disableDelayedDrag),a(t,"pointermove",this._disableDelayedDrag)},_triggerDragStart:function(t,e){(e=e||("touch"==t.pointerType?t:null))?(U={target:C,clientX:e.clientX,clientY:e.clientY},this._onDragStart(U,"touch")):this.nativeDraggable?(r(C,"dragend",this),r(N,"dragstart",this._onDragStart)):this._onDragStart(U,!0);try{Q.selection?w(function(){Q.selection.empty()}):window.getSelection().removeAllRanges()}catch(t){}},_dragStarted:function(){if(N&&C){var e=this.options;l(C,e.ghostClass,!0),l(C,e.dragClass,!1),t.active=this,d(this,N,"start",C,N,N,M)}else this._nulling()},_emulateDragOver:function(){if(j){if(this._lastX===j.clientX&&this._lastY===j.clientY)return;this._lastX=j.clientX,this._lastY=j.clientY,nt||s(E,"display","none");var t=Q.elementFromPoint(j.clientX,j.clientY),e=t,n=lt.length;if(t&&t.shadowRoot&&(e=t=t.shadowRoot.elementFromPoint(j.clientX,j.clientY)),e)do{if(e[z]){for(;n--;)lt[n]({clientX:j.clientX,clientY:j.clientY,target:t,rootEl:e});break}t=e}while(e=e.parentNode);nt||s(E,"display","")}},_onTouchMove:function(e){if(U){var n=this.options,o=n.fallbackTolerance,i=n.fallbackOffset,r=e.touches?e.touches[0]:e,a=r.clientX-U.clientX+i.x,l=r.clientY-U.clientY+i.y,c=e.touches?"translate3d("+a+"px,"+l+"px,0)":"translate("+a+"px,"+l+"px)";if(!t.active){if(o&&rt(it(r.clientX-this._lastX),it(r.clientY-this._lastY))C.offsetWidth,T=i.offsetHeight>C.offsetHeight,B=(y?(o.clientX-a.left)/b:(o.clientY-a.top)/D)>.5,Y=i.nextElementSibling,X=!1;if(y){var O=C.offsetTop,M=i.offsetTop;X=O===M?i.previousElementSibling===C&&!w||B&&w:i.previousElementSibling===C||C.previousElementSibling===i?(o.clientY-a.top)/D>.5:M>O}else m||(X=Y!==C&&!T||B&&T);var P=h(N,c,C,r,i,a,o,X);!1!==P&&(1!==P&&-1!==P||(X=1===P),ot=!0,J(f,30),e(g,v),C.contains(c)||(X&&!Y?c.appendChild(C):i.parentNode.insertBefore(C,X?Y:i)),S=C.parentNode,this._animate(r,C),this._animate(a,i))}}},_animate:function(t,e){var n=this.options.animation;if(n){var o=e.getBoundingClientRect();1===t.nodeType&&(t=t.getBoundingClientRect()),s(e,"transition","none"),s(e,"transform","translate3d("+(t.left-o.left)+"px,"+(t.top-o.top)+"px,0)"),e.offsetWidth,s(e,"transition","all "+n+"ms"),s(e,"transform","translate3d(0,0,0)"),clearTimeout(e.animated),e.animated=J(function(){s(e,"transition",""),s(e,"transform",""),e.animated=!1},n)}},_offUpEvents:function(){var t=this.el.ownerDocument;a(Q,"touchmove",this._onTouchMove),a(Q,"pointermove",this._onTouchMove),a(t,"mouseup",this._onDrop),a(t,"touchend",this._onDrop),a(t,"pointerup",this._onDrop),a(t,"touchcancel",this._onDrop),a(t,"pointercancel",this._onDrop),a(t,"selectstart",this)},_onDrop:function(e){var n=this.el,o=this.options;clearInterval(this._loopId),clearInterval(W.pid),clearTimeout(this._dragStartTimer),T(this._cloneId),T(this._dragStartId),a(Q,"mouseover",this),a(Q,"mousemove",this._onTouchMove),this.nativeDraggable&&(a(Q,"drop",this),a(n,"dragstart",this._onDragStart)),this._offUpEvents(),e&&(H&&(e.preventDefault(),!o.dropBubble&&e.stopPropagation()),E&&E.parentNode&&E.parentNode.removeChild(E),N!==S&&"clone"===t.active.lastPullMode||x&&x.parentNode&&x.parentNode.removeChild(x),C&&(this.nativeDraggable&&a(C,"dragend",this),u(C),C.style["will-change"]="",l(C,this.options.ghostClass,!1),l(C,this.options.chosenClass,!1),d(this,N,"unchoose",C,S,N,M),N!==S?(P=v(C,o.draggable))>=0&&(d(null,S,"add",C,S,N,M,P),d(this,N,"remove",C,S,N,M,P),d(null,S,"sort",C,S,N,M,P),d(this,N,"sort",C,S,N,M,P)):C.nextSibling!==k&&(P=v(C,o.draggable))>=0&&(d(this,N,"update",C,S,N,M,P),d(this,N,"sort",C,S,N,M,P)),t.active&&(null!=P&&-1!==P||(P=M),d(this,N,"end",C,S,N,M,P),this.save()))),this._nulling()},_nulling:function(){N=C=S=E=k=x=B=Y=X=U=j=H=P=I=R=F=L=t.active=null,at.forEach(function(t){t.checked=!0}),at.length=0},handleEvent:function(t){switch(t.type){case"drop":case"dragend":this._onDrop(t);break;case"dragover":case"dragenter":C&&(this._onDragOver(t),i(t));break;case"mouseover":this._onDrop(t);break;case"selectstart":t.preventDefault()}},toArray:function(){for(var t,e=[],o=this.el.children,i=0,r=o.length,a=this.options;i