Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sortable-dnd

Package Overview
Dependencies
Maintainers
1
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sortable-dnd - npm Package Compare versions

Comparing version 0.5.2 to 0.5.3

113

dist/sortable-dnd.js
/*!
* sortable-dnd v0.5.2
* sortable-dnd v0.5.3
* open source under the MIT license

@@ -148,5 +148,2 @@ * https://github.com/mfuu/sortable-dnd#readme

* add specified event listener
* @param {HTMLElement} el
* @param {String} event
* @param {Function} fn
*/

@@ -163,5 +160,2 @@ function on(el, event, fn) {

* remove specified event listener
* @param {HTMLElement} el
* @param {String} event
* @param {Function} fn
*/

@@ -200,5 +194,3 @@ function off(el, event, fn) {

/**
* get element's offetTop
* @param {HTMLElement} el
* @param {HTMLElement} parentEl
* get element's offetTop in given parent node
*/

@@ -221,3 +213,2 @@ function getOffset(el, parentEl) {

* get scroll element
* @param {HTMLElement} el
* @param {Boolean} includeSelf whether to include the passed element

@@ -365,4 +356,2 @@ * @returns {HTMLElement} scroll element

* Check if child element is contained in parent element
* @param {HTMLElement} el
* @param {HTMLElement} root
*/

@@ -383,5 +372,3 @@ function containes(el, root) {

* Gets the last child in the el, ignoring ghostEl or invisible elements (clones)
* @param {HTMLElement} el Parent element
* @param {selector} selector Any other elements that should be ignored
* @return {HTMLElement} The last child, ignoring ghostEl
* @return {HTMLElement|null} The last child, ignoring ghostEl
*/

@@ -398,5 +385,2 @@ function lastChild(el, helper, selector) {

* add or remove element's class
* @param {HTMLElement} el element
* @param {String} name class name
* @param {Boolean} state true: add, false: remove
*/

@@ -416,4 +400,2 @@ function toggleClass(el, name, state) {

* Check if a DOM element matches a given selector
* @param {HTMLElement} el
* @param {String} selector
* @returns

@@ -467,2 +449,8 @@ */

}
function sortableChanged(from, to) {
return from.sortable.el !== to.sortable.el;
}
function visible(el, visible) {
css(el, 'display', visible ? '' : 'none');
}
function _nextTick(fn) {

@@ -550,3 +538,3 @@ return setTimeout(fn, 0);

if (node == dragEl) return;
node.parentNode.removeChild(node);
visible(node, false);
});

@@ -572,2 +560,3 @@ sortable.animator.animate();

selectedElements[this.groupName].forEach(function (node, i) {
visible(node, true);
if (i < index) {

@@ -588,3 +577,3 @@ dragEl.parentNode.insertBefore(node, dragEl);

});
var changed = multiTo.sortable.el != multiFrom.sortable.el || this._offsetChanged(multiFrom.nodes, multiTo.nodes);
var changed = sortableChanged(multiFrom, multiTo) || this._offsetChanged(multiFrom.nodes, multiTo.nodes);
var params = _objectSpread2(_objectSpread2({}, _emits()), {}, {

@@ -594,3 +583,3 @@ changed: changed,

});
if (multiTo.sortable.el != multiFrom.sortable.el) {
if (sortableChanged(multiFrom, multiTo)) {
multiFrom.sortable._dispatchEvent('onDrop', params);

@@ -709,2 +698,3 @@ }

children.slice(start, end + 1).forEach(function (node) {
if (css(node, 'display') === 'none') return;
if (node === except || node === Sortable.helper) return;

@@ -836,2 +826,3 @@ _this.animations.push({

dropEl,
cloneEl,
downEvent,

@@ -868,5 +859,3 @@ moveEvent,

* Detects first nearest empty sortable to X and Y position using emptyInsertThreshold.
* @param {Number} x X position
* @param {Number} y Y position
* @return {HTMLElement} Element of the first found nearest Sortable
* @return {HTMLElement} Element of the first found nearest Sortable
*/

@@ -915,5 +904,5 @@ var _detectNearestSortable = function _detectNearestSortable(x, y) {

/**
* @class Sortable
* @param {HTMLElement} el group element
* @param {Object} options
* @class Sortable
* @param {HTMLElement} el container
* @param {Object} options
*/

@@ -940,3 +929,3 @@ function Sortable(el, options) {

autoScroll: true,
scrollThreshold: 25,
scrollThreshold: 55,
delay: 0,

@@ -949,2 +938,3 @@ delayOnTouchOnly: false,

selectedClass: '',
swapOnDrop: true,
fallbackOnBody: false,

@@ -994,6 +984,3 @@ stopPropagation: false,

/**
* Set/get option
* @param {string} key
* @param {any} [value]
* @returns {any}
* Get or set the option value, depending on whether the `value` is passed in
*/

@@ -1041,2 +1028,3 @@ option: function option(key, value) {

if (!dragEl || dragEl.animated) return;
cloneEl = dragEl.cloneNode(true);
this._prepareStart(touch, event);

@@ -1135,5 +1123,5 @@ },

Sortable.helper = helper.node;
// add class for drag element
toggleClass(dragEl, this.options.chosenClass, true);
visible(dragEl, false);
dragEl.parentNode.insertBefore(cloneEl, dragEl);
toggleClass(cloneEl, this.options.chosenClass, true);
Safari && css(document.body, 'user-select', 'none');

@@ -1179,4 +1167,4 @@ }

lastDropEl = dropEl;
if (dropEl === dragEl) return;
if (dropEl.animated || containes(dropEl, dragEl)) return;
if (dropEl === cloneEl) return;
if (dropEl.animated || containes(dropEl, cloneEl)) return;
}

@@ -1202,8 +1190,8 @@ if (rootEl !== from.sortable.el) {

},
_onInsert: function _onInsert( /** Event|TouchEvent */event, insert) {
var target = insert ? dragEl : dropEl;
var parentEl = insert ? rootEl : dropEl.parentNode;
from.sortable.animator.collect(dragEl, null, dragEl.parentNode, dragEl);
this.animator.collect(null, target, parentEl, dragEl);
isMultiple && this.multiplayer.onChange(dragEl, this);
_onInsert: function _onInsert( /** Event|TouchEvent */event, insertToLast) {
var target = insertToLast ? cloneEl : dropEl;
var parentEl = insertToLast ? rootEl : dropEl.parentNode;
from.sortable.animator.collect(cloneEl, null, cloneEl.parentNode, cloneEl);
this.animator.collect(null, target, parentEl, cloneEl);
isMultiple && this.multiplayer.onChange(cloneEl, this);
to = {

@@ -1219,6 +1207,6 @@ sortable: this,

}));
if (insert) {
parentEl.appendChild(dragEl);
if (insertToLast) {
parentEl.appendChild(cloneEl);
} else {
parentEl.insertBefore(dragEl, dropEl);
parentEl.insertBefore(cloneEl, dropEl);
}

@@ -1235,4 +1223,4 @@ this._dispatchEvent('onAdd', _objectSpread2(_objectSpread2({}, _emits()), {}, {

var parentEl = dropEl.parentNode;
this.animator.collect(dragEl, dropEl, parentEl);
isMultiple && this.multiplayer.onChange(dragEl, this);
this.animator.collect(cloneEl, dropEl, parentEl);
isMultiple && this.multiplayer.onChange(cloneEl, this);
to = {

@@ -1250,3 +1238,3 @@ sortable: this,

// the top value is compared first, and the left is compared if the top value is the same
var offset = getOffset(dragEl, rootEl);
var offset = getOffset(cloneEl, rootEl);
var nextEl = null;

@@ -1258,3 +1246,3 @@ if (offset.top === to.offset.top) {

}
parentEl.insertBefore(dragEl, nextEl);
parentEl.insertBefore(cloneEl, nextEl);
this.animator.animate();

@@ -1270,5 +1258,2 @@ from.group = parentEl;

autoScroller.clear();
// clear style, attrs and class
dragEl && toggleClass(dragEl, this.options.chosenClass, false);
if (dragEl && downEvent && moveEvent) {

@@ -1282,2 +1267,5 @@ this._onEnd(evt);

_onEnd: function _onEnd( /** Event|TouchEvent */evt) {
if (this.options.swapOnDrop) {
cloneEl.parentNode.insertBefore(dragEl, cloneEl);
}
from.group = downEvent.group;

@@ -1289,5 +1277,6 @@ from.sortable = downEvent.sortable;

// re-acquire the offset and rect values of the dragged element as the value after the drag is completed
to.rect = getRect(dragEl);
to.offset = getOffset(dragEl, rootEl);
var changed = to.sortable.el !== from.sortable.el || offsetChanged(from.offset, to.offset);
to.rect = getRect(cloneEl);
to.offset = getOffset(cloneEl, rootEl);
if (to.node === cloneEl) to.node = dragEl;
var changed = sortableChanged(from, to) || offsetChanged(from.offset, to.offset);
var params = _objectSpread2(_objectSpread2({}, _emits()), {}, {

@@ -1297,3 +1286,3 @@ changed: changed,

});
if (to.sortable.el !== from.sortable.el) {
if (sortableChanged(from, to)) {
from.sortable._dispatchEvent('onDrop', params);

@@ -1303,2 +1292,4 @@ }

}
visible(dragEl, true);
cloneEl.parentNode.removeChild(cloneEl);
Safari && css(document.body, 'user-select', '');

@@ -1321,3 +1312,3 @@ },

_clearState: function _clearState() {
dragEl = dropEl = downEvent = moveEvent = isMultiple = lastDropEl = dragStartTimer = Sortable.helper = null;
dragEl = dropEl = cloneEl = downEvent = moveEvent = isMultiple = lastDropEl = dragStartTimer = Sortable.helper = null;
lastPosition = {

@@ -1324,0 +1315,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 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||document.documentElement}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||"group_"+Number(Math.random().toString().slice(-3)+Date.now()).toString(32)}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,(f=d=0)<i&&c<=o&&o<=c+e&&(d=Math.floor(Math.max(-1,(o-c)/e-1)*this.speed.x)),h&&(d=Math.ceil(Math.min(1,(o-s)/e+1)*this.speed.x)),u&&(f=Math.floor(Math.max(-1,(n-a)/e-1)*this.speed.y)),(f=p?Math.ceil(Math.min(1,(n-l)/e+1)*this.speed.y):f)&&(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){this.helper&&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 r(){var t,e={from:l({},A),to:l({},j)};return T&&(t={from:l({},w),to:l({},_)},e.from=l(l({},t.from),e.from),e.to=l(l({},t.to),e.to)),e}var N,E,x,D,C,T,O,J,K={sortable:null,group:null,node:null,rect:{},offset:{}},M=[],P=new G,Q=new U,A=l({},K),j=l({},K),X={x:0,y:0},$=function(t){var e={},n=t.group;n&&"object"==R(n)||(n={name:n,pull:!0,put:!0}),e.name=n.name,e.pull=n.pull,e.put=n.put,t.group=e};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 $(e),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},option:function(t,e){var n=this.options;if(void 0===e)return n[t];n[t]=e,"group"===t&&$(n)},_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=((D=e).sortable=this,D.group=E.parentNode,(T=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(document,"touchend",this._onDrop),p(document,"touchcancel",this._onDrop),p(document,"mouseup",this._onDrop),this.options),o=r.delay,e=r.delayOnTouchOnly;if(!o||e&&!t||L||d)this._onStart(t);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);J=setTimeout(function(){return n._onStart(t)},o)}},_delayMoveHandler:function(t){t=t.touches?t.touches[0]:t;Math.max(Math.abs(t.clientX-D.clientX),Math.abs(t.clientY-D.clientY))>=Math.floor(this.options.touchStartThreshold/(window.devicePixelRatio||1))&&this._cancelStart()},_cancelStart:function(){clearTimeout(J);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(t){N=this.el,p(document,t?"touchmove":"mousemove",this._nearestSortable);try{document.selection?setTimeout(function(){document.selection.empty()},0):window.getSelection().removeAllRanges()}catch(t){}},_onTrulyStarted:function(){var t;C||(this._dispatchEvent("onDrag",l(l({},r()),{},{event:D})),T&&this.multiplayer.onTrulyStarted(E,this),t=T?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"))},_nearestSortable:function(t){var e,n,o,i,r,a,s;this._preventEvent(t),D&&E&&(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||(n=(e=I(t)).event,o=e.target,r=n.clientX,a=n.clientY,M.some(function(t){var e,n,o=t[y].options.emptyInsertThreshold;if(o)return n=g(t,{parent:!0}),e=r>=n.left-o&&r<=n.right+o,n=a>=n.top-o&&a<=n.bottom+o,e&&n?s=t:void 0}),i=s,this._onTrulyStarted(),C=n,P.move(n.clientX-D.clientX,n.clientY-D.clientY),this._autoScroll(o),i&&(N=i)[y]._onMove(n,o)))},_allowPut:function(){var t,e;return D.sortable.el===this.el||!!this.options.group.put&&(t=this.options.group.name,(e=D.sortable.options.group).name)&&t&&e.name===t},_onMove:function(t,e){if(this._dispatchEvent("onMove",l(l({},r()),{},{event:t})),this._allowPut()){if(x=W(e,this.options.draggable,N,!1)){if(x===O)return;if((O=x)===E)return;if(x.animated||z(x,E))return}N!==A.sortable.el?e!==N&&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}(N,P.node)?x&&this._onInsert(t,!1):this._onInsert(t,!0):x&&this._onChange(t)}},_autoScroll:function(t){var t=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()}(t,!0),e=this.options,n=e.autoScroll,e=e.scrollThreshold;n&&Q.update(t,e,D,C)},_onInsert:function(t,e){var n=e?E:x,o=e?N:x.parentNode;A.sortable.animator.collect(E,null,E.parentNode,E),this.animator.collect(null,n,o,E),T&&this.multiplayer.onChange(E,this),j={sortable:this,group:o,node:n,rect:g(n),offset:f(n,N)},A.sortable._dispatchEvent("onRemove",l(l({},r()),{},{event:t})),e?o.appendChild(E):o.insertBefore(E,x),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=x.parentNode,t=(this.animator.collect(E,x,e),T&&this.multiplayer.onChange(E,this),j={sortable:this,group:e,node:x,rect:g(x),offset:f(x,N)},this._dispatchEvent("onChange",l(l({},r()),{},{event:t})),f(E,N)),n=null,n=t.top===j.offset.top?t.left<j.offset.left?x.nextSibling:x:t.top<j.offset.top?x.nextSibling:x;e.insertBefore(E,n),this.animator.animate(),A.group=e,A.sortable=this},_onDrop:function(t){this._unbindMoveEvents(),this._unbindDropEvents(),this._preventEvent(t),this._cancelStart(),Q.clear(),E&&v(E,this.options.chosenClass,!1),E&&D&&C?this._onEnd(t):this.options.multiple&&this.multiplayer.select(t,E,N,l({},A)),this._clearState()},_onEnd:function(t){var e;A.group=D.group,A.sortable=D.sortable,T?this.multiplayer.onDrop(t,E,N,D,r):(j.rect=g(E),j.offset=f(E,N),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=x=D=C=T=O=J=Y.helper=null,X={x:0,y:0},A=j=l({},K),P.destroy()},_unbindMoveEvents:function(){for(var t=0;t<c.move.length;t++)n(document,c.move[t],this._nearestSortable)},_unbindDropEvents:function(){for(var t=0;t<c.end.length;t++)n(document,c.end[t],this._onDrop)}}).utils={getRect:g,getOffset:f},Y.get=function(t){return t[y]},Y.create=function(t,e){return new Y(t,e)},Y});
!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 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||document.documentElement}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"!==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: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)&&V(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 q(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 V(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,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")}}function s(t,e){return t.sortable.el!==e.sortable.el}function y(t,e){v(t,"display",e?"":"none")}var b="Sortable"+Date.now(),o={sortable:null,nodes:[]},w=l({},o),_=l({},o),S={};function Z(t){this.options=t||{},this.groupName=t.group.name||"group_"+Number(Math.random().toString().slice(-3)+Date.now()).toString(32)}function G(){this.autoScrollAnimationFrame=null,this.speed={x:10,y:10}}function J(t){this.options=t,this.animations=[]}function K(){this.helper=null,this.distance={x:0,y:0}}Z.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),q(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&&y(t,!1)}),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){y(t,!0),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)}}),s(w,_)||this._offsetChanged(w.nodes,_.nodes)),i=l(l({},i()),{},{changed:o,event:t});s(w,_)&&w.sortable._dispatchEvent("onDrop",i),_.sortable._dispatchEvent("onDrop",i),_.sortable.animator.animate()},_offsetChanged:function(t,n){return!!t.find(function(e){return U(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)}),G.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,(f=d=0)<i&&c<=o&&o<=c+e&&(d=Math.floor(Math.max(-1,(o-c)/e-1)*this.speed.x)),h&&(d=Math.ceil(Math.min(1,(o-s)/e+1)*this.speed.x)),u&&(f=Math.floor(Math.max(-1,(n-a)/e-1)*this.speed.y)),(f=p?Math.ceil(Math.min(1,(n-l)/e+1)*this.speed.y):f)&&(t.scrollTop+=f),d&&(t.scrollLeft+=d)))}},J.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){"none"!==v(t,"display")&&t!==o&&t!==B.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}}},K.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){this.helper&&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),q(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)v(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;v(this.helper,"transform-origin","".concat(a,"% ").concat(t,"%")),v(this.helper,"transform","translateZ(0)"),v(this.helper,"will-change","transform")}}};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 N,E,x,D,O,T,C,Q,$,tt={sortable:null,group:null,node:null,rect:{},offset:{}},M=[],P=new K,et=new G,A=l({},tt),j=l({},tt),X={x:0,y:0},nt=function(t){var e={},n=t.group;n&&"object"==R(n)||(n={name:n,pull:!0,put:!0}),e.name=n.name,e.pull=n.pull,e.put=n.put,t.group=e};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={disabled:!1,group:"",animation:150,multiple:!1,draggable:null,handle:null,onDrag:null,onMove:null,onDrop:null,onChange:null,autoScroll:!0,scrollThreshold:55,delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,ghostClass:"",ghostStyle:{},chosenClass:"",selectedClass:"",swapOnDrop:!0,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),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 Z(this.options),this.animator=new J(this.options)}return(B.prototype={constructor:B,destroy:function(){this._dispatchEvent("destroy",this),this.el[b]=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},option:function(t,e){var n=this.options;if(void 0===e)return n[t];n[t]=e,"group"===t&&nt(n)},_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||V(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&&(D=E.cloneNode(!0),this._prepareStart(n,o))}}}},_prepareStart:function(t,e){var n=this,o=E.parentNode,i=((O=e).sortable=this,O.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(document,"touchend",this._onDrop),p(document,"touchcancel",this._onDrop),p(document,"mouseup",this._onDrop),this.options),o=r.delay,e=r.delayOnTouchOnly;if(!o||e&&!t||L||d)this._onStart(t);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);$=setTimeout(function(){return n._onStart(t)},o)}},_delayMoveHandler:function(t){t=t.touches?t.touches[0]:t;Math.max(Math.abs(t.clientX-O.clientX),Math.abs(t.clientY-O.clientY))>=Math.floor(this.options.touchStartThreshold/(window.devicePixelRatio||1))&&this._cancelStart()},_cancelStart:function(){clearTimeout($);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(t){N=this.el,p(document,t?"touchmove":"mousemove",this._nearestSortable);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:O})),C&&this.multiplayer.onTrulyStarted(E,this),t=C?this.multiplayer.getHelper():E,P.init(A.rect,t,this.el,this.options),B.helper=P.node,y(E,!1),E.parentNode.insertBefore(D,E),q(D,this.options.chosenClass,!0),a&&v(document.body,"user-select","none"))},_nearestSortable:function(t){var e,n,o,i,r,a,s;this._preventEvent(t),O&&E&&(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||(n=(e=I(t)).event,o=e.target,r=n.clientX,a=n.clientY,M.some(function(t){var e,n,o=t[b].options.emptyInsertThreshold;if(o)return n=g(t,{parent:!0}),e=r>=n.left-o&&r<=n.right+o,n=a>=n.top-o&&a<=n.bottom+o,e&&n?s=t:void 0}),i=s,this._onTrulyStarted(),T=n,P.move(n.clientX-O.clientX,n.clientY-O.clientY),this._autoScroll(o),i&&(N=i)[b]._onMove(n,o)))},_allowPut:function(){var t,e;return O.sortable.el===this.el||!!this.options.group.put&&(t=this.options.group.name,(e=O.sortable.options.group).name)&&t&&e.name===t},_onMove:function(t,e){if(this._dispatchEvent("onMove",l(l({},r()),{},{event:t})),this._allowPut()){if(x=W(e,this.options.draggable,N,!1)){if(x===Q)return;if((Q=x)===D)return;if(x.animated||z(x,D))return}N!==A.sortable.el?e!==N&&function(t,e,n){for(var o=t.lastElementChild;o&&(o===e||"none"===v(o,"display")||n&&!V(o,n));)o=o.previousElementSibling;return o}(N,P.node)?x&&this._onInsert(t,!1):this._onInsert(t,!0):x&&this._onChange(t)}},_autoScroll:function(t){var t=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 m();if(o||e)return n;o=!0}}}while(n=n.parentNode)}return m()}(t,!0),e=this.options,n=e.autoScroll,e=e.scrollThreshold;n&&et.update(t,e,O,T)},_onInsert:function(t,e){var n=e?D:x,o=e?N:x.parentNode;A.sortable.animator.collect(D,null,D.parentNode,D),this.animator.collect(null,n,o,D),C&&this.multiplayer.onChange(D,this),j={sortable:this,group:o,node:n,rect:g(n),offset:f(n,N)},A.sortable._dispatchEvent("onRemove",l(l({},r()),{},{event:t})),e?o.appendChild(D):o.insertBefore(D,x),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=x.parentNode,t=(this.animator.collect(D,x,e),C&&this.multiplayer.onChange(D,this),j={sortable:this,group:e,node:x,rect:g(x),offset:f(x,N)},this._dispatchEvent("onChange",l(l({},r()),{},{event:t})),f(D,N)),n=null,n=t.top===j.offset.top?t.left<j.offset.left?x.nextSibling:x:t.top<j.offset.top?x.nextSibling:x;e.insertBefore(D,n),this.animator.animate(),A.group=e,A.sortable=this},_onDrop:function(t){this._unbindMoveEvents(),this._unbindDropEvents(),this._preventEvent(t),this._cancelStart(),et.clear(),E&&O&&T?this._onEnd(t):this.options.multiple&&this.multiplayer.select(t,E,N,l({},A)),this._clearState()},_onEnd:function(t){var e;this.options.swapOnDrop&&D.parentNode.insertBefore(E,D),A.group=O.group,A.sortable=O.sortable,C?this.multiplayer.onDrop(t,E,N,O,r):(j.rect=g(D),j.offset=f(D,N),j.node===D&&(j.node=E),e=s(A,j)||U(A.offset,j.offset),e=l(l({},r()),{},{changed:e,event:t}),s(A,j)&&A.sortable._dispatchEvent("onDrop",e),j.sortable._dispatchEvent("onDrop",e)),y(E,!0),D.parentNode.removeChild(D),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(){E=x=D=O=T=C=Q=$=B.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(document,c.move[t],this._nearestSortable)},_unbindDropEvents:function(){for(var t=0;t<c.end.length;t++)n(document,c.end[t],this._onDrop)}}).utils={getRect:g,getOffset:f},B.get=function(t){return t[b]},B.create=function(t,e){return new B(t,e)},B});
{
"name": "sortable-dnd",
"version": "0.5.2",
"version": "0.5.3",
"description": "JS library for drag-and-drop lists, supports sortable and draggable",

@@ -5,0 +5,0 @@ "main": "dist/sortable-dnd.min.js",

@@ -1,2 +0,2 @@

[![npm](https://img.shields.io/npm/v/sortable-dnd.svg)](https://www.npmjs.com/package/sortable-dnd) [![npm](https://img.shields.io/npm/dt/sortable-dnd.svg)](https://npm-stat.com/charts.html?package=sortable-dnd) [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE)
[![npm](https://img.shields.io/npm/v/sortable-dnd.svg)](https://www.npmjs.com/package/sortable-dnd) [![npm](https://img.shields.io/npm/dm/sortable-dnd.svg)](https://npm-stat.com/charts.html?package=sortable-dnd) [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE)

@@ -79,2 +79,3 @@

| `destroy()` | Manually clear all the state of the component, using this method the component will not be draggable |
| `option(key, value?)` | Get or set the option value, depending on whether the `value` is passed in |

@@ -113,3 +114,3 @@

| `autoScroll` | `Boolean` | `true` | Automatic scrolling when moving to the edge of the container |
| `scrollThreshold` | `Number` | `25` | Threshold to trigger autoscroll |
| `scrollThreshold` | `Number` | `55` | Threshold to trigger autoscroll |
| `delay` | `Number` | `0` | Time in milliseconds to define when the sorting should start |

@@ -119,1 +120,2 @@ | `delayOnTouchOnly`| `Boolean` | `false` | Only delay if user is using touch |

| `stopPropagation` | `Boolean` | `false` | The `stopPropagation()` method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases |
| `swapOnDrop` | `Boolean` | `true` | When the value is false, the dragged element will return to the starting position of the drag |

@@ -192,2 +192,8 @@ type SortableState = {

stopPropagation?: Boolean;
/**
* When the value is false, the dragged element will return to the starting position of the drag.
* @defaults `true`
*/
swapOnDrop?: Boolean;
};

@@ -194,0 +200,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc