sortable-dnd
Advanced tools
Comparing version 0.4.10 to 0.4.11
/*! | ||
* sortable-dnd v0.4.10 | ||
* sortable-dnd v0.4.11 | ||
* open source under the MIT license | ||
@@ -696,10 +696,2 @@ * https://github.com/mfuu/sortable-dnd#readme | ||
this.animations.length = 0; | ||
var offsetHeight = (dragEl || dropEl).offsetHeight; | ||
var max = Math.floor(container.scrollHeight / offsetHeight); | ||
var min = Math.min(children.length - 1, max); | ||
if (start < 0) { | ||
start = end; | ||
end = min; | ||
} | ||
if (end < 0) end = min; | ||
children.slice(start, end + 1).forEach(function (node) { | ||
@@ -750,2 +742,7 @@ if (node === except || node === Sortable.helper) return; | ||
} | ||
if (start < 0) { | ||
start = end; | ||
end = children.length - 1; | ||
} | ||
if (end < 0) end = children.length - 1; | ||
return { | ||
@@ -824,2 +821,3 @@ start: start, | ||
isMultiple, | ||
lastDropEl, | ||
autoScroller, | ||
@@ -1044,3 +1042,3 @@ dragStartTimer, | ||
// multi-drag | ||
if (isMultiple) this.multiplayer.onDrag(this); | ||
isMultiple && this.multiplayer.onDrag(this); | ||
@@ -1126,3 +1124,3 @@ // get the position of the dragEl | ||
// on-multi-drag | ||
if (isMultiple) this.multiplayer.onTrulyStarted(dragEl, this); | ||
isMultiple && this.multiplayer.onTrulyStarted(dragEl, this); | ||
@@ -1137,5 +1135,16 @@ // Init in the move event to prevent conflict with the click event | ||
css(dragEl, 'will-change', 'transform'); | ||
if (Safari) css(document.body, 'user-select', 'none'); | ||
Safari && css(document.body, 'user-select', 'none'); | ||
} | ||
}, | ||
_allowPut: function _allowPut() { | ||
if (downEvent.group === this.el) { | ||
return true; | ||
} else if (!this.options.group.put) { | ||
return false; | ||
} else { | ||
var name = this.options.group.name; | ||
var fromGroup = downEvent.sortable.options.group; | ||
return fromGroup.name && name && fromGroup.name === name; | ||
} | ||
}, | ||
_onMove: function _onMove( /** Event|TouchEvent */evt) { | ||
@@ -1174,4 +1183,8 @@ this._preventEvent(evt); | ||
dropEl = closest(target, this.options.draggable, rootEl, false); | ||
if (dropEl === dragEl || dropEl && dropEl.animated) return; | ||
if (dropEl && containes(dropEl, dragEl)) return; | ||
if (dropEl) { | ||
if (dropEl === lastDropEl) return; | ||
lastDropEl = dropEl; | ||
if (dropEl.animated || containes(dropEl, dragEl)) return; | ||
} | ||
if (dropEl === dragEl) return; | ||
if (rootEl !== from.sortable.el) { | ||
@@ -1187,13 +1200,2 @@ if (target === rootEl || !lastChild(rootEl, helper.node)) { | ||
}, | ||
_allowPut: function _allowPut() { | ||
if (downEvent.group === this.el) { | ||
return true; | ||
} else if (!this.options.group.put) { | ||
return false; | ||
} else { | ||
var name = this.options.group.name; | ||
var fromGroup = downEvent.sortable.options.group; | ||
return fromGroup.name && name && fromGroup.name === name; | ||
} | ||
}, | ||
_onInsert: function _onInsert( /** Event|TouchEvent */event, insert) { | ||
@@ -1204,3 +1206,3 @@ var target = insert ? dragEl : dropEl; | ||
this.animator.collect(null, target, parentEl, dragEl); | ||
if (isMultiple) this.multiplayer.onChange(dragEl, this); | ||
isMultiple && this.multiplayer.onChange(dragEl, this); | ||
to = { | ||
@@ -1232,3 +1234,3 @@ sortable: this, | ||
this.animator.collect(dragEl, dropEl, parentEl); | ||
if (isMultiple) this.multiplayer.onChange(dragEl, this); | ||
isMultiple && this.multiplayer.onChange(dragEl, this); | ||
to = { | ||
@@ -1247,7 +1249,9 @@ sortable: this, | ||
var offset = getOffset(dragEl); | ||
if (offset.top < to.offset.top || offset.left < to.offset.left) { | ||
parentEl.insertBefore(dragEl, dropEl.nextSibling); | ||
var nextEl = null; | ||
if (offset.top === to.offset.top) { | ||
nextEl = offset.left < to.offset.left ? dropEl.nextSibling : dropEl; | ||
} else { | ||
parentEl.insertBefore(dragEl, dropEl); | ||
nextEl = offset.top < to.offset.top ? dropEl.nextSibling : dropEl; | ||
} | ||
parentEl.insertBefore(dragEl, nextEl); | ||
this.animator.animate(); | ||
@@ -1267,3 +1271,3 @@ from.group = parentEl; | ||
toggleClass(dragEl, this.options.chosenClass, false); | ||
if (touchEvent) css(dragEl, 'touch-action', ''); | ||
touchEvent && css(dragEl, 'touch-action', ''); | ||
css(dragEl, 'will-change', ''); | ||
@@ -1301,9 +1305,14 @@ } | ||
} | ||
if (Safari) css(document.body, 'user-select', ''); | ||
Safari && css(document.body, 'user-select', ''); | ||
}, | ||
_preventEvent: function _preventEvent(evt) { | ||
evt.preventDefault !== void 0 && evt.cancelable && evt.preventDefault(); | ||
if (this.options.stopPropagation) evt.stopPropagation && evt.stopPropagation(); // prevent events from bubbling | ||
if (this.options.stopPropagation) { | ||
if (evt && evt.stopPropagation) { | ||
evt.stopPropagation(); | ||
} else { | ||
window.event.cancelBubble = true; | ||
} | ||
} | ||
}, | ||
_dispatchEvent: function _dispatchEvent(event, params) { | ||
@@ -1314,3 +1323,3 @@ var callback = this.options[event]; | ||
_clearState: function _clearState() { | ||
dragEl = dropEl = downEvent = moveEvent = touchEvent = isMultiple = dragStartTimer = Sortable.ghost = null; | ||
dragEl = dropEl = downEvent = moveEvent = touchEvent = isMultiple = lastDropEl = dragStartTimer = Sortable.ghost = null; | ||
distance = lastPosition = { | ||
@@ -1317,0 +1326,0 @@ x: 0, |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).Sortable=e()}(this,function(){"use strict";function Y(e,t){var o,n=Object.keys(e);return Object.getOwnPropertySymbols&&(o=Object.getOwnPropertySymbols(e),t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,o)),n}function c(n){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?Y(Object(i),!0).forEach(function(t){var e,o;e=n,o=i[t=t],(t=function(t){t=function(t,e){if("object"!=typeof t||null===t)return t;var o=t[Symbol.toPrimitive];if(void 0===o)return("string"===e?String:Number)(t);o=o.call(t,e||"default");if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):Y(Object(i)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(i,t))})}return n}function F(t){return(F="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var H={capture:!1,passive:!1},L=/\s+/g,e={start:["pointerdown","touchstart","mousedown"],move:["pointermove","touchmove","mousemove"],end:["pointerup","pointercancel","touchend","touchcancel","mouseup"]};function t(t){if("undefined"!=typeof window&&window.navigator)return!!navigator.userAgent.match(t)}var o,d=t(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),R=t(/Edge/i),a=t(/safari/i)&&!t(/chrome/i)&&!t(/android/i),k=(o=!1,document.addEventListener("checkIfSupportPassive",null,{get passive(){return o=!0}}),o),I="undefined"==typeof window||"undefined"==typeof document?"":(i=window.getComputedStyle(document.documentElement,"")||["-moz-hidden-iframe"],"ms"!==(i=(Array.prototype.slice.call(i).join("").match(/-(moz|webkit|ms)-/)||""===i.OLink&&["","o"])[1])?i&&i.length?i[0].toUpperCase()+i.substr(1):"":"ms");function W(t,e){t.style["".concat(I,"TransitionDuration")]=null==e?"":"".concat(e,"ms")}function u(t,e){t.style["".concat(I,"Transform")]=e?"".concat(e):""}function l(t,e,o){window.addEventListener?t.addEventListener(e,o,!(!k&&d)&&H):window.attachEvent&&t.attachEvent("on"+e,o)}function n(t,e,o){window.removeEventListener?t.removeEventListener(e,o,!(!k&&d)&&H):window.detachEvent&&t.detachEvent("on"+e,o)}function z(t){var e=t,o=t.touches&&t.touches[0]||t.changedTouches&&t.changedTouches[0]||t.pointerType&&"touch"===t.pointerType&&t,t=o?document.elementFromPoint(o.clientX,o.clientY):t.target;return o&&(e.clientX=o.clientX,e.clientY=o.clientY,e.pageX=o.pageX,e.pageY=o.pageY,e.screenX=o.screenX,e.screenY=o.screenY),{touch:o,event:e,target:t}}function h(t){for(var e={top:0,left:0,height:t.offsetHeight,width:t.offsetWidth},o=f();e.top+=t.offsetTop,e.left+=t.offsetLeft,t!==o&&(t=t.offsetParent););return e}function f(){var t=document.scrollingElement;return!t||t.contains(document.body)?document:t}function m(t){var e,o,n,i,r,s,a,l=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},c=2<arguments.length?arguments[2]:void 0;if(t.getBoundingClientRect||t===window){if(t!==window&&t.parentNode&&t!==f()){if(o=(e=t.getBoundingClientRect()).top,n=e.left,i=e.bottom,r=e.right,s=e.height,a=e.width,l.parent&&t.parentNode!==t.ownerDocument.body)for(var u,h=t.parentNode;h&&h.getBoundingClientRect&&h!==t.ownerDocument.body;){if((u=h.getBoundingClientRect()).height<s)return o=u.top,n=u.left,i=u.bottom,r=u.right,s=u.height,{top:o,left:n,bottom:i,right:r,width:a=u.width,height:s};h=h.parentNode}}else n=o=0,i=window.innerHeight,r=window.innerWidth,s=window.innerHeight,a=window.innerWidth;if((l.block||l.relative)&&t!==window&&(c=c||t.parentNode,!d))do{if(c&&c.getBoundingClientRect&&("none"!==v(c,"transform")||l.relative&&"static"!==v(c,"position"))){var p=c.getBoundingClientRect();o-=p.top+parseInt(v(c,"border-top-width")),n-=p.left+parseInt(v(c,"border-left-width")),i=o+e.height,r=n+e.width;break}}while(c=c.parentNode);return{top:o,left:n,bottom:i,right:r,width:a,height:s}}}function q(t,e,o,n){if(t){o=o||document;do{if(null==e){var i=Array.prototype.slice.call(o.children),r=i.indexOf(t);if(-1<r)return i[r];for(var s=0;s<i.length;s++)if(V(t,i[s]))return i[s]}else if(">"===e[0]?t.parentNode===o&&g(t,e):g(t,e)||n&&t===o)return t}while(t=t.parentNode)}return null}function V(t,e){if(e.compareDocumentPosition)return e===t||16&e.compareDocumentPosition(t);if(e.contains&&1===t.nodeType)return e.contains(t)&&e!==t;for(;t=t.parentNode;)if(t===e)return 1}function p(t,e,o){var n;t&&e&&(t.classList?t.classList[o?"add":"remove"](e):(n=(" "+t.className+" ").replace(L," ").replace(" "+e+" "," "),t.className=(n+(o?" "+e:"")).replace(L," ")))}function g(t,e){if(e&&(">"===e[0]&&(e=e.substring(1)),t))try{if(t.matches)return t.matches(e);if(t.msMatchesSelector)return t.msMatchesSelector(e);if(t.webkitMatchesSelector)return t.webkitMatchesSelector(e)}catch(t){return}}function U(t,e){return t.top!==e.top||t.left!==e.left}function v(t,e,o){var n=t&&t.style;if(n){if(void 0===o)return document.defaultView&&document.defaultView.getComputedStyle?o=document.defaultView.getComputedStyle(t,""):t.currentStyle&&(o=t.currentStyle),void 0===e?o:o[e];n[e=e in n||-1!==e.indexOf("webkit")?e:"-webkit-"+e]=o+("string"==typeof o?"":"px")}}var y="Sortable"+Date.now(),i={sortable:null,nodes:[]},s=c({},i),w=c({},i),b={};function Z(t){this.options=t||{},this.groupName=t.group.name}function G(){this.autoScrollAnimationFrame=null,this.speed={x:10,y:10}}function J(t){this.options=t,this.animations=[]}function K(){this.helper=null}Z.prototype={allowDrag:function(t){return this.options.multiple&&b[this.groupName]&&b[this.groupName].length&&-1<b[this.groupName].indexOf(t)},getHelper:function(){var o=document.createElement("div");return b[this.groupName].forEach(function(t,e){t=t.cloneNode(!0);t.style="\n opacity: ".concat(0===e?1:.5,";\n position: absolute;\n z-index: ").concat(e,";\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n "),o.appendChild(t)}),o},select:function(t,e,o){var n;e&&(b[this.groupName]||(b[this.groupName]=[]),n=b[this.groupName].indexOf(e),p(e,this.options.selectedClass,n<0),t=c(c({},o),{},{event:t}),n<0?(b[this.groupName].push(e),o.sortable._dispatchEvent("onSelect",t)):(b[this.groupName].splice(n,1),o.sortable._dispatchEvent("onDeselect",t)),b[this.groupName].sort(function(t,e){return t=h(t),e=h(e),t.top==e.top?t.left-e.left:t.top-e.top}))},onDrag:function(t){s.sortable=t,s.nodes=b[this.groupName].map(function(t){return{node:t,rect:m(t),offset:h(t)}}),w.sortable=t},onTrulyStarted:function(e,t){t.animator.collect(e,null,e.parentNode),b[this.groupName].forEach(function(t){t!=e&&t.parentNode.removeChild(t)}),t.animator.animate()},onChange:function(t,e){var o=m(t),n=h(t);w.sortable=e,w.nodes=b[this.groupName].map(function(t){return{node:t,rect:o,offset:n}})},onDrop:function(t,o,e,n){var i=this,r=(w.sortable.animator.collect(o,null,o.parentNode),b[this.groupName].indexOf(o)),e=(b[this.groupName].forEach(function(t,e){e<r?o.parentNode.insertBefore(t,o):(e=0<e?b[i.groupName][e-1]:o,o.parentNode.insertBefore(t,e.nextSibling))}),s.sortable=e.sortable,w.nodes=b[this.groupName].map(function(t){return{node:t,rect:m(t),offset:h(t)}}),this._offsetChanged(s.nodes,w.nodes)),n=c(c({},n()),{},{changed:e,event:t});w.sortable.el!=s.sortable.el&&s.sortable._dispatchEvent("onDrop",n),w.sortable._dispatchEvent("onDrop",n),w.sortable.animator.animate()},_offsetChanged:function(t,o){return!!t.find(function(e){return U(o.find(function(t){return t.node===e.node}).offset,e.offset)})}},window.requestAnimationFrame||(window.requestAnimationFrame=function(t){return setTimeout(t,17)}),window.cancelAnimationFrame||(window.cancelAnimationFrame=function(t){clearTimeout(t)}),G.prototype={clear:function(){null!=this.autoScrollAnimationFrame&&(cancelAnimationFrame(this.autoScrollAnimationFrame),this.autoScrollAnimationFrame=null)},update:function(t,e,o,n){var i=this;cancelAnimationFrame(this.autoScrollAnimationFrame),this.autoScrollAnimationFrame=requestAnimationFrame(function(){o&&n&&i.autoScroll(t,e,n),i.update(t,e,o,n)})},autoScroll:function(t,e,o){var n,i,r,s,a,l,c,u,h,p,d,f;t&&(n=o.clientX,o=o.clientY,void 0!==n)&&void 0!==o&&(h=m(t))&&(d=t.scrollTop,i=t.scrollLeft,r=t.scrollHeight,p=t.scrollWidth,s=h.top,a=h.right,l=h.bottom,c=h.left,f=h.height,h=h.width,o<s||a<n||l<o||n<c||(u=0<d&&s<=o&&o<=s+e,h=i+h<p&&n<=a&&a-e<=n,p=d+f<r&&o<=l&&l-e<=o,d=(f=d=0)<i&&c<=n&&n<=c+e?Math.floor(Math.max(-1,(n-c)/e-1)*this.speed.x):h?Math.ceil(Math.min(1,(n-a)/e+1)*this.speed.x):0,(f=u?Math.floor(Math.max(-1,(o-s)/e-1)*this.speed.y):p?Math.ceil(Math.min(1,(o-l)/e+1)*this.speed.y):0)&&(t.scrollTop+=f),d&&(t.scrollLeft+=d)))}},J.prototype={collect:function(t,e,o,n){var i,r,s,a=this;o&&(i=Array.prototype.slice.call(o.children),r=(s=this._getRange(i,t,e,n)).start,s=s.end,this.animations.length=0,t=(t||e).offsetHeight,e=Math.floor(o.scrollHeight/t),o=Math.min(i.length-1,e),r<0&&(r=s,s=o),i.slice(r,(s=s<0?o:s)+1).forEach(function(t){t!==n&&t!==X.helper&&a.animations.push({node:t,rect:m(t)})}))},animate:function(){var o=this;this.animations.forEach(function(t){var e=t.node,t=t.rect;o._excute(e,t)})},_excute:function(t,e){var o=e.left,e=e.top,n=m(t),e=e-n.top,o=o-n.left,n=(W(t),u(t,"translate3d(".concat(o,"px, ").concat(e,"px, 0)")),t.offsetWidth,this.options.animation);W(t,n),u(t,"translate3d(0px, 0px, 0px)"),clearTimeout(t.animated),t.animated=setTimeout(function(){W(t),u(t,""),t.animated=null},n)},_getRange:function(t,e,o){e=t.indexOf(e),t=t.indexOf(o);return t<e&&(e=(o=[t,e])[0],t=o[1]),{start:e,end:t}}},K.prototype={get node(){return this.helper},destroy:function(){this.helper&&this.helper.parentNode&&this.helper.parentNode.removeChild(this.helper),this.helper=null},move:function(t,e){u(this.helper,"translate3d(".concat(t,"px, ").concat(e,"px, 0)"))},init:function(t,e,o,n,i){if(!this.helper){var r,s=n.fallbackOnBody,a=n.ghostClass,n=n.ghostStyle,n=void 0===n?{}:n,s=s?document.body:o,l=(this.helper=e.cloneNode(!0),p(this.helper,a,!0),c({"box-sizing":"border-box",top:t.top,left:t.left,width:t.width,height:t.height,position:"fixed",opacity:"0.8","z-index":1e5,"pointer-events":"none"},n));for(r in l)v(this.helper,r,l[r]);o=this.helper,e="none",o.style["".concat(I,"Transition")]=e?"none"===e?"none":"".concat(e):"",u(this.helper,"translate3d(0px, 0px, 0px)"),s.appendChild(this.helper);a=i.x/parseInt(this.helper.style.width)*100,t=i.y/parseInt(this.helper.style.height)*100;v(this.helper,"transform-origin","".concat(a,"% ").concat(t,"%")),v(this.helper,"transform","translateZ(0)")}}};function Q(t){var e;D&&(e=t.touches?t.touches[0]:t,e=$(e.clientX,e.clientY))&&(_=e)!==E.sortable.el&&e[y]._onMove(t)}function $(i,r){var s;return M.some(function(t){var e,o,n=t[y].options.emptyInsertThreshold;if(n)return o=m(t,{parent:!0}),e=i>=o.left-n&&i<=o.right+n,o=r>=o.top-n&&r<=o.bottom+n,e&&o?s=t:void 0}),s}function r(){var t,e={from:c({},A),to:c({},j)};return T&&(t={from:c({},s),to:c({},w)},e.from=c(c({},t.from),e.from),e.to=c(c({},t.to),e.to)),e}var _,D,S,E,N,x,T,C,O,tt={sortable:null,group:null,node:null,rect:{},offset:{}},M=[],P=new K,A=c({},tt),j=c({},tt),et={x:0,y:0},B={x:0,y:0},ot=function(t,e){var o={},n=t.group;n&&"object"==F(n)||(n={name:n,pull:!0,put:!0}),o.name=n.name||e,o.pull=n.pull,o.put=n.put,t.group=o};function X(t,e){if(!t||!t.nodeType||1!==t.nodeType)throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(t));(t[y]=this).el=t,this.ownerDocument=t.ownerDocument,this.options=e=Object.assign({},e);var o,n,i={group:"",animation:150,multiple:!1,draggable:null,handle:null,onDrag:null,onMove:null,onDrop:null,onChange:null,autoScroll:!0,scrollThreshold:25,delay:0,delayOnTouchOnly:!1,disabled:!1,ghostClass:"",ghostStyle:{},chosenClass:"",selectedClass:"",fallbackOnBody:!1,stopPropagation:!1,supportPointer:"onpointerdown"in window&&!a,supportTouch:"ontouchstart"in window,emptyInsertThreshold:5};for(o in i)o in this.options||(this.options[o]=i[o]);for(n in ot(e,"group_"+Number(Math.random().toString().slice(-3)+Date.now()).toString(32)),this)"_"===n.charAt(0)&&"function"==typeof this[n]&&(this[n]=this[n].bind(this));var e=this.options,r=e.supportPointer,e=e.supportTouch;l(t,r?"pointerdown":e?"touchstart":"mousedown",this._onDrag),M.push(t),this.multiplayer=new Z(this.options),this.animator=new J(this.options),C=new G}return(X.prototype={constructor:X,get helper(){return P.node},destroy:function(){this._dispatchEvent("destroy",this),this.el[y]=null;for(var t=0;t<e.start.length;t++)n(this.el,e.start[t],this._onDrag);this._clearState(),M.splice(M.indexOf(this.el),1),0==M.length&&(C=null),this.el=null},_onDrag:function(t){var e=this;if(!this.options.disabled&&this.options.group.pull&&(!/mousedown|pointerdown/.test(t.type)||0===t.button)){var o=z(t),n=o.touch,i=o.event,o=o.target;if(!(a&&o&&"SELECT"===o.tagName.toUpperCase()||o===this.el)){var r=this.options,s=r.draggable,r=r.handle;if(("function"!=typeof r||r(t))&&("string"!=typeof r||g(o,r))){if("function"==typeof s){r=s(t);if(!r)return;!function(e){if(e){var t=document.createElement("div");try{return t.appendChild(e.cloneNode(!0)),1==e.nodeType}catch(t){return e==window||e==document}}}(r)||(D=r)}else D=q(o,s,this.el,!1);D&&!D.animated&&(n&&v(D,"touch-action","none"),t=D.parentNode,x=n,(E=i).sortable=this,E.group=t,(T=this.options.multiple&&this.multiplayer.allowDrag(D))&&this.multiplayer.onDrag(this),r=m(D),o=h(D),A={sortable:this,group:t,node:D,rect:r,offset:o},j.group=t,j.sortable=this,et={x:i.clientX-r.left,y:i.clientY-r.top},this.options.supportPointer?l(this.ownerDocument,"pointermove",Q):l(this.ownerDocument,n?"touchmove":"mousemove",Q),o=(s=this.options).delay,t=s.delayOnTouchOnly,!o||t&&!n||R||d?this._onStart():(this.options.supportPointer?l(this.ownerDocument,"pointerup",this._onDrop):l(this.ownerDocument,x?"touchend":"mouseup",this._onDrop),clearTimeout(O),O=setTimeout(function(){return e._onStart()},o)))}}}},_onStart:function(){_=this.el,this.options.supportPointer?(l(this.ownerDocument,"pointermove",this._onMove),l(this.ownerDocument,"pointerup",this._onDrop),l(this.ownerDocument,"pointercancel",this._onDrop)):x?(l(this.ownerDocument,"touchmove",this._onMove),l(this.ownerDocument,"touchend",this._onDrop),l(this.ownerDocument,"touchcancel",this._onDrop)):(l(this.ownerDocument,"mousemove",this._onMove),l(this.ownerDocument,"mouseup",this._onDrop));try{document.selection?setTimeout(function(){document.selection.empty()},0):window.getSelection().removeAllRanges()}catch(t){}},_onTrulyStarted:function(){var t;N||(this._dispatchEvent("onDrag",c(c({},r()),{},{event:E})),T&&this.multiplayer.onTrulyStarted(D,this),t=T?this.multiplayer.getHelper():D,P.init(A.rect,t,this.el,this.options,et),X.helper=P.node,p(D,this.options.chosenClass,!0),v(D,"will-change","transform"),a&&v(document.body,"user-select","none"))},_onMove:function(t){var e,o,n,i;this._preventEvent(t),E&&D&&(i=(e=t).clientX,e=e.clientY,o=i-B.x,n=e-B.y,B.x=i,B.y=e,void 0!==i&&void 0!==e&&Math.abs(o)<=0&&Math.abs(n)<=0||(e=(i=z(t)).event,o=i.target,this._onTrulyStarted(),N=e,n=t.clientX-E.clientX,i=t.clientY-E.clientY,P.move(n,i),this._dispatchEvent("onMove",c(c({},r()),{},{event:e})),this.scrollEl||(this.scrollEl=function(t,e){if(t&&t.getBoundingClientRect){var o=t,n=!1;do{if(o.clientWidth<o.scrollWidth||o.clientHeight<o.scrollHeight){var i=v(o);if(o.clientWidth<o.scrollWidth&&("auto"==i.overflowX||"scroll"==i.overflowX)||o.clientHeight<o.scrollHeight&&("auto"==i.overflowY||"scroll"==i.overflowY)){if(!o.getBoundingClientRect||o===document.body)return f();if(n||e)return o;n=!0}}}while(o=o.parentNode)}return f()}(this.el,!0)),n=(t=this.options).autoScroll,i=t.scrollThreshold,n&&C.update(this.scrollEl,i,E,N),!this._allowPut())||(S=q(o,this.options.draggable,_,!1))===D||S&&S.animated||S&&V(S,D)||(_!==A.sortable.el?o!==_&&function(t,e,o){for(var n=t.lastElementChild;n&&(n===e||"none"===v(n,"display")||o&&!g(n,o));)n=n.previousElementSibling;return n}(_,P.node)?S&&this._onInsert(e,!1):this._onInsert(e,!0):S&&this._onChange(e)))},_allowPut:function(){var t,e;return E.group===this.el||!!this.options.group.put&&(t=this.options.group.name,(e=E.sortable.options.group).name)&&t&&e.name===t},_onInsert:function(t,e){var o=e?D:S,n=e?_:S.parentNode;A.sortable.animator.collect(D,null,D.parentNode,D),this.animator.collect(null,o,n,D),T&&this.multiplayer.onChange(D,this),j={sortable:this,group:n,node:o,rect:m(D),offset:h(D)},A.sortable._dispatchEvent("onRemove",c(c({},r()),{},{event:t})),e?n.appendChild(D):n.insertBefore(D,o),this._dispatchEvent("onAdd",c(c({},r()),{},{event:t})),A.sortable.animator.animate(),this.animator.animate(),A.group=n,A.sortable=this},_onChange:function(t){var e=S.parentNode,t=(this.animator.collect(D,S,e),T&&this.multiplayer.onChange(D,this),j={sortable:this,group:e,node:S,rect:m(S),offset:h(S)},this._dispatchEvent("onChange",c(c({},r()),{},{event:t})),h(D));t.top<j.offset.top||t.left<j.offset.left?e.insertBefore(D,S.nextSibling):e.insertBefore(D,S),this.animator.animate(),A.group=e,A.sortable=this},_onDrop:function(t){this._unbindMoveEvents(),this._unbindDropEvents(),this._preventEvent(t),C.clear(),clearTimeout(O),D&&(p(D,this.options.chosenClass,!1),x&&v(D,"touch-action",""),v(D,"will-change","")),D&&E&&N?this._onEnd(t):this.options.multiple&&this.multiplayer.select(t,D,c({},A)),this._clearState()},_onEnd:function(t){var e;A.group=E.group,A.sortable=E.sortable,T?this.multiplayer.onDrop(t,D,E,r):(j.rect=m(D),j.offset=h(D),e=U(A.offset,j.offset),e=c(c({},r()),{},{changed:e,event:t}),j.sortable.el!==A.sortable.el&&A.sortable._dispatchEvent("onDrop",e),j.sortable._dispatchEvent("onDrop",e)),a&&v(document.body,"user-select","")},_preventEvent:function(t){void 0!==t.preventDefault&&t.cancelable&&t.preventDefault(),this.options.stopPropagation&&t.stopPropagation&&t.stopPropagation()},_dispatchEvent:function(t,e){t=this.options[t];"function"==typeof t&&t(e)},_clearState:function(){D=S=E=N=x=T=O=X.ghost=null,et=B={x:0,y:0},A=j=c({},tt),P.destroy()},_unbindMoveEvents:function(){for(var t=0;t<e.move.length;t++)n(this.ownerDocument,e.move[t],this._onMove),n(this.ownerDocument,e.move[t],Q)},_unbindDropEvents:function(){for(var t=0;t<e.end.length;t++)n(this.ownerDocument,e.end[t],this._onDrop)}}).utils={getRect:m,getOffset:h},X}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).Sortable=e()}(this,function(){"use strict";function Y(e,t){var o,n=Object.keys(e);return Object.getOwnPropertySymbols&&(o=Object.getOwnPropertySymbols(e),t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,o)),n}function c(n){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?Y(Object(i),!0).forEach(function(t){var e,o;e=n,o=i[t=t],(t=function(t){t=function(t,e){if("object"!=typeof t||null===t)return t;var o=t[Symbol.toPrimitive];if(void 0===o)return("string"===e?String:Number)(t);o=o.call(t,e||"default");if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):Y(Object(i)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(i,t))})}return n}function F(t){return(F="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var L={capture:!1,passive:!1},R=/\s+/g,e={start:["pointerdown","touchstart","mousedown"],move:["pointermove","touchmove","mousemove"],end:["pointerup","pointercancel","touchend","touchcancel","mouseup"]};function t(t){if("undefined"!=typeof window&&window.navigator)return!!navigator.userAgent.match(t)}var o,d=t(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),k=t(/Edge/i),a=t(/safari/i)&&!t(/chrome/i)&&!t(/android/i),H=(o=!1,document.addEventListener("checkIfSupportPassive",null,{get passive(){return o=!0}}),o),I="undefined"==typeof window||"undefined"==typeof document?"":(i=window.getComputedStyle(document.documentElement,"")||["-moz-hidden-iframe"],"ms"!==(i=(Array.prototype.slice.call(i).join("").match(/-(moz|webkit|ms)-/)||""===i.OLink&&["","o"])[1])?i&&i.length?i[0].toUpperCase()+i.substr(1):"":"ms");function W(t,e){t.style["".concat(I,"TransitionDuration")]=null==e?"":"".concat(e,"ms")}function u(t,e){t.style["".concat(I,"Transform")]=e?"".concat(e):""}function l(t,e,o){window.addEventListener?t.addEventListener(e,o,!(!H&&d)&&L):window.attachEvent&&t.attachEvent("on"+e,o)}function n(t,e,o){window.removeEventListener?t.removeEventListener(e,o,!(!H&&d)&&L):window.detachEvent&&t.detachEvent("on"+e,o)}function z(t){var e=t,o=t.touches&&t.touches[0]||t.changedTouches&&t.changedTouches[0]||t.pointerType&&"touch"===t.pointerType&&t,t=o?document.elementFromPoint(o.clientX,o.clientY):t.target;return o&&(e.clientX=o.clientX,e.clientY=o.clientY,e.pageX=o.pageX,e.pageY=o.pageY,e.screenX=o.screenX,e.screenY=o.screenY),{touch:o,event:e,target:t}}function h(t){for(var e={top:0,left:0,height:t.offsetHeight,width:t.offsetWidth},o=f();e.top+=t.offsetTop,e.left+=t.offsetLeft,t!==o&&(t=t.offsetParent););return e}function f(){var t=document.scrollingElement;return!t||t.contains(document.body)?document:t}function m(t){var e,o,n,i,r,s,a,l=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},c=2<arguments.length?arguments[2]:void 0;if(t.getBoundingClientRect||t===window){if(t!==window&&t.parentNode&&t!==f()){if(o=(e=t.getBoundingClientRect()).top,n=e.left,i=e.bottom,r=e.right,s=e.height,a=e.width,l.parent&&t.parentNode!==t.ownerDocument.body)for(var u,h=t.parentNode;h&&h.getBoundingClientRect&&h!==t.ownerDocument.body;){if((u=h.getBoundingClientRect()).height<s)return o=u.top,n=u.left,i=u.bottom,r=u.right,s=u.height,{top:o,left:n,bottom:i,right:r,width:a=u.width,height:s};h=h.parentNode}}else n=o=0,i=window.innerHeight,r=window.innerWidth,s=window.innerHeight,a=window.innerWidth;if((l.block||l.relative)&&t!==window&&(c=c||t.parentNode,!d))do{if(c&&c.getBoundingClientRect&&("none"!==v(c,"transform")||l.relative&&"static"!==v(c,"position"))){var p=c.getBoundingClientRect();o-=p.top+parseInt(v(c,"border-top-width")),n-=p.left+parseInt(v(c,"border-left-width")),i=o+e.height,r=n+e.width;break}}while(c=c.parentNode);return{top:o,left:n,bottom:i,right:r,width:a,height:s}}}function q(t,e,o,n){if(t){o=o||document;do{if(null==e){var i=Array.prototype.slice.call(o.children),r=i.indexOf(t);if(-1<r)return i[r];for(var s=0;s<i.length;s++)if(V(t,i[s]))return i[s]}else if(">"===e[0]?t.parentNode===o&&g(t,e):g(t,e)||n&&t===o)return t}while(t=t.parentNode)}return null}function V(t,e){if(e.compareDocumentPosition)return e===t||16&e.compareDocumentPosition(t);if(e.contains&&1===t.nodeType)return e.contains(t)&&e!==t;for(;t=t.parentNode;)if(t===e)return 1}function p(t,e,o){var n;t&&e&&(t.classList?t.classList[o?"add":"remove"](e):(n=(" "+t.className+" ").replace(R," ").replace(" "+e+" "," "),t.className=(n+(o?" "+e:"")).replace(R," ")))}function g(t,e){if(e&&(">"===e[0]&&(e=e.substring(1)),t))try{if(t.matches)return t.matches(e);if(t.msMatchesSelector)return t.msMatchesSelector(e);if(t.webkitMatchesSelector)return t.webkitMatchesSelector(e)}catch(t){return}}function U(t,e){return t.top!==e.top||t.left!==e.left}function v(t,e,o){var n=t&&t.style;if(n){if(void 0===o)return document.defaultView&&document.defaultView.getComputedStyle?o=document.defaultView.getComputedStyle(t,""):t.currentStyle&&(o=t.currentStyle),void 0===e?o:o[e];n[e=e in n||-1!==e.indexOf("webkit")?e:"-webkit-"+e]=o+("string"==typeof o?"":"px")}}var y="Sortable"+Date.now(),i={sortable:null,nodes:[]},s=c({},i),w=c({},i),b={};function Z(t){this.options=t||{},this.groupName=t.group.name}function G(){this.autoScrollAnimationFrame=null,this.speed={x:10,y:10}}function J(t){this.options=t,this.animations=[]}function K(){this.helper=null}Z.prototype={allowDrag:function(t){return this.options.multiple&&b[this.groupName]&&b[this.groupName].length&&-1<b[this.groupName].indexOf(t)},getHelper:function(){var o=document.createElement("div");return b[this.groupName].forEach(function(t,e){t=t.cloneNode(!0);t.style="\n opacity: ".concat(0===e?1:.5,";\n position: absolute;\n z-index: ").concat(e,";\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n "),o.appendChild(t)}),o},select:function(t,e,o){var n;e&&(b[this.groupName]||(b[this.groupName]=[]),n=b[this.groupName].indexOf(e),p(e,this.options.selectedClass,n<0),t=c(c({},o),{},{event:t}),n<0?(b[this.groupName].push(e),o.sortable._dispatchEvent("onSelect",t)):(b[this.groupName].splice(n,1),o.sortable._dispatchEvent("onDeselect",t)),b[this.groupName].sort(function(t,e){return t=h(t),e=h(e),t.top==e.top?t.left-e.left:t.top-e.top}))},onDrag:function(t){s.sortable=t,s.nodes=b[this.groupName].map(function(t){return{node:t,rect:m(t),offset:h(t)}}),w.sortable=t},onTrulyStarted:function(e,t){t.animator.collect(e,null,e.parentNode),b[this.groupName].forEach(function(t){t!=e&&t.parentNode.removeChild(t)}),t.animator.animate()},onChange:function(t,e){var o=m(t),n=h(t);w.sortable=e,w.nodes=b[this.groupName].map(function(t){return{node:t,rect:o,offset:n}})},onDrop:function(t,o,e,n){var i=this,r=(w.sortable.animator.collect(o,null,o.parentNode),b[this.groupName].indexOf(o)),e=(b[this.groupName].forEach(function(t,e){e<r?o.parentNode.insertBefore(t,o):(e=0<e?b[i.groupName][e-1]:o,o.parentNode.insertBefore(t,e.nextSibling))}),s.sortable=e.sortable,w.nodes=b[this.groupName].map(function(t){return{node:t,rect:m(t),offset:h(t)}}),this._offsetChanged(s.nodes,w.nodes)),n=c(c({},n()),{},{changed:e,event:t});w.sortable.el!=s.sortable.el&&s.sortable._dispatchEvent("onDrop",n),w.sortable._dispatchEvent("onDrop",n),w.sortable.animator.animate()},_offsetChanged:function(t,o){return!!t.find(function(e){return U(o.find(function(t){return t.node===e.node}).offset,e.offset)})}},window.requestAnimationFrame||(window.requestAnimationFrame=function(t){return setTimeout(t,17)}),window.cancelAnimationFrame||(window.cancelAnimationFrame=function(t){clearTimeout(t)}),G.prototype={clear:function(){null!=this.autoScrollAnimationFrame&&(cancelAnimationFrame(this.autoScrollAnimationFrame),this.autoScrollAnimationFrame=null)},update:function(t,e,o,n){var i=this;cancelAnimationFrame(this.autoScrollAnimationFrame),this.autoScrollAnimationFrame=requestAnimationFrame(function(){o&&n&&i.autoScroll(t,e,n),i.update(t,e,o,n)})},autoScroll:function(t,e,o){var n,i,r,s,a,l,c,u,h,p,d,f;t&&(n=o.clientX,o=o.clientY,void 0!==n)&&void 0!==o&&(h=m(t))&&(d=t.scrollTop,i=t.scrollLeft,r=t.scrollHeight,p=t.scrollWidth,s=h.top,a=h.right,l=h.bottom,c=h.left,f=h.height,h=h.width,o<s||a<n||l<o||n<c||(u=0<d&&s<=o&&o<=s+e,h=i+h<p&&n<=a&&a-e<=n,p=d+f<r&&o<=l&&l-e<=o,d=(f=d=0)<i&&c<=n&&n<=c+e?Math.floor(Math.max(-1,(n-c)/e-1)*this.speed.x):h?Math.ceil(Math.min(1,(n-a)/e+1)*this.speed.x):0,(f=u?Math.floor(Math.max(-1,(o-s)/e-1)*this.speed.y):p?Math.ceil(Math.min(1,(o-l)/e+1)*this.speed.y):0)&&(t.scrollTop+=f),d&&(t.scrollLeft+=d)))}},J.prototype={collect:function(t,e,o,n){var i=this;o&&(o=Array.prototype.slice.call(o.children),e=(t=this._getRange(o,t,e,n)).start,t=t.end,this.animations.length=0,o.slice(e,t+1).forEach(function(t){t!==n&&t!==r.helper&&i.animations.push({node:t,rect:m(t)})}))},animate:function(){var o=this;this.animations.forEach(function(t){var e=t.node,t=t.rect;o._excute(e,t)})},_excute:function(t,e){var o=e.left,e=e.top,n=m(t),e=e-n.top,o=o-n.left,n=(W(t),u(t,"translate3d(".concat(o,"px, ").concat(e,"px, 0)")),t.offsetWidth,this.options.animation);W(t,n),u(t,"translate3d(0px, 0px, 0px)"),clearTimeout(t.animated),t.animated=setTimeout(function(){W(t),u(t,""),t.animated=null},n)},_getRange:function(t,e,o){var n,e=t.indexOf(e),o=t.indexOf(o);return o<e&&(e=(n=[o,e])[0],o=n[1]),e<0&&(e=o,o=t.length-1),{start:e,end:o=o<0?t.length-1:o}}},K.prototype={get node(){return this.helper},destroy:function(){this.helper&&this.helper.parentNode&&this.helper.parentNode.removeChild(this.helper),this.helper=null},move:function(t,e){u(this.helper,"translate3d(".concat(t,"px, ").concat(e,"px, 0)"))},init:function(t,e,o,n,i){if(!this.helper){var r,s=n.fallbackOnBody,a=n.ghostClass,n=n.ghostStyle,n=void 0===n?{}:n,s=s?document.body:o,l=(this.helper=e.cloneNode(!0),p(this.helper,a,!0),c({"box-sizing":"border-box",top:t.top,left:t.left,width:t.width,height:t.height,position:"fixed",opacity:"0.8","z-index":1e5,"pointer-events":"none"},n));for(r in l)v(this.helper,r,l[r]);o=this.helper,e="none",o.style["".concat(I,"Transition")]=e?"none"===e?"none":"".concat(e):"",u(this.helper,"translate3d(0px, 0px, 0px)"),s.appendChild(this.helper);a=i.x/parseInt(this.helper.style.width)*100,t=i.y/parseInt(this.helper.style.height)*100;v(this.helper,"transform-origin","".concat(a,"% ").concat(t,"%")),v(this.helper,"transform","translateZ(0)")}}};function Q(t){var e;S&&(e=t.touches?t.touches[0]:t,e=$(e.clientX,e.clientY))&&(D=e)!==N.sortable.el&&e[y]._onMove(t)}function $(i,r){var s;return M.some(function(t){var e,o,n=t[y].options.emptyInsertThreshold;if(n)return o=m(t,{parent:!0}),e=i>=o.left-n&&i<=o.right+n,o=r>=o.top-n&&r<=o.bottom+n,e&&o?s=t:void 0}),s}function _(){var t,e={from:c({},j),to:c({},B)};return C&&(t={from:c({},s),to:c({},w)},e.from=c(c({},t.from),e.from),e.to=c(c({},t.to),e.to)),e}var D,S,E,N,x,T,C,tt,O,P,et={sortable:null,group:null,node:null,rect:{},offset:{}},M=[],A=new K,j=c({},et),B=c({},et),ot={x:0,y:0},X={x:0,y:0},nt=function(t,e){var o={},n=t.group;n&&"object"==F(n)||(n={name:n,pull:!0,put:!0}),o.name=n.name||e,o.pull=n.pull,o.put=n.put,t.group=o};function r(t,e){if(!t||!t.nodeType||1!==t.nodeType)throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(t));(t[y]=this).el=t,this.ownerDocument=t.ownerDocument,this.options=e=Object.assign({},e);var o,n,i={group:"",animation:150,multiple:!1,draggable:null,handle:null,onDrag:null,onMove:null,onDrop:null,onChange:null,autoScroll:!0,scrollThreshold:25,delay:0,delayOnTouchOnly:!1,disabled:!1,ghostClass:"",ghostStyle:{},chosenClass:"",selectedClass:"",fallbackOnBody:!1,stopPropagation:!1,supportPointer:"onpointerdown"in window&&!a,supportTouch:"ontouchstart"in window,emptyInsertThreshold:5};for(o in i)o in this.options||(this.options[o]=i[o]);for(n in nt(e,"group_"+Number(Math.random().toString().slice(-3)+Date.now()).toString(32)),this)"_"===n.charAt(0)&&"function"==typeof this[n]&&(this[n]=this[n].bind(this));var e=this.options,r=e.supportPointer,e=e.supportTouch;l(t,r?"pointerdown":e?"touchstart":"mousedown",this._onDrag),M.push(t),this.multiplayer=new Z(this.options),this.animator=new J(this.options),O=new G}return(r.prototype={constructor:r,get helper(){return A.node},destroy:function(){this._dispatchEvent("destroy",this),this.el[y]=null;for(var t=0;t<e.start.length;t++)n(this.el,e.start[t],this._onDrag);this._clearState(),M.splice(M.indexOf(this.el),1),0==M.length&&(O=null),this.el=null},_onDrag:function(t){var e=this;if(!this.options.disabled&&this.options.group.pull&&(!/mousedown|pointerdown/.test(t.type)||0===t.button)){var o=z(t),n=o.touch,i=o.event,o=o.target;if(!(a&&o&&"SELECT"===o.tagName.toUpperCase()||o===this.el)){var r=this.options,s=r.draggable,r=r.handle;if(("function"!=typeof r||r(t))&&("string"!=typeof r||g(o,r))){if("function"==typeof s){r=s(t);if(!r)return;!function(e){if(e){var t=document.createElement("div");try{return t.appendChild(e.cloneNode(!0)),1==e.nodeType}catch(t){return e==window||e==document}}}(r)||(S=r)}else S=q(o,s,this.el,!1);S&&!S.animated&&(n&&v(S,"touch-action","none"),t=S.parentNode,T=n,(N=i).sortable=this,N.group=t,(C=this.options.multiple&&this.multiplayer.allowDrag(S))&&this.multiplayer.onDrag(this),r=m(S),o=h(S),j={sortable:this,group:t,node:S,rect:r,offset:o},B.group=t,B.sortable=this,ot={x:i.clientX-r.left,y:i.clientY-r.top},this.options.supportPointer?l(this.ownerDocument,"pointermove",Q):l(this.ownerDocument,n?"touchmove":"mousemove",Q),o=(s=this.options).delay,t=s.delayOnTouchOnly,!o||t&&!n||k||d?this._onStart():(this.options.supportPointer?l(this.ownerDocument,"pointerup",this._onDrop):l(this.ownerDocument,T?"touchend":"mouseup",this._onDrop),clearTimeout(P),P=setTimeout(function(){return e._onStart()},o)))}}}},_onStart:function(){D=this.el,this.options.supportPointer?(l(this.ownerDocument,"pointermove",this._onMove),l(this.ownerDocument,"pointerup",this._onDrop),l(this.ownerDocument,"pointercancel",this._onDrop)):T?(l(this.ownerDocument,"touchmove",this._onMove),l(this.ownerDocument,"touchend",this._onDrop),l(this.ownerDocument,"touchcancel",this._onDrop)):(l(this.ownerDocument,"mousemove",this._onMove),l(this.ownerDocument,"mouseup",this._onDrop));try{document.selection?setTimeout(function(){document.selection.empty()},0):window.getSelection().removeAllRanges()}catch(t){}},_onTrulyStarted:function(){var t;x||(this._dispatchEvent("onDrag",c(c({},_()),{},{event:N})),C&&this.multiplayer.onTrulyStarted(S,this),t=C?this.multiplayer.getHelper():S,A.init(j.rect,t,this.el,this.options,ot),r.helper=A.node,p(S,this.options.chosenClass,!0),v(S,"will-change","transform"),a&&v(document.body,"user-select","none"))},_allowPut:function(){var t,e;return N.group===this.el||!!this.options.group.put&&(t=this.options.group.name,(e=N.sortable.options.group).name)&&t&&e.name===t},_onMove:function(t){if(this._preventEvent(t),N&&S&&(e=(o=t).clientX,o=o.clientY,n=e-X.x,i=o-X.y,X.x=e,X.y=o,!(void 0!==e&&void 0!==o&&Math.abs(n)<=0&&Math.abs(i)<=0))){var e=z(t),o=e.event,n=e.target,i=(this._onTrulyStarted(),x=o,t.clientX-N.clientX),t=t.clientY-N.clientY,t=(A.move(i,t),this._dispatchEvent("onMove",c(c({},_()),{},{event:o})),this.scrollEl||(this.scrollEl=function(t,e){if(t&&t.getBoundingClientRect){var o=t,n=!1;do{if(o.clientWidth<o.scrollWidth||o.clientHeight<o.scrollHeight){var i=v(o);if(o.clientWidth<o.scrollWidth&&("auto"==i.overflowX||"scroll"==i.overflowX)||o.clientHeight<o.scrollHeight&&("auto"==i.overflowY||"scroll"==i.overflowY)){if(!o.getBoundingClientRect||o===document.body)return f();if(n||e)return o;n=!0}}}while(o=o.parentNode)}return f()}(this.el,!0)),this.options),r=t.autoScroll,t=t.scrollThreshold;if(r&&O.update(this.scrollEl,t,N,x),this._allowPut()){if(E=q(n,this.options.draggable,D,!1)){if(E===tt)return;if((tt=E).animated||V(E,S))return}E!==S&&(D!==j.sortable.el?n!==D&&function(t,e,o){for(var n=t.lastElementChild;n&&(n===e||"none"===v(n,"display")||o&&!g(n,o));)n=n.previousElementSibling;return n}(D,A.node)?E&&this._onInsert(o,!1):this._onInsert(o,!0):E&&this._onChange(o))}}},_onInsert:function(t,e){var o=e?S:E,n=e?D:E.parentNode;j.sortable.animator.collect(S,null,S.parentNode,S),this.animator.collect(null,o,n,S),C&&this.multiplayer.onChange(S,this),B={sortable:this,group:n,node:o,rect:m(S),offset:h(S)},j.sortable._dispatchEvent("onRemove",c(c({},_()),{},{event:t})),e?n.appendChild(S):n.insertBefore(S,o),this._dispatchEvent("onAdd",c(c({},_()),{},{event:t})),j.sortable.animator.animate(),this.animator.animate(),j.group=n,j.sortable=this},_onChange:function(t){var e=E.parentNode,t=(this.animator.collect(S,E,e),C&&this.multiplayer.onChange(S,this),B={sortable:this,group:e,node:E,rect:m(E),offset:h(E)},this._dispatchEvent("onChange",c(c({},_()),{},{event:t})),h(S)),o=null,o=t.top===B.offset.top?t.left<B.offset.left?E.nextSibling:E:t.top<B.offset.top?E.nextSibling:E;e.insertBefore(S,o),this.animator.animate(),j.group=e,j.sortable=this},_onDrop:function(t){this._unbindMoveEvents(),this._unbindDropEvents(),this._preventEvent(t),O.clear(),clearTimeout(P),S&&(p(S,this.options.chosenClass,!1),T&&v(S,"touch-action",""),v(S,"will-change","")),S&&N&&x?this._onEnd(t):this.options.multiple&&this.multiplayer.select(t,S,c({},j)),this._clearState()},_onEnd:function(t){var e;j.group=N.group,j.sortable=N.sortable,C?this.multiplayer.onDrop(t,S,N,_):(B.rect=m(S),B.offset=h(S),e=U(j.offset,B.offset),e=c(c({},_()),{},{changed:e,event:t}),B.sortable.el!==j.sortable.el&&j.sortable._dispatchEvent("onDrop",e),B.sortable._dispatchEvent("onDrop",e)),a&&v(document.body,"user-select","")},_preventEvent:function(t){void 0!==t.preventDefault&&t.cancelable&&t.preventDefault(),this.options.stopPropagation&&(t&&t.stopPropagation?t.stopPropagation():window.event.cancelBubble=!0)},_dispatchEvent:function(t,e){t=this.options[t];"function"==typeof t&&t(e)},_clearState:function(){S=E=N=x=T=C=tt=P=r.ghost=null,ot=X={x:0,y:0},j=B=c({},et),A.destroy()},_unbindMoveEvents:function(){for(var t=0;t<e.move.length;t++)n(this.ownerDocument,e.move[t],this._onMove),n(this.ownerDocument,e.move[t],Q)},_unbindDropEvents:function(){for(var t=0;t<e.end.length;t++)n(this.ownerDocument,e.end[t],this._onDrop)}}).utils={getRect:m,getOffset:h},r}); |
{ | ||
"name": "sortable-dnd", | ||
"version": "0.4.10", | ||
"version": "0.4.11", | ||
"description": "JS library for drag-and-drop lists, supports sortable and draggable", | ||
@@ -5,0 +5,0 @@ "main": "dist/sortable.js", |
@@ -41,2 +41,5 @@ type Group = { | ||
nodes: MultiNode[]; | ||
node: HTMLElement; | ||
offset: Offset; | ||
rect: Rect; | ||
} | ||
@@ -43,0 +46,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
77995
1560