sortable-dnd
Advanced tools
Comparing version 0.4.12 to 0.4.13
/*! | ||
* sortable-dnd v0.4.12 | ||
* sortable-dnd v0.4.13 | ||
* open source under the MIT license | ||
@@ -78,5 +78,5 @@ * https://github.com/mfuu/sortable-dnd#readme | ||
var events = { | ||
start: ['pointerdown', 'touchstart', 'mousedown'], | ||
move: ['pointermove', 'touchmove', 'mousemove'], | ||
end: ['pointerup', 'pointercancel', 'touchend', 'touchcancel', 'mouseup'] | ||
start: ['touchstart', 'mousedown'], | ||
move: ['touchmove', 'mousemove'], | ||
end: ['touchend', 'touchcancel', 'mouseup'] | ||
}; | ||
@@ -181,3 +181,3 @@ function userAgent(pattern) { | ||
var event = evt; | ||
var touch = evt.touches && evt.touches[0] || evt.changedTouches && evt.changedTouches[0] || evt.pointerType && evt.pointerType === 'touch' && evt; | ||
var touch = evt.touches && evt.touches[0] || evt.changedTouches && evt.changedTouches[0]; | ||
var target = touch ? document.elementFromPoint(touch.clientX, touch.clientY) : evt.target; | ||
@@ -353,3 +353,3 @@ if (touch && !('clientX' in event)) { | ||
} | ||
} else if (selector[0] === '>' ? el.parentNode === ctx && matches(el, selector) : matches(el, selector) || includeCTX && el === ctx) { | ||
} else if ((selector[0] === '>' ? el.parentNode === ctx && matches(el, selector) : matches(el, selector)) || includeCTX && el === ctx) { | ||
return el; | ||
@@ -508,3 +508,3 @@ } | ||
*/ | ||
select: function select(event, dragEl, from) { | ||
select: function select(event, dragEl, rootEl, from) { | ||
if (!dragEl) return; | ||
@@ -526,8 +526,7 @@ if (!selectedElements[this.groupName]) { | ||
} | ||
var contaienr = from.sortable.el; | ||
selectedElements[this.groupName].sort(function (a, b) { | ||
return sortByOffset(getOffset(a, contaienr), getOffset(b, contaienr)); | ||
return sortByOffset(getOffset(a, rootEl), getOffset(b, rootEl)); | ||
}); | ||
}, | ||
onDrag: function onDrag(sortable) { | ||
onDrag: function onDrag(rootEl, sortable) { | ||
multiFrom.sortable = sortable; | ||
@@ -538,3 +537,3 @@ multiFrom.nodes = selectedElements[this.groupName].map(function (node) { | ||
rect: getRect(node), | ||
offset: getOffset(node, sortable.el) | ||
offset: getOffset(node, rootEl) | ||
}; | ||
@@ -564,3 +563,3 @@ }); | ||
}, | ||
onDrop: function onDrop(event, dragEl, downEvent, _emits) { | ||
onDrop: function onDrop(event, dragEl, rootEl, downEvent, _emits) { | ||
var _this = this; | ||
@@ -582,6 +581,6 @@ multiTo.sortable.animator.collect(dragEl, null, dragEl.parentNode); | ||
rect: getRect(node), | ||
offset: getOffset(node, multiTo.sortable.el) | ||
offset: getOffset(node, rootEl) | ||
}; | ||
}); | ||
var changed = this._offsetChanged(multiFrom.nodes, multiTo.nodes); | ||
var changed = multiTo.sortable.el != multiFrom.sortable.el || this._offsetChanged(multiFrom.nodes, multiTo.nodes); | ||
var params = _objectSpread2(_objectSpread2({}, _emits()), {}, { | ||
@@ -598,7 +597,7 @@ changed: changed, | ||
_offsetChanged: function _offsetChanged(ns1, ns2) { | ||
return !!ns1.find(function (node) { | ||
var n = ns2.find(function (n) { | ||
return n.node === node.node; | ||
return !!ns1.find(function (o2) { | ||
var o1 = ns2.find(function (n) { | ||
return n.node === o2.node; | ||
}); | ||
return offsetChanged(n.offset, node.offset); | ||
return offsetChanged(o1.offset, o2.offset); | ||
}); | ||
@@ -818,2 +817,3 @@ } | ||
css(this.helper, 'transform', 'translateZ(0)'); | ||
css(this.helper, 'will-change', 'transform'); | ||
} | ||
@@ -939,2 +939,3 @@ }; | ||
var defaults = { | ||
disabled: false, | ||
group: '', | ||
@@ -953,3 +954,3 @@ animation: 150, | ||
delayOnTouchOnly: false, | ||
disabled: false, | ||
touchStartThreshold: (Number.parseInt ? Number : window).parseInt(window.devicePixelRatio, 10) || 1, | ||
ghostClass: '', | ||
@@ -961,3 +962,2 @@ ghostStyle: {}, | ||
stopPropagation: false, | ||
supportPointer: 'onpointerdown' in window && !Safari, | ||
supportTouch: 'ontouchstart' in window, | ||
@@ -979,10 +979,4 @@ emptyInsertThreshold: 5 | ||
} | ||
var _this$options = this.options, | ||
supportPointer = _this$options.supportPointer, | ||
supportTouch = _this$options.supportTouch; | ||
if (supportPointer) { | ||
on(el, 'pointerdown', this._onDrag); | ||
// Fixed some mobile terminals could not be dragged | ||
on(el, 'touchstart', this._preventEvent); | ||
} else if (supportTouch) { | ||
var supportTouch = this.options.supportTouch; | ||
if (supportTouch) { | ||
on(el, 'touchstart', this._onDrag); | ||
@@ -1012,3 +1006,2 @@ } else { | ||
_onDrag: function _onDrag( /** Event|TouchEvent */evt) { | ||
var _this = this; | ||
if (this.options.disabled || !this.options.group.pull) return; | ||
@@ -1025,5 +1018,5 @@ if (/mousedown|pointerdown/.test(evt.type) && evt.button !== 0) return; // only left button and enabled | ||
if (target === this.el) return; | ||
var _this$options2 = this.options, | ||
draggable = _this$options2.draggable, | ||
handle = _this$options2.handle; | ||
var _this$options = this.options, | ||
draggable = _this$options.draggable, | ||
handle = _this$options.handle; | ||
if (typeof handle === 'function' && !handle(evt)) return; | ||
@@ -1044,5 +1037,6 @@ if (typeof handle === 'string' && !matches(target, handle)) return; | ||
if (!dragEl || dragEl.animated) return; | ||
// solve the problem that the mobile cannot be dragged | ||
if (touch) css(dragEl, 'touch-action', 'none'); | ||
this._prepareStart(touch, event); | ||
}, | ||
_prepareStart: function _prepareStart(touch, event) { | ||
var _this = this; | ||
var parentEl = dragEl.parentNode; | ||
@@ -1052,5 +1046,5 @@ touchEvent = touch; | ||
downEvent.sortable = this; | ||
downEvent.group = parentEl; | ||
downEvent.group = dragEl.parentNode; | ||
isMultiple = this.options.multiple && this.multiplayer.allowDrag(dragEl); | ||
isMultiple && this.multiplayer.onDrag(this); | ||
isMultiple && this.multiplayer.onDrag(this.el, this); | ||
@@ -1075,5 +1069,3 @@ // get the position of the dragEl | ||
// enable drag between groups | ||
if (this.options.supportPointer) { | ||
on(this.ownerDocument, 'pointermove', _nearestSortable); | ||
} else if (touch) { | ||
if (touch) { | ||
on(this.ownerDocument, 'touchmove', _nearestSortable); | ||
@@ -1083,14 +1075,12 @@ } else { | ||
} | ||
var _this$options3 = this.options, | ||
delay = _this$options3.delay, | ||
delayOnTouchOnly = _this$options3.delayOnTouchOnly; | ||
var _this$options2 = this.options, | ||
delay = _this$options2.delay, | ||
delayOnTouchOnly = _this$options2.delayOnTouchOnly; | ||
if (delay && (!delayOnTouchOnly || touch) && !(Edge || IE11OrLess)) { | ||
if (this.options.supportPointer) { | ||
on(this.ownerDocument, 'pointerup', this._onDrop); | ||
} else if (touchEvent) { | ||
on(this.ownerDocument, 'touchend', this._onDrop); | ||
} else { | ||
on(this.ownerDocument, 'mouseup', this._onDrop); | ||
for (var i = 0; i < events.end.length; i++) { | ||
on(this.ownerDocument, events.end[i], this._cancelStart); | ||
} | ||
clearTimeout(dragStartTimer); | ||
for (var _i = 0; _i < events.move.length; _i++) { | ||
on(this.ownerDocument, events.move[_i], this._delayMoveHandler); | ||
} | ||
dragStartTimer = setTimeout(function () { | ||
@@ -1103,9 +1093,20 @@ return _this._onStart(); | ||
}, | ||
_delayMoveHandler: function _delayMoveHandler(evt) { | ||
var touch = evt.touches ? evt.touches[0] : evt; | ||
if (Math.max(Math.abs(touch.clientX - downEvent.clientX), Math.abs(touch.clientY - downEvent.clientY)) >= Math.floor(this.options.touchStartThreshold / (window.devicePixelRatio || 1))) { | ||
this._cancelStart(); | ||
} | ||
}, | ||
_cancelStart: function _cancelStart() { | ||
clearTimeout(dragStartTimer); | ||
for (var i = 0; i < events.end.length; i++) { | ||
off(this.ownerDocument, events.end[i], this._cancelStart); | ||
} | ||
for (var _i2 = 0; _i2 < events.move.length; _i2++) { | ||
off(this.ownerDocument, events.move[_i2], this._delayMoveHandler); | ||
} | ||
}, | ||
_onStart: function _onStart() { | ||
rootEl = this.el; | ||
if (this.options.supportPointer) { | ||
on(this.ownerDocument, 'pointermove', this._onMove); | ||
on(this.ownerDocument, 'pointerup', this._onDrop); | ||
on(this.ownerDocument, 'pointercancel', this._onDrop); | ||
} else if (touchEvent) { | ||
if (touchEvent) { | ||
on(this.ownerDocument, 'touchmove', this._onMove); | ||
@@ -1145,3 +1146,2 @@ on(this.ownerDocument, 'touchend', this._onDrop); | ||
toggleClass(dragEl, this.options.chosenClass, true); | ||
css(dragEl, 'will-change', 'transform'); | ||
Safari && css(document.body, 'user-select', 'none'); | ||
@@ -1171,18 +1171,7 @@ } | ||
moveEvent = event; | ||
var x = evt.clientX - downEvent.clientX; | ||
var y = evt.clientY - downEvent.clientY; | ||
helper.move(x, y); | ||
helper.move(evt.clientX - downEvent.clientX, evt.clientY - downEvent.clientY); | ||
this._autoScroll(); | ||
this._dispatchEvent('onMove', _objectSpread2(_objectSpread2({}, _emits()), {}, { | ||
event: event | ||
})); | ||
if (!this.scrollEl) { | ||
// get the scroll element, fix display 'none' to 'block' | ||
this.scrollEl = getParentAutoScrollElement(this.el, true); | ||
} | ||
var _this$options4 = this.options, | ||
autoScroll = _this$options4.autoScroll, | ||
scrollThreshold = _this$options4.scrollThreshold; | ||
if (autoScroll) { | ||
autoScroller.update(this.scrollEl, scrollThreshold, downEvent, moveEvent); | ||
} | ||
if (!this._allowPut()) return; | ||
@@ -1206,2 +1195,14 @@ dropEl = closest(target, this.options.draggable, rootEl, false); | ||
}, | ||
_autoScroll: function _autoScroll() { | ||
if (!this.scrollEl) { | ||
// get the scroll element, fix display 'none' to 'block' | ||
this.scrollEl = getParentAutoScrollElement(this.el, true); | ||
} | ||
var _this$options3 = this.options, | ||
autoScroll = _this$options3.autoScroll, | ||
scrollThreshold = _this$options3.scrollThreshold; | ||
if (autoScroll) { | ||
autoScroller.update(this.scrollEl, scrollThreshold, downEvent, moveEvent); | ||
} | ||
}, | ||
_onInsert: function _onInsert( /** Event|TouchEvent */event, insert) { | ||
@@ -1272,12 +1273,7 @@ var target = insert ? dragEl : dropEl; | ||
// clear style, attrs and class | ||
if (dragEl) { | ||
toggleClass(dragEl, this.options.chosenClass, false); | ||
touchEvent && css(dragEl, 'touch-action', ''); | ||
css(dragEl, 'will-change', ''); | ||
} | ||
dragEl && toggleClass(dragEl, this.options.chosenClass, false); | ||
if (dragEl && downEvent && moveEvent) { | ||
this._onEnd(evt); | ||
} else if (this.options.multiple) { | ||
// click event | ||
this.multiplayer.select(evt, dragEl, _objectSpread2({}, from)); | ||
this.multiplayer.select(evt, dragEl, rootEl, _objectSpread2({}, from)); | ||
} | ||
@@ -1290,3 +1286,3 @@ this._clearState(); | ||
if (isMultiple) { | ||
this.multiplayer.onDrop(evt, dragEl, downEvent, _emits); | ||
this.multiplayer.onDrop(evt, dragEl, rootEl, downEvent, _emits); | ||
} else { | ||
@@ -1293,0 +1289,0 @@ // re-acquire the offset and rect values of the dragged element as the value after the drag is completed |
@@ -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 n,o=Object.keys(e);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(e),t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),o.push.apply(o,n)),o}function l(o){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,n;e=o,n=i[t=t],(t=function(t){t=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);n=n.call(t,e||"default");if("object"!=typeof n)return n;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:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(i)):Y(Object(i)).forEach(function(t){Object.defineProperty(o,t,Object.getOwnPropertyDescriptor(i,t))})}return o}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 n,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=(n=!1,document.addEventListener("checkIfSupportPassive",null,{get passive(){return n=!0}}),n),c="undefined"==typeof window||"undefined"==typeof document?"":(r=window.getComputedStyle(document.documentElement,"")||["-moz-hidden-iframe"],"ms"!==(r=(Array.prototype.slice.call(r).join("").match(/-(moz|webkit|ms)-/)||""===r.OLink&&["","o"])[1])?r&&r.length?r[0].toUpperCase()+r.substr(1):"":"ms");function i(t,e){t.style["".concat(c,"TransitionDuration")]=null==e?"":"".concat(e,"ms")}function u(t,e){t.style["".concat(c,"Transform")]=e?"".concat(e):""}function h(t,e,n){window.addEventListener?t.addEventListener(e,n,!(!H&&d)&&L):window.attachEvent&&t.attachEvent("on"+e,n)}function o(t,e,n){window.removeEventListener?t.removeEventListener(e,n,!(!H&&d)&&L):window.detachEvent&&t.detachEvent("on"+e,n)}function I(t){var e=t,n=t.touches&&t.touches[0]||t.changedTouches&&t.changedTouches[0]||t.pointerType&&"touch"===t.pointerType&&t,t=n?document.elementFromPoint(n.clientX,n.clientY):t.target;return!n||"clientX"in e||(e.clientX=n.clientX,e.clientY=n.clientY,e.pageX=n.pageX,e.pageY=n.pageY,e.screenX=n.screenX,e.screenY=n.screenY),{touch:n,event:e,target:t}}function p(t,e){for(var n={top:0,left:0,height:t.offsetHeight,width:t.offsetWidth};n.top+=t.offsetTop,n.left+=t.offsetLeft,(t=t.parentNode)&&t!==e;);return n}function W(){var t=document.scrollingElement;return!t||t.contains(document.body)?document:t}function m(t){var e,n,o,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!==W()){if(n=(e=t.getBoundingClientRect()).top,o=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 n=u.top,o=u.left,i=u.bottom,r=u.right,s=u.height,{top:n,left:o,bottom:i,right:r,width:a=u.width,height:s};h=h.parentNode}}else o=n=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();n-=p.top+parseInt(v(c,"border-top-width")),o-=p.left+parseInt(v(c,"border-left-width")),i=n+e.height,r=o+e.width;break}}while(c=c.parentNode);return{top:n,left:o,bottom:i,right:r,width:a,height:s}}}function z(t,e,n,o){if(t){n=n||document;do{if(null==e){var i=Array.prototype.slice.call(n.children),r=i.indexOf(t);if(-1<r)return i[r];for(var s=0;s<i.length;s++)if(q(t,i[s]))return i[s]}else if(">"===e[0]?t.parentNode===n&&g(t,e):g(t,e)||o&&t===n)return t}while(t=t.parentNode)}return null}function q(t,e){if(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 f(t,e,n){var o;t&&e&&(t.classList?t.classList[n?"add":"remove"](e):(o=(" "+t.className+" ").replace(R," ").replace(" "+e+" "," "),t.className=(o+(n?" "+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 V(t,e){return t.top!==e.top||t.left!==e.left}function v(t,e,n){var o=t&&t.style;if(o){if(void 0===n)return document.defaultView&&document.defaultView.getComputedStyle?n=document.defaultView.getComputedStyle(t,""):t.currentStyle&&(n=t.currentStyle),void 0===e?n:n[e];o[e=e in o||-1!==e.indexOf("webkit")?e:"-webkit-"+e]=n+("string"==typeof n?"":"px")}}var b="Sortable"+Date.now(),r={sortable:null,nodes:[]},s=l({},r),y=l({},r),w={};function U(t){this.options=t||{},this.groupName=t.group.name}function Z(){this.autoScrollAnimationFrame=null,this.speed={x:10,y:10}}function G(t){this.options=t,this.animations=[]}function J(){this.helper=null,this.distance={x:0,y:0}}U.prototype={allowDrag:function(t){return this.options.multiple&&w[this.groupName]&&w[this.groupName].length&&-1<w[this.groupName].indexOf(t)},getHelper:function(){var n=document.createElement("div");return w[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 "),n.appendChild(t)}),n},select:function(t,e,n){var o,i;e&&(w[this.groupName]||(w[this.groupName]=[]),o=w[this.groupName].indexOf(e),f(e,this.options.selectedClass,o<0),t=l(l({},n),{},{event:t}),o<0?(w[this.groupName].push(e),n.sortable._dispatchEvent("onSelect",t)):(w[this.groupName].splice(o,1),n.sortable._dispatchEvent("onDeselect",t)),i=n.sortable.el,w[this.groupName].sort(function(t,e){return t=p(t,i),e=p(e,i),t.top==e.top?t.left-e.left:t.top-e.top}))},onDrag:function(e){s.sortable=e,s.nodes=w[this.groupName].map(function(t){return{node:t,rect:m(t),offset:p(t,e.el)}}),y.sortable=e},onTrulyStarted:function(e,t){t.animator.collect(e,null,e.parentNode),w[this.groupName].forEach(function(t){t!=e&&t.parentNode.removeChild(t)}),t.animator.animate()},onChange:function(t,e){var n=m(t),o=p(t,e.el);y.sortable=e,y.nodes=w[this.groupName].map(function(t){return{node:t,rect:n,offset:o}})},onDrop:function(t,n,e,o){var i=this,r=(y.sortable.animator.collect(n,null,n.parentNode),w[this.groupName].indexOf(n)),e=(w[this.groupName].forEach(function(t,e){e<r?n.parentNode.insertBefore(t,n):(e=0<e?w[i.groupName][e-1]:n,n.parentNode.insertBefore(t,e.nextSibling))}),s.sortable=e.sortable,y.nodes=w[this.groupName].map(function(t){return{node:t,rect:m(t),offset:p(t,y.sortable.el)}}),this._offsetChanged(s.nodes,y.nodes)),o=l(l({},o()),{},{changed:e,event:t});y.sortable.el!=s.sortable.el&&s.sortable._dispatchEvent("onDrop",o),y.sortable._dispatchEvent("onDrop",o),y.sortable.animator.animate()},_offsetChanged:function(t,n){return!!t.find(function(e){return V(n.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)}),Z.prototype={clear:function(){null!=this.autoScrollAnimationFrame&&(cancelAnimationFrame(this.autoScrollAnimationFrame),this.autoScrollAnimationFrame=null)},update:function(t,e,n,o){var i=this;cancelAnimationFrame(this.autoScrollAnimationFrame),this.autoScrollAnimationFrame=requestAnimationFrame(function(){n&&o&&i.autoScroll(t,e,o),i.update(t,e,n,o)})},autoScroll:function(t,e,n){var o,i,r,s,a,l,c,u,h,p,d,f;t&&(o=n.clientX,n=n.clientY,void 0!==o)&&void 0!==n&&(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,n<s||a<o||l<n||o<c||(u=0<d&&s<=n&&n<=s+e,h=i+h<p&&o<=a&&a-e<=o,p=d+f<r&&n<=l&&l-e<=n,d=(f=d=0)<i&&c<=o&&o<=c+e?Math.floor(Math.max(-1,(o-c)/e-1)*this.speed.x):h?Math.ceil(Math.min(1,(o-a)/e+1)*this.speed.x):0,(f=u?Math.floor(Math.max(-1,(n-s)/e-1)*this.speed.y):p?Math.ceil(Math.min(1,(n-l)/e+1)*this.speed.y):0)&&(t.scrollTop+=f),d&&(t.scrollLeft+=d)))}},G.prototype={collect:function(t,e,n,o){var i=this;n&&(n=Array.prototype.slice.call(n.children),e=(t=this._getRange(n,t,e,o)).start,t=t.end,this.animations.length=0,n.slice(e,t+1).forEach(function(t){t!==o&&t!==B.helper&&i.animations.push({node:t,rect:m(t)})}))},animate:function(){var n=this;this.animations.forEach(function(t){var e=t.node,t=t.rect;n._excute(e,t)})},_excute:function(t,e){var n=e.left,e=e.top,o=m(t),e=e-o.top,n=n-o.left,o=(i(t),u(t,"translate3d(".concat(n,"px, ").concat(e,"px, 0)")),t.offsetWidth,this.options.animation);i(t,o),u(t,"translate3d(0px, 0px, 0px)"),clearTimeout(t.animated),t.animated=setTimeout(function(){i(t),u(t,""),t.animated=null},o)},_getRange:function(t,e,n){var o,e=t.indexOf(e),n=t.indexOf(n);return n<e&&(e=(o=[n,e])[0],n=o[1]),e<0&&(e=n,n=t.length-1),{start:e,end:n=n<0?t.length-1:n}}},J.prototype={get node(){return this.helper},destroy:function(){this.helper&&this.helper.parentNode&&this.helper.parentNode.removeChild(this.helper),this.helper=null,this.distance={x:0,y:0}},move:function(t,e){u(this.helper,"translate3d(".concat(t,"px, ").concat(e,"px, 0)"))},init:function(t,e,n,o){if(!this.helper){var i,r=o.fallbackOnBody,s=o.ghostClass,o=o.ghostStyle,o=void 0===o?{}:o,r=r?document.body:n,a=(this.helper=e.cloneNode(!0),f(this.helper,s,!0),l({"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"},o));for(i in a)v(this.helper,i,a[i]);n=this.helper,e="none",n.style["".concat(c,"Transition")]=e?"none"===e?"none":"".concat(e):"",u(this.helper,"translate3d(0px, 0px, 0px)"),r.appendChild(this.helper);s=this.distance.x/parseInt(this.helper.style.width)*100,t=this.distance.y/parseInt(this.helper.style.height)*100;v(this.helper,"transform-origin","".concat(s,"% ").concat(t,"%")),v(this.helper,"transform","translateZ(0)")}}};function K(t){var e;S&&(e=t.touches?t.touches[0]:t,e=Q(e.clientX,e.clientY))&&(D=e)!==N.sortable.el&&e[b]._onMove(t)}function Q(i,r){var s;return P.some(function(t){var e,n,o=t[b].options.emptyInsertThreshold;if(o)return n=m(t,{parent:!0}),e=i>=n.left-o&&i<=n.right+o,n=r>=n.top-o&&r<=n.bottom+o,e&&n?s=t:void 0}),s}function _(){var t,e={from:l({},A),to:l({},j)};return C&&(t={from:l({},s),to:l({},y)},e.from=l(l({},t.from),e.from),e.to=l(l({},t.to),e.to)),e}var D,S,E,N,x,T,C,$,O,tt={sortable:null,group:null,node:null,rect:{},offset:{}},P=[],M=new J,et=new Z,A=l({},tt),j=l({},tt),X={x:0,y:0},nt=function(t,e){var n={},o=t.group;o&&"object"==F(o)||(o={name:o,pull:!0,put:!0}),n.name=o.name||e,n.pull=o.pull,n.put=o.put,t.group=n};function B(t,e){if(!t||!t.nodeType||1!==t.nodeType)throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(t));(t[b]=this).el=t,this.ownerDocument=t.ownerDocument,this.options=e=Object.assign({},e);var n,o,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(n in i)n in this.options||(this.options[n]=i[n]);for(o in nt(e,"group_"+Number(Math.random().toString().slice(-3)+Date.now()).toString(32)),this)"_"===o.charAt(0)&&"function"==typeof this[o]&&(this[o]=this[o].bind(this));var e=this.options,r=e.supportPointer,e=e.supportTouch;r?(h(t,"pointerdown",this._onDrag),h(t,"touchstart",this._preventEvent)):h(t,e?"touchstart":"mousedown",this._onDrag),P.push(t),this.multiplayer=new U(this.options),this.animator=new G(this.options)}return(B.prototype={constructor:B,destroy:function(){this._dispatchEvent("destroy",this),this.el[b]=null;for(var t=0;t<e.start.length;t++)o(this.el,e.start[t],this._onDrag);this._clearState(),P.splice(P.indexOf(this.el),1),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 n=I(t),o=n.touch,i=n.event,n=n.target;if(!(a&&n&&"SELECT"===n.tagName.toUpperCase()||n===this.el)){var r=this.options,s=r.draggable,r=r.handle;if(("function"!=typeof r||r(t))&&("string"!=typeof r||g(n,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=z(n,s,this.el,!1);S&&!S.animated&&(o&&v(S,"touch-action","none"),t=S.parentNode,T=o,(N=i).sortable=this,N.group=t,(C=this.options.multiple&&this.multiplayer.allowDrag(S))&&this.multiplayer.onDrag(this),r=m(S),n=p(S,this.el),A={sortable:this,group:t,node:S,rect:r,offset:n},j.group=t,j.sortable=this,M.distance={x:i.clientX-r.left,y:i.clientY-r.top},this.options.supportPointer?h(this.ownerDocument,"pointermove",K):h(this.ownerDocument,o?"touchmove":"mousemove",K),n=(s=this.options).delay,t=s.delayOnTouchOnly,!n||t&&!o||k||d?this._onStart():(this.options.supportPointer?h(this.ownerDocument,"pointerup",this._onDrop):h(this.ownerDocument,T?"touchend":"mouseup",this._onDrop),clearTimeout(O),O=setTimeout(function(){return e._onStart()},n)))}}}},_onStart:function(){D=this.el,this.options.supportPointer?(h(this.ownerDocument,"pointermove",this._onMove),h(this.ownerDocument,"pointerup",this._onDrop),h(this.ownerDocument,"pointercancel",this._onDrop)):T?(h(this.ownerDocument,"touchmove",this._onMove),h(this.ownerDocument,"touchend",this._onDrop),h(this.ownerDocument,"touchcancel",this._onDrop)):(h(this.ownerDocument,"mousemove",this._onMove),h(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",l(l({},_()),{},{event:N})),C&&this.multiplayer.onTrulyStarted(S,this),t=C?this.multiplayer.getHelper():S,M.init(A.rect,t,this.el,this.options),B.helper=M.node,f(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=(n=t).clientX,n=n.clientY,o=e-X.x,i=n-X.y,X.x=e,X.y=n,!(void 0!==e&&void 0!==n&&Math.abs(o)<=0&&Math.abs(i)<=0))){var e=I(t),n=e.event,o=e.target,i=(this._onTrulyStarted(),x=n,t.clientX-N.clientX),t=t.clientY-N.clientY,t=(M.move(i,t),this._dispatchEvent("onMove",l(l({},_()),{},{event:n})),this.scrollEl||(this.scrollEl=function(t,e){if(t&&t.getBoundingClientRect){var n=t,o=!1;do{if(n.clientWidth<n.scrollWidth||n.clientHeight<n.scrollHeight){var i=v(n);if(n.clientWidth<n.scrollWidth&&("auto"==i.overflowX||"scroll"==i.overflowX)||n.clientHeight<n.scrollHeight&&("auto"==i.overflowY||"scroll"==i.overflowY)){if(!n.getBoundingClientRect||n===document.body)return W();if(o||e)return n;o=!0}}}while(n=n.parentNode)}return W()}(this.el,!0)),this.options),r=t.autoScroll,t=t.scrollThreshold;if(r&&et.update(this.scrollEl,t,N,x),this._allowPut()){if(E=z(o,this.options.draggable,D,!1)){if(E===$)return;if(($=E).animated||q(E,S))return}E!==S&&(D!==A.sortable.el?o!==D&&function(t,e,n){for(var o=t.lastElementChild;o&&(o===e||"none"===v(o,"display")||n&&!g(o,n));)o=o.previousElementSibling;return o}(D,M.node)?E&&this._onInsert(n,!1):this._onInsert(n,!0):E&&this._onChange(n))}}},_onInsert:function(t,e){var n=e?S:E,o=e?D:E.parentNode;A.sortable.animator.collect(S,null,S.parentNode,S),this.animator.collect(null,n,o,S),C&&this.multiplayer.onChange(S,this),j={sortable:this,group:o,node:n,rect:m(S),offset:p(S,D)},A.sortable._dispatchEvent("onRemove",l(l({},_()),{},{event:t})),e?o.appendChild(S):o.insertBefore(S,n),this._dispatchEvent("onAdd",l(l({},_()),{},{event:t})),A.sortable.animator.animate(),this.animator.animate(),A.group=o,A.sortable=this},_onChange:function(t){var e=E.parentNode,t=(this.animator.collect(S,E,e),C&&this.multiplayer.onChange(S,this),j={sortable:this,group:e,node:E,rect:m(E),offset:p(E,D)},this._dispatchEvent("onChange",l(l({},_()),{},{event:t})),p(S,D)),n=null,n=t.top===j.offset.top?t.left<j.offset.left?E.nextSibling:E:t.top<j.offset.top?E.nextSibling:E;e.insertBefore(S,n),this.animator.animate(),A.group=e,A.sortable=this},_onDrop:function(t){this._unbindMoveEvents(),this._unbindDropEvents(),this._preventEvent(t),et.clear(),clearTimeout(O),S&&(f(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,l({},A)),this._clearState()},_onEnd:function(t){var e;A.group=N.group,A.sortable=N.sortable,C?this.multiplayer.onDrop(t,S,N,_):(j.rect=m(S),j.offset=p(S,D),e=j.sortable.el!==A.sortable.el||V(A.offset,j.offset),e=l(l({},_()),{},{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&&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=$=O=B.helper=null,X={x:0,y:0},A=j=l({},tt),M.destroy()},_unbindMoveEvents:function(){for(var t=0;t<e.move.length;t++)o(this.ownerDocument,e.move[t],this._onMove),o(this.ownerDocument,e.move[t],K)},_unbindDropEvents:function(){for(var t=0;t<e.end.length;t++)o(this.ownerDocument,e.end[t],this._onDrop)}}).utils={getRect:m,getOffset:p},B}); | ||
!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 B(e,t){var n,o=Object.keys(e);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(e),t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),o.push.apply(o,n)),o}function l(o){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?B(Object(i),!0).forEach(function(t){var e,n;e=o,n=i[t=t],(t=function(t){t=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);n=n.call(t,e||"default");if("object"!=typeof n)return n;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:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(i)):B(Object(i)).forEach(function(t){Object.defineProperty(o,t,Object.getOwnPropertyDescriptor(i,t))})}return o}function R(t){return(R="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 F={capture:!1,passive:!1},H=/\s+/g,c={start:["touchstart","mousedown"],move:["touchmove","mousemove"],end:["touchend","touchcancel","mouseup"]};function t(t){if("undefined"!=typeof window&&window.navigator)return!!navigator.userAgent.match(t)}var e,d=t(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),L=t(/Edge/i),a=t(/safari/i)&&!t(/chrome/i)&&!t(/android/i),k=(e=!1,document.addEventListener("checkIfSupportPassive",null,{get passive(){return e=!0}}),e),u="undefined"==typeof window||"undefined"==typeof document?"":(o=window.getComputedStyle(document.documentElement,"")||["-moz-hidden-iframe"],"ms"!==(o=(Array.prototype.slice.call(o).join("").match(/-(moz|webkit|ms)-/)||""===o.OLink&&["","o"])[1])?o&&o.length?o[0].toUpperCase()+o.substr(1):"":"ms");function i(t,e){t.style["".concat(u,"TransitionDuration")]=null==e?"":"".concat(e,"ms")}function h(t,e){t.style["".concat(u,"Transform")]=e?"".concat(e):""}function p(t,e,n){window.addEventListener?t.addEventListener(e,n,!(!k&&d)&&F):window.attachEvent&&t.attachEvent("on"+e,n)}function n(t,e,n){window.removeEventListener?t.removeEventListener(e,n,!(!k&&d)&&F):window.detachEvent&&t.detachEvent("on"+e,n)}function I(t){var e=t,n=t.touches&&t.touches[0]||t.changedTouches&&t.changedTouches[0],t=n?document.elementFromPoint(n.clientX,n.clientY):t.target;return!n||"clientX"in e||(e.clientX=n.clientX,e.clientY=n.clientY,e.pageX=n.pageX,e.pageY=n.pageY,e.screenX=n.screenX,e.screenY=n.screenY),{touch:n,event:e,target:t}}function f(t,e){for(var n={top:0,left:0,height:t.offsetHeight,width:t.offsetWidth};n.top+=t.offsetTop,n.left+=t.offsetLeft,(t=t.parentNode)&&t!==e;);return n}function m(){var t=document.scrollingElement;return!t||t.contains(document.body)?document:t}function g(t){var e,n,o,i,r,a,s,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!==m()){if(n=(e=t.getBoundingClientRect()).top,o=e.left,i=e.bottom,r=e.right,a=e.height,s=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<a)return n=u.top,o=u.left,i=u.bottom,r=u.right,a=u.height,{top:n,left:o,bottom:i,right:r,width:s=u.width,height:a};h=h.parentNode}}else o=n=0,i=window.innerHeight,r=window.innerWidth,a=window.innerHeight,s=window.innerWidth;if((l.block||l.relative)&&t!==window&&(c=c||t.parentNode,!d))do{if(c&&c.getBoundingClientRect&&("none"!==b(c,"transform")||l.relative&&"static"!==b(c,"position"))){var p=c.getBoundingClientRect();n-=p.top+parseInt(b(c,"border-top-width")),o-=p.left+parseInt(b(c,"border-left-width")),i=n+e.height,r=o+e.width;break}}while(c=c.parentNode);return{top:n,left:o,bottom:i,right:r,width:s,height:a}}}function W(t,e,n,o){if(t){n=n||document;do{if(null==e){var i=Array.prototype.slice.call(n.children),r=i.indexOf(t);if(-1<r)return i[r];for(var a=0;a<i.length;a++)if(z(t,i[a]))return i[a]}else if((">"!==e[0]||t.parentNode===n)&&s(t,e)||o&&t===n)return t}while(t=t.parentNode)}return null}function z(t,e){if(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 v(t,e,n){var o;t&&e&&(t.classList?t.classList[n?"add":"remove"](e):(o=(" "+t.className+" ").replace(H," ").replace(" "+e+" "," "),t.className=(o+(n?" "+e:"")).replace(H," ")))}function s(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 q(t,e){return t.top!==e.top||t.left!==e.left}function b(t,e,n){var o=t&&t.style;if(o){if(void 0===n)return document.defaultView&&document.defaultView.getComputedStyle?n=document.defaultView.getComputedStyle(t,""):t.currentStyle&&(n=t.currentStyle),void 0===e?n:n[e];o[e=e in o||-1!==e.indexOf("webkit")?e:"-webkit-"+e]=n+("string"==typeof n?"":"px")}}var y="Sortable"+Date.now(),o={sortable:null,nodes:[]},w=l({},o),_=l({},o),S={};function V(t){this.options=t||{},this.groupName=t.group.name}function U(){this.autoScrollAnimationFrame=null,this.speed={x:10,y:10}}function Z(t){this.options=t,this.animations=[]}function G(){this.helper=null,this.distance={x:0,y:0}}V.prototype={allowDrag:function(t){return this.options.multiple&&S[this.groupName]&&S[this.groupName].length&&-1<S[this.groupName].indexOf(t)},getHelper:function(){var n=document.createElement("div");return S[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 "),n.appendChild(t)}),n},select:function(t,e,n,o){var i;e&&(S[this.groupName]||(S[this.groupName]=[]),i=S[this.groupName].indexOf(e),v(e,this.options.selectedClass,i<0),t=l(l({},o),{},{event:t}),i<0?(S[this.groupName].push(e),o.sortable._dispatchEvent("onSelect",t)):(S[this.groupName].splice(i,1),o.sortable._dispatchEvent("onDeselect",t)),S[this.groupName].sort(function(t,e){return t=f(t,n),e=f(e,n),t.top==e.top?t.left-e.left:t.top-e.top}))},onDrag:function(e,t){w.sortable=t,w.nodes=S[this.groupName].map(function(t){return{node:t,rect:g(t),offset:f(t,e)}}),_.sortable=t},onTrulyStarted:function(e,t){t.animator.collect(e,null,e.parentNode),S[this.groupName].forEach(function(t){t!=e&&t.parentNode.removeChild(t)}),t.animator.animate()},onChange:function(t,e){var n=g(t),o=f(t,e.el);_.sortable=e,_.nodes=S[this.groupName].map(function(t){return{node:t,rect:n,offset:o}})},onDrop:function(t,n,e,o,i){var r=this,a=(_.sortable.animator.collect(n,null,n.parentNode),S[this.groupName].indexOf(n)),o=(S[this.groupName].forEach(function(t,e){e<a?n.parentNode.insertBefore(t,n):(e=0<e?S[r.groupName][e-1]:n,n.parentNode.insertBefore(t,e.nextSibling))}),w.sortable=o.sortable,_.nodes=S[this.groupName].map(function(t){return{node:t,rect:g(t),offset:f(t,e)}}),_.sortable.el!=w.sortable.el||this._offsetChanged(w.nodes,_.nodes)),i=l(l({},i()),{},{changed:o,event:t});_.sortable.el!=w.sortable.el&&w.sortable._dispatchEvent("onDrop",i),_.sortable._dispatchEvent("onDrop",i),_.sortable.animator.animate()},_offsetChanged:function(t,n){return!!t.find(function(e){return q(n.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)}),U.prototype={clear:function(){null!=this.autoScrollAnimationFrame&&(cancelAnimationFrame(this.autoScrollAnimationFrame),this.autoScrollAnimationFrame=null)},update:function(t,e,n,o){var i=this;cancelAnimationFrame(this.autoScrollAnimationFrame),this.autoScrollAnimationFrame=requestAnimationFrame(function(){n&&o&&i.autoScroll(t,e,o),i.update(t,e,n,o)})},autoScroll:function(t,e,n){var o,i,r,a,s,l,c,u,h,p,d,f;t&&(o=n.clientX,n=n.clientY,void 0!==o)&&void 0!==n&&(h=g(t))&&(d=t.scrollTop,i=t.scrollLeft,r=t.scrollHeight,p=t.scrollWidth,a=h.top,s=h.right,l=h.bottom,c=h.left,f=h.height,h=h.width,n<a||s<o||l<n||o<c||(u=0<d&&a<=n&&n<=a+e,h=i+h<p&&o<=s&&s-e<=o,p=d+f<r&&n<=l&&l-e<=n,d=(f=d=0)<i&&c<=o&&o<=c+e?Math.floor(Math.max(-1,(o-c)/e-1)*this.speed.x):h?Math.ceil(Math.min(1,(o-s)/e+1)*this.speed.x):0,(f=u?Math.floor(Math.max(-1,(n-a)/e-1)*this.speed.y):p?Math.ceil(Math.min(1,(n-l)/e+1)*this.speed.y):0)&&(t.scrollTop+=f),d&&(t.scrollLeft+=d)))}},Z.prototype={collect:function(t,e,n,o){var i=this;n&&(n=Array.prototype.slice.call(n.children),e=(t=this._getRange(n,t,e,o)).start,t=t.end,this.animations.length=0,n.slice(e,t+1).forEach(function(t){t!==o&&t!==Y.helper&&i.animations.push({node:t,rect:g(t)})}))},animate:function(){var n=this;this.animations.forEach(function(t){var e=t.node,t=t.rect;n._excute(e,t)})},_excute:function(t,e){var n=e.left,e=e.top,o=g(t),e=e-o.top,n=n-o.left,o=(i(t),h(t,"translate3d(".concat(n,"px, ").concat(e,"px, 0)")),t.offsetWidth,this.options.animation);i(t,o),h(t,"translate3d(0px, 0px, 0px)"),clearTimeout(t.animated),t.animated=setTimeout(function(){i(t),h(t,""),t.animated=null},o)},_getRange:function(t,e,n){var o,e=t.indexOf(e),n=t.indexOf(n);return n<e&&(e=(o=[n,e])[0],n=o[1]),e<0&&(e=n,n=t.length-1),{start:e,end:n=n<0?t.length-1:n}}},G.prototype={get node(){return this.helper},destroy:function(){this.helper&&this.helper.parentNode&&this.helper.parentNode.removeChild(this.helper),this.helper=null,this.distance={x:0,y:0}},move:function(t,e){h(this.helper,"translate3d(".concat(t,"px, ").concat(e,"px, 0)"))},init:function(t,e,n,o){if(!this.helper){var i,r=o.fallbackOnBody,a=o.ghostClass,o=o.ghostStyle,o=void 0===o?{}:o,r=r?document.body:n,s=(this.helper=e.cloneNode(!0),v(this.helper,a,!0),l({"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"},o));for(i in s)b(this.helper,i,s[i]);n=this.helper,e="none",n.style["".concat(u,"Transition")]=e?"none"===e?"none":"".concat(e):"",h(this.helper,"translate3d(0px, 0px, 0px)"),r.appendChild(this.helper);a=this.distance.x/parseInt(this.helper.style.width)*100,t=this.distance.y/parseInt(this.helper.style.height)*100;b(this.helper,"transform-origin","".concat(a,"% ").concat(t,"%")),b(this.helper,"transform","translateZ(0)"),b(this.helper,"will-change","transform")}}};function J(t){var e;E&&(e=t.touches?t.touches[0]:t,e=K(e.clientX,e.clientY))&&(D=e)!==x.sortable.el&&e[y]._onMove(t)}function K(i,r){var a;return M.some(function(t){var e,n,o=t[y].options.emptyInsertThreshold;if(o)return n=g(t,{parent:!0}),e=i>=n.left-o&&i<=n.right+o,n=r>=n.top-o&&r<=n.bottom+o,e&&n?a=t:void 0}),a}function r(){var t,e={from:l({},A),to:l({},j)};return C&&(t={from:l({},w),to:l({},_)},e.from=l(l({},t.from),e.from),e.to=l(l({},t.to),e.to)),e}var D,E,N,x,T,Q,C,$,O,tt={sortable:null,group:null,node:null,rect:{},offset:{}},M=[],P=new G,et=new U,A=l({},tt),j=l({},tt),X={x:0,y:0},nt=function(t,e){var n={},o=t.group;o&&"object"==R(o)||(o={name:o,pull:!0,put:!0}),n.name=o.name||e,n.pull=o.pull,n.put=o.put,t.group=n};function Y(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 n,o,i={disabled:!1,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,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,ghostClass:"",ghostStyle:{},chosenClass:"",selectedClass:"",fallbackOnBody:!1,stopPropagation:!1,supportTouch:"ontouchstart"in window,emptyInsertThreshold:5};for(n in i)n in this.options||(this.options[n]=i[n]);for(o in nt(e,"group_"+Number(Math.random().toString().slice(-3)+Date.now()).toString(32)),this)"_"===o.charAt(0)&&"function"==typeof this[o]&&(this[o]=this[o].bind(this));p(t,this.options.supportTouch?"touchstart":"mousedown",this._onDrag),M.push(t),this.multiplayer=new V(this.options),this.animator=new Z(this.options)}return(Y.prototype={constructor:Y,destroy:function(){this._dispatchEvent("destroy",this),this.el[y]=null;for(var t=0;t<c.start.length;t++)n(this.el,c.start[t],this._onDrag);this._clearState(),M.splice(M.indexOf(this.el),1),this.el=null},_onDrag:function(t){if(!this.options.disabled&&this.options.group.pull&&(!/mousedown|pointerdown/.test(t.type)||0===t.button)){var e=I(t),n=e.touch,o=e.event,e=e.target;if(!(a&&e&&"SELECT"===e.tagName.toUpperCase()||e===this.el)){var i=this.options,r=i.draggable,i=i.handle;if(("function"!=typeof i||i(t))&&("string"!=typeof i||s(e,i))){if("function"==typeof r){i=r(t);if(!i)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}}}(i)||(E=i)}else E=W(e,r,this.el,!1);E&&!E.animated&&this._prepareStart(n,o)}}}},_prepareStart:function(t,e){var n=this,o=E.parentNode,i=(Q=t,(x=e).sortable=this,x.group=E.parentNode,(C=this.options.multiple&&this.multiplayer.allowDrag(E))&&this.multiplayer.onDrag(this.el,this),g(E)),r=f(E,this.el),r=(A={sortable:this,group:o,node:E,rect:i,offset:r},j.group=o,j.sortable=this,P.distance={x:e.clientX-i.left,y:e.clientY-i.top},p(this.ownerDocument,t?"touchmove":"mousemove",J),this.options),o=r.delay,e=r.delayOnTouchOnly;if(!o||e&&!t||L||d)this._onStart();else{for(var a=0;a<c.end.length;a++)p(this.ownerDocument,c.end[a],this._cancelStart);for(var s=0;s<c.move.length;s++)p(this.ownerDocument,c.move[s],this._delayMoveHandler);O=setTimeout(function(){return n._onStart()},o)}},_delayMoveHandler:function(t){t=t.touches?t.touches[0]:t;Math.max(Math.abs(t.clientX-x.clientX),Math.abs(t.clientY-x.clientY))>=Math.floor(this.options.touchStartThreshold/(window.devicePixelRatio||1))&&this._cancelStart()},_cancelStart:function(){clearTimeout(O);for(var t=0;t<c.end.length;t++)n(this.ownerDocument,c.end[t],this._cancelStart);for(var e=0;e<c.move.length;e++)n(this.ownerDocument,c.move[e],this._delayMoveHandler)},_onStart:function(){D=this.el,Q?(p(this.ownerDocument,"touchmove",this._onMove),p(this.ownerDocument,"touchend",this._onDrop),p(this.ownerDocument,"touchcancel",this._onDrop)):(p(this.ownerDocument,"mousemove",this._onMove),p(this.ownerDocument,"mouseup",this._onDrop));try{document.selection?setTimeout(function(){document.selection.empty()},0):window.getSelection().removeAllRanges()}catch(t){}},_onTrulyStarted:function(){var t;T||(this._dispatchEvent("onDrag",l(l({},r()),{},{event:x})),C&&this.multiplayer.onTrulyStarted(E,this),t=C?this.multiplayer.getHelper():E,P.init(A.rect,t,this.el,this.options),Y.helper=P.node,v(E,this.options.chosenClass,!0),a&&b(document.body,"user-select","none"))},_allowPut:function(){var t,e;return x.group===this.el||!!this.options.group.put&&(t=this.options.group.name,(e=x.sortable.options.group).name)&&t&&e.name===t},_onMove:function(t){if(this._preventEvent(t),x&&E&&(n=(o=t).clientX,o=o.clientY,i=n-X.x,e=o-X.y,X.x=n,X.y=o,!(void 0!==n&&void 0!==o&&Math.abs(i)<=0&&Math.abs(e)<=0))){var e,n=I(t),o=n.event,i=n.target;if(this._onTrulyStarted(),T=o,P.move(t.clientX-x.clientX,t.clientY-x.clientY),this._autoScroll(),this._dispatchEvent("onMove",l(l({},r()),{},{event:o})),this._allowPut()){if(N=W(i,this.options.draggable,D,!1)){if(N===$)return;if(($=N).animated||z(N,E))return}N!==E&&(D!==A.sortable.el?i!==D&&function(t,e,n){for(var o=t.lastElementChild;o&&(o===e||"none"===b(o,"display")||n&&!s(o,n));)o=o.previousElementSibling;return o}(D,P.node)?N&&this._onInsert(o,!1):this._onInsert(o,!0):N&&this._onChange(o))}}},_autoScroll:function(){this.scrollEl||(this.scrollEl=function(t,e){if(t&&t.getBoundingClientRect){var n=t,o=!1;do{if(n.clientWidth<n.scrollWidth||n.clientHeight<n.scrollHeight){var i=b(n);if(n.clientWidth<n.scrollWidth&&("auto"==i.overflowX||"scroll"==i.overflowX)||n.clientHeight<n.scrollHeight&&("auto"==i.overflowY||"scroll"==i.overflowY)){if(!n.getBoundingClientRect||n===document.body)return m();if(o||e)return n;o=!0}}}while(n=n.parentNode)}return m()}(this.el,!0));var t=this.options,e=t.autoScroll,t=t.scrollThreshold;e&&et.update(this.scrollEl,t,x,T)},_onInsert:function(t,e){var n=e?E:N,o=e?D:N.parentNode;A.sortable.animator.collect(E,null,E.parentNode,E),this.animator.collect(null,n,o,E),C&&this.multiplayer.onChange(E,this),j={sortable:this,group:o,node:n,rect:g(E),offset:f(E,D)},A.sortable._dispatchEvent("onRemove",l(l({},r()),{},{event:t})),e?o.appendChild(E):o.insertBefore(E,n),this._dispatchEvent("onAdd",l(l({},r()),{},{event:t})),A.sortable.animator.animate(),this.animator.animate(),A.group=o,A.sortable=this},_onChange:function(t){var e=N.parentNode,t=(this.animator.collect(E,N,e),C&&this.multiplayer.onChange(E,this),j={sortable:this,group:e,node:N,rect:g(N),offset:f(N,D)},this._dispatchEvent("onChange",l(l({},r()),{},{event:t})),f(E,D)),n=null,n=t.top===j.offset.top?t.left<j.offset.left?N.nextSibling:N:t.top<j.offset.top?N.nextSibling:N;e.insertBefore(E,n),this.animator.animate(),A.group=e,A.sortable=this},_onDrop:function(t){this._unbindMoveEvents(),this._unbindDropEvents(),this._preventEvent(t),et.clear(),clearTimeout(O),E&&v(E,this.options.chosenClass,!1),E&&x&&T?this._onEnd(t):this.options.multiple&&this.multiplayer.select(t,E,D,l({},A)),this._clearState()},_onEnd:function(t){var e;A.group=x.group,A.sortable=x.sortable,C?this.multiplayer.onDrop(t,E,D,x,r):(j.rect=g(E),j.offset=f(E,D),e=j.sortable.el!==A.sortable.el||q(A.offset,j.offset),e=l(l({},r()),{},{changed:e,event:t}),j.sortable.el!==A.sortable.el&&A.sortable._dispatchEvent("onDrop",e),j.sortable._dispatchEvent("onDrop",e)),a&&b(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(){E=N=x=T=Q=C=$=O=Y.helper=null,X={x:0,y:0},A=j=l({},tt),P.destroy()},_unbindMoveEvents:function(){for(var t=0;t<c.move.length;t++)n(this.ownerDocument,c.move[t],this._onMove),n(this.ownerDocument,c.move[t],J)},_unbindDropEvents:function(){for(var t=0;t<c.end.length;t++)n(this.ownerDocument,c.end[t],this._onDrop)}}).utils={getRect:g,getOffset:f},Y}); |
{ | ||
"name": "sortable-dnd", | ||
"version": "0.4.12", | ||
"version": "0.4.13", | ||
"description": "JS library for drag-and-drop lists, supports sortable and draggable", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
76809
0
1544