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
74
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.6.1 to 0.6.2

398

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

@@ -265,3 +265,3 @@ * https://github.com/mfuu/sortable-dnd#readme

while (el = el.previousElementSibling) {
if (el.nodeName.toUpperCase() !== 'TEMPLATE' && (!selector || matches(el, selector)) && css(el, 'display') !== 'none' && el !== Sortable.dragged) {
if (el.nodeName.toUpperCase() !== 'TEMPLATE' && (!selector || matches(el, selector)) && css(el, 'display') !== 'none') {
index++;

@@ -275,3 +275,3 @@ }

* Gets nth child of el, ignoring hidden children, sortable's elements (does not ignore clone if it's visible) and non-draggable elements
* @return {HTMLElement} The child at index childNum, or null if not found
* @return {HTMLElement} The child at index childNum, or null if not found
*/

@@ -494,16 +494,28 @@ function getChild(el, childNum, selector, includeDragEl) {

Animation.prototype = {
collect: function collect(dragEl, dropEl, parentEl, except) {
collect: function collect(parentEl) {
if (!parentEl) return;
var children = Array.prototype.slice.call(parentEl.children);
var _this$_getRange = this._getRange(children, dragEl, dropEl),
start = _this$_getRange.start,
end = _this$_getRange.end;
var animations = [];
for (var i = start; i <= end; i++) {
var parentRect = getRect(parentEl),
docWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth,
docHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight,
maxWidth = Math.min(parentRect.right, docWidth),
maxHeight = Math.min(parentRect.bottom, docHeight),
children = Array.prototype.slice.call(parentEl.children),
animations = [];
for (var i = 0; i <= children.length; i++) {
var node = children[i];
if (!node || css(node, 'display') === 'none') continue;
if (node === except || node === Sortable.ghost) continue;
if (!node || node === Sortable.ghost || css(node, 'display') === 'none') {
continue;
}
var rect = getRect(node);
if (rect.bottom < 0 || rect.right < 0) {
continue;
}
// Animate only elements within the visible area
if (rect.top > maxHeight || rect.left > maxWidth) {
break;
}
animations.push({
node: node,
rect: getRect(node)
rect: rect
});

@@ -526,2 +538,5 @@ }

var rect = getRect(el);
if (rect.top === top && rect.left === left) {
return;
}
var ot = top - rect.top;

@@ -534,4 +549,3 @@ var ol = left - rect.left;

el.offsetWidth;
var duration = this.options.animation;
setTransitionDuration(el, duration);
setTransitionDuration(el, this.options.animation);
setTransform(el, 'translate3d(0px, 0px, 0px)');

@@ -543,25 +557,7 @@ clearTimeout(el.animated);

el.animated = null;
}, duration);
},
_getRange: function _getRange(children, dragEl, dropEl) {
var start = children.indexOf(dragEl);
var end = children.indexOf(dropEl);
if (start > end) {
var _ref2 = [end, start];
start = _ref2[0];
end = _ref2[1];
}
if (start < 0) {
start = end;
end = children.length - 1;
}
if (end < 0) end = children.length - 1;
return {
start: start,
end: end
};
}, this.options.animation);
}
};
var toSortable, fromSortable, dragElements, cloneElements;
var dragElements, cloneElements;
function Multiple(options) {

@@ -573,7 +569,11 @@ this.options = options || {};

destroy: function destroy() {
toSortable = fromSortable = dragElements = cloneElements = null;
dragElements = cloneElements = null;
},
active: function active() {
return !!fromSortable;
return !!dragElements;
},
setParams: function setParams(params) {
params.nodes = dragElements || [];
params.clones = cloneElements || [];
},
select: function select(element) {

@@ -593,27 +593,4 @@ toggleClass(element, this.options.selectedClass, true);

},
addSelected: function addSelected(elements) {
var _this = this;
elements.forEach(function (el) {
return _this.selectedElements.push(el);
});
},
removeSelected: function removeSelected(elements) {
this.selectedElements = this.selectedElements.filter(function (el) {
return elements.indexOf(el) < 0;
});
},
getSelectedElements: function getSelectedElements() {
return this.selectedElements;
},
getParams: function getParams() {
if (!fromSortable) return {};
var params = {};
params.nodes = dragElements;
if (cloneElements) {
params.clones = cloneElements;
}
return params;
},
getGhostElement: function getGhostElement() {
if (!fromSortable) return null;
if (!dragElements) return null;
var container = document.createElement('div');

@@ -628,4 +605,22 @@ this.selectedElements.forEach(function (node, index) {

},
toggleSelected: function toggleSelected(elements, add) {
var _this = this;
if (add) {
elements.forEach(function (el) {
return _this.selectedElements.push(el);
});
} else {
this.selectedElements = this.selectedElements.filter(function (el) {
return elements.indexOf(el) < 0;
});
}
},
toggleClass: function toggleClass$1(bool) {
if (!dragElements) return;
for (var i = 0; i < dragElements.length; i++) {
toggleClass(dragElements[i], this.options.chosenClass, bool);
}
},
toggleVisible: function toggleVisible(bool) {
if (!fromSortable) return;
if (!dragElements) return;
if (bool) {

@@ -638,5 +633,4 @@ var dragIndex = dragElements.indexOf(Sortable.dragged);

},
onDrag: function onDrag(sortable) {
var dragEl = Sortable.dragged;
if (!this.options.multiple || !this.selectedElements.length || this.selectedElements.indexOf(dragEl) < 0) {
onChoose: function onChoose() {
if (!this.options.multiple || !this.selectedElements.length || this.selectedElements.indexOf(Sortable.dragged) < 0) {
return;

@@ -648,20 +642,18 @@ }

dragElements = this.selectedElements;
fromSortable = sortable;
toSortable = sortable;
sortable.animator.collect(dragEl, null, dragEl.parentNode);
this.toggleClass(true);
},
onDrag: function onDrag(sortable) {
if (!dragElements) return;
sortable.animator.collect(Sortable.dragged.parentNode);
this._hideElements(dragElements);
sortable.animator.animate();
this.toggleClass(false);
},
onChange: function onChange(sortable) {
if (!fromSortable) return;
toSortable = sortable;
},
onDrop: function onDrop(sortable, listChanged, pullMode) {
if (!fromSortable || !toSortable) return;
fromSortable = sortable;
var dragEl = Sortable.dragged;
var cloneEl = Sortable.clone;
var dragIndex = dragElements.indexOf(dragEl);
toSortable.animator.collect(dragEl, null, dragEl.parentNode);
if (listChanged && pullMode === 'clone') {
onDrop: function onDrop(fromSortable, toSortable, pullMode) {
if (!dragElements) return;
var dragEl = Sortable.dragged,
cloneEl = Sortable.clone,
dragIndex = dragElements.indexOf(dragEl);
toSortable.animator.collect(cloneEl.parentNode);
if (fromSortable !== toSortable && pullMode === 'clone') {
css(cloneEl, 'display', 'none');

@@ -672,13 +664,13 @@ cloneElements = dragElements.map(function (node) {

this._viewElements(cloneElements, dragIndex, cloneEl);
this._viewElements(dragElements, dragIndex, dragEl);
} else {
cloneElements = null;
this._viewElements(dragElements, dragIndex, cloneEl);
}
this._viewElements(dragElements, dragIndex, dragEl);
toSortable.animator.animate();
// Recalculate selected elements
if (listChanged) {
toSortable.multiplayer.addSelected(cloneElements || dragElements);
if (fromSortable !== toSortable) {
toSortable.multiplayer.toggleSelected(cloneElements || dragElements, true);
if (pullMode !== 'clone') {
fromSortable.multiplayer.removeSelected(dragElements);
fromSortable.multiplayer.toggleSelected(dragElements, false);
}

@@ -689,8 +681,4 @@ }

var _getEvent = getEvent(dropEvent),
event = _getEvent.event,
target = _getEvent.target;
event = _getEvent.event;
if (Sortable.dragged || !this._isClick(dragEvent, event)) return;
var selectHandle = this.options.selectHandle;
if (typeof selectHandle === 'function' && !selectHandle(event)) return;
if (typeof selectHandle === 'string' && !matches(target, selectHandle)) return;
var dragIndex = this.selectedElements.indexOf(dragEl);

@@ -749,16 +737,5 @@ toggleClass(dragEl, this.options.selectedClass, dragIndex < 0);

var expando = 'Sortable' + Date.now();
var dragEl,
dropEl,
nextEl,
cloneEl,
ghostEl,
parentEl,
dragEvent,
moveEvent,
lastDropEl,
listenerNode,
lastHoverArea,
dragStartTimer,
sortables = [];
var to, from, pullMode, oldIndex, newIndex, dragIndex, targetNode;
var sortables = [];
var fromEl, dragEl, dropEl, nextEl, cloneEl, ghostEl, parentEl, dragEvent, moveEvent, lastDropEl, listenerNode, lastHoverArea, dragStartTimer;
var to, from, pullMode, oldIndex, newIndex, fromIndex, targetNode;
var _prepareGroup = function _prepareGroup(options) {

@@ -895,11 +872,8 @@ var group = {};

if (Safari && target && target.tagName.toUpperCase() === 'SELECT') return;
var _this$options = this.options,
handle = _this$options.handle,
draggable = _this$options.draggable;
dragEl = closest(target, draggable, this.el);
var element = closest(target, this.options.draggable, this.el);
// No dragging is allowed when there is no dragging element
if (!dragEl || dragEl.animated) return;
if (!element || element.animated) return;
dragEl = element;
dragEvent = event;
dragEvent.sortable = this;
listenerNode = touch ? dragEl : document;

@@ -909,2 +883,11 @@ on(listenerNode, 'mouseup', this._onDrop);

on(listenerNode, 'touchcancel', this._onDrop);
var _this$options = this.options,
handle = _this$options.handle,
selectHandle = _this$options.selectHandle;
// allow multi-drag
if (typeof selectHandle === 'function' && selectHandle(event)) return;
if (typeof selectHandle === 'string' && matches(target, selectHandle)) return;
// check handle
if (typeof handle === 'function' && !handle(event)) return;

@@ -924,6 +907,6 @@ if (typeof handle === 'string' && !matches(target, handle)) return;

dragStartTimer = setTimeout(function () {
return _this._onStart(touch);
return _this._onStart(touch, event);
}, delay);
} else {
this._onStart(touch);
this._onStart(touch, event);
}

@@ -945,3 +928,24 @@ },

},
_onStart: function _onStart(touch) {
_onStart: function _onStart(touch, event) {
var i = index(dragEl);
to = this.el;
from = this.el;
oldIndex = i;
newIndex = i;
fromIndex = i;
targetNode = dragEl;
fromEl = this.el;
cloneEl = dragEl.cloneNode(true);
parentEl = dragEl.parentNode;
pullMode = this.options.group.pull;
Sortable.clone = cloneEl;
Sortable.active = this;
Sortable.dragged = dragEl;
toggleClass(dragEl, this.options.chosenClass, true);
this.multiplayer.onChoose();
dispatchEvent({
sortable: this,
name: 'onChoose',
params: this._getParams(event)
});
if (touch) {

@@ -966,16 +970,3 @@ on(listenerNode, 'touchmove', this._nearestSortable);

_onStarted: function _onStarted() {
var i = index(dragEl);
to = this.el;
from = this.el;
oldIndex = i;
newIndex = i;
dragIndex = i;
targetNode = dragEl;
parentEl = dragEl.parentNode;
pullMode = this.options.group.pull;
cloneEl = dragEl.cloneNode(true);
toggleClass(cloneEl, this.options.chosenClass, true);
Sortable.clone = cloneEl;
Sortable.active = this;
Sortable.dragged = dragEl;
this._appendGhost();

@@ -989,4 +980,7 @@ this.multiplayer.onDrag(this);

css(dragEl, 'display', 'none');
toggleClass(dragEl, this.options.chosenClass, false);
dragEl.parentNode.insertBefore(cloneEl, dragEl);
Safari && css(document.body, 'user-select', 'none');
if (Safari) {
css(document.body, 'user-select', 'none');
}
},

@@ -996,3 +990,3 @@ _getGhostElement: function _getGhostElement() {

if (typeof customGhost === 'function') {
var selectedElements = this.multiplayer.getSelectedElements();
var selectedElements = this.multiplayer.selectedElements;
return customGhost(selectedElements.length ? selectedElements : [dragEl]);

@@ -1061,3 +1055,3 @@ }

_allowPut: function _allowPut() {
if (dragEvent.sortable.el === this.el) {
if (fromEl === this.el) {
return true;

@@ -1070,3 +1064,3 @@ } else if (!this.options.group.put) {

put = _this$options$group.put;
var fromGroup = dragEvent.sortable.options.group;
var fromGroup = fromEl[expando].options.group;
return put.join && put.indexOf(fromGroup.name) > -1 || fromGroup.name && name && fromGroup.name === name;

@@ -1122,24 +1116,47 @@ }

_onInsert: function _onInsert(event) {
var target = dropEl || cloneEl;
parentEl = dropEl ? dropEl.parentNode : this.el;
from[expando].animator.collect(cloneEl, null, cloneEl.parentNode, cloneEl);
this.animator.collect(null, target, parentEl, cloneEl);
this.multiplayer.onChange(this);
var target = dropEl || cloneEl,
cloneTo = pullMode === 'clone' && this.el !== fromEl && from === fromEl,
cloneBack = pullMode === 'clone' && this.el === fromEl && from !== fromEl;
to = this.el;
oldIndex = index(cloneEl);
newIndex = index(target);
targetNode = target;
parentEl = dropEl ? dropEl.parentNode : this.el;
from[expando].animator.collect(cloneEl.parentNode);
this.animator.collect(parentEl);
// show dragEl before clone to another list
// no need to trigger 'onRemove' when clone to another list
if (pullMode === 'clone' && this.el !== dragEvent.sortable.el && from === dragEvent.sortable.el) {
this.animator.collect(dragEl, cloneEl, dragEl.parentNode);
if (cloneTo) {
css(dragEl, 'display', '');
if (!dragEvent.sortable.options.group.revertDrag) {
dragEl.parentNode.insertBefore(dragEl, cloneEl);
fromEl[expando].multiplayer.toggleVisible(true);
if (!fromEl[expando].options.group.revertDrag) {
from.insertBefore(dragEl, cloneEl);
}
dragEvent.sortable.multiplayer.toggleVisible(true);
this.animator.animate();
}
// hide dragEl when returning to the original list
if (cloneBack) {
oldIndex = index(dragEl);
css(dragEl, 'display', 'none');
this.multiplayer.toggleVisible(false);
}
if (dropEl) {
parentEl.insertBefore(cloneEl, lastHoverArea < 0 ? dropEl : dropEl.nextSibling);
} else {
parentEl.appendChild(cloneEl);
}
newIndex = index(cloneEl);
if (cloneTo && fromEl[expando].options.group.revertDrag) {
dispatchEvent({
sortable: fromEl[expando],
name: 'onChange',
params: this._getParams(event, {
to: fromEl,
target: dragEl,
newIndex: fromIndex,
revertDrag: true
})
});
}
if (!cloneTo) {
dispatchEvent({
sortable: from[expando],

@@ -1150,14 +1167,13 @@ name: 'onRemove',

}
if (dropEl) {
parentEl.insertBefore(cloneEl, dropEl);
} else {
parentEl.appendChild(cloneEl);
if (cloneBack && dropEl !== dragEl) {
dispatchEvent({
sortable: this,
name: 'onChange',
params: this._getParams(event, {
from: fromEl,
backToOrigin: true
})
});
}
// hide dragEl when returning to the original list
// no need to trigger 'onAdd' when clone back to the original list
if (pullMode === 'clone' && this.el === dragEvent.sortable.el) {
css(dragEl, 'display', 'none');
dragEvent.sortable.multiplayer.toggleVisible(false);
} else {
if (!cloneBack) {
dispatchEvent({

@@ -1176,8 +1192,7 @@ sortable: this,

parentEl = dropEl.parentNode;
this.animator.collect(cloneEl, dropEl, parentEl);
this.multiplayer.onChange(this);
oldIndex = index(cloneEl);
newIndex = index(dropEl);
targetNode = dropEl;
this.animator.collect(parentEl);
parentEl.insertBefore(cloneEl, nextEl);
newIndex = index(cloneEl);
dispatchEvent({

@@ -1199,5 +1214,16 @@ sortable: this,

off(listenerNode, 'touchcancel', this._onDrop);
if (dragEl && dragEvent && moveEvent) {
this._onEnd(event);
} else if (this.options.multiple) {
toggleClass(dragEl, this.options.chosenClass, false);
if (fromEl) {
from = fromEl;
oldIndex = fromIndex;
if (targetNode === cloneEl) targetNode = dragEl;
this.multiplayer.toggleClass(false);
dispatchEvent({
sortable: this,
name: 'onUnchoose',
params: this._getParams(event)
});
moveEvent && this._onEnd(event);
}
if (!moveEvent && this.options.multiple) {
this.multiplayer.onSelect(dragEvent, event, dragEl, this);

@@ -1210,17 +1236,22 @@ }

this.autoScroller.destroy();
_nulling();
this._nulling();
},
_onEnd: function _onEnd(event) {
from = dragEvent.sortable.el;
oldIndex = dragIndex;
var listChanged = from !== to;
var params = this._getParams(event);
this.multiplayer.onDrop(from[expando], to[expando], pullMode);
// swap real drag element to the current drop position
if (this.options.swapOnDrop && (pullMode !== 'clone' || !listChanged)) {
if (this.options.swapOnDrop && (pullMode !== 'clone' || from === to)) {
parentEl.insertBefore(dragEl, cloneEl);
}
if (targetNode === cloneEl) targetNode = dragEl;
this.multiplayer.onDrop(from[expando], listChanged, pullMode);
var params = this._getParams(event);
if (listChanged) {
if (pullMode !== 'clone' || from === to || this.multiplayer.active()) {
cloneEl && cloneEl.parentNode && cloneEl.parentNode.removeChild(cloneEl);
} else {
toggleClass(cloneEl, this.options.chosenClass, false);
}
css(dragEl, 'display', '');
if (Safari) {
css(document.body, 'user-select', '');
}
if (from !== to) {
dispatchEvent({

@@ -1237,11 +1268,5 @@ sortable: from[expando],

});
if (pullMode !== 'clone' || !listChanged || this.multiplayer.active()) {
parentEl.removeChild(cloneEl);
} else {
toggleClass(cloneEl, this.options.chosenClass, false);
}
css(dragEl, 'display', '');
Safari && css(document.body, 'user-select', '');
},
_getParams: function _getParams(event) {
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var evt = Object.create(null);

@@ -1257,15 +1282,13 @@ evt.event = event;

evt.pullMode = pullMode;
evt.relative = targetNode === dragEl ? 0 : sort(targetNode, cloneEl);
var multiParams = this.multiplayer.getParams();
if (multiParams.nodes) {
evt.nodes = multiParams.nodes;
}
if (multiParams.clones) {
evt.clones = multiParams.clones;
}
this.multiplayer.setParams(evt);
Object.assign(evt, params);
evt.relative = evt.target === dragEl ? 0 : sort(evt.target, cloneEl);
return evt;
},
_nulling: function _nulling() {
to = from = fromEl = dragEl = dropEl = nextEl = cloneEl = ghostEl = parentEl = pullMode = oldIndex = newIndex = fromIndex = dragEvent = moveEvent = targetNode = lastDropEl = listenerNode = lastHoverArea = dragStartTimer = Sortable.clone = Sortable.ghost = Sortable.active = Sortable.dragged = null;
},
// ========================================= Public Methods =========================================
destroy: function destroy() {
_nulling();
this._nulling();
this._cancelStart();

@@ -1298,8 +1321,5 @@ off(this.el, 'touchstart', this._onDrag);

getSelectedElements: function getSelectedElements() {
return this.multiplayer.getSelectedElements();
return this.multiplayer.selectedElements;
}
};
var _nulling = function _nulling() {
to = from = dragEl = dropEl = nextEl = cloneEl = ghostEl = parentEl = pullMode = oldIndex = newIndex = dragIndex = dragEvent = moveEvent = targetNode = lastDropEl = listenerNode = lastHoverArea = dragStartTimer = Sortable.clone = Sortable.ghost = Sortable.active = Sortable.dragged = null;
};
Sortable.utils = {

@@ -1306,0 +1326,0 @@ on: on,

@@ -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 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 H={capture:!1,passive:!1},L=/\s+/g;function t(t){if("undefined"!=typeof window&&window.navigator)return!!navigator.userAgent.match(t)}var B,e,s,l,r,a,h=t(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),F=t(/Edge/i),W=t(/safari/i)&&!t(/chrome/i)&&!t(/android/i),k=(B=!1,document.addEventListener("checkIfSupportPassive",null,{get passive(){return B=!0}}),B),z="undefined"==typeof window||"undefined"==typeof document?{}:(e=window.getComputedStyle(document.documentElement,"")||["-moz-hidden-iframe"],e=(Array.prototype.slice.call(e).join("").match(/-(moz|webkit|ms)-/)||""===e.OLink&&["","o"])[1],{dom:"WebKit|Moz|MS|O".match(new RegExp("("+e+")","i"))[1],lowercase:e,css:"-"+e+"-",js:e[0].toUpperCase()+e.substr(1)});function j(t,e){t.style["".concat(z.css,"transition-duration")]=null==e?"":"".concat(e,"ms")}function c(t,e){t.style["".concat(z.css,"transform")]=e?"".concat(e):""}function u(t,e,n){window.addEventListener?t.addEventListener(e,n,!(!k&&h)&&H):window.attachEvent?t.attachEvent("on"+e,n):t["on"+e]=n}function n(t,e,n){window.removeEventListener?t.removeEventListener(e,n,!(!k&&h)&&H):window.detachEvent?t.detachEvent("on"+e,n):t["on"+e]=null}function G(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 V(){return document.scrollingElement||document.documentElement}function f(t,e,n){if(t.getBoundingClientRect||t===window){var o,i,s,l,r,a,c=t!==window&&t.parentNode&&t!==V()?(i=(o=t.getBoundingClientRect()).top,s=o.left,l=o.bottom,r=o.right,a=o.height,o.width):(s=i=0,l=window.innerHeight,r=window.innerWidth,a=window.innerHeight,window.innerWidth);if(e&&t!==window){n=n||t.parentNode;do{if(n&&n.getBoundingClientRect){var h=n.getBoundingClientRect();i-=h.top+parseInt(v(n,"border-top-width")),s-=h.left+parseInt(v(n,"border-left-width")),l=i+o.height,r=s+o.width;break}}while(n=n.parentNode)}return{top:i,left:s,bottom:l,right:r,width:c,height:a}}}function d(t,e,n,o){if(t){n=n||document;do{if(null==e){var i=Array.prototype.slice.call(n.children),s=i.indexOf(t);if(-1<s)return i[s];for(var l=0;l<i.length;l++)if(q(t,i[l]))return i[l]}else if((">"!==e[0]||t.parentNode===n)&&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 p(t,e){var n=0;if(!t||!t.parentNode)return-1;for(;t=t.previousElementSibling;)"TEMPLATE"===t.nodeName.toUpperCase()||e&&!g(t,e)||"none"===v(t,"display")||t===P.dragged||n++;return n}function U(t,e,n,o){for(var i=0,s=0,l=t.children;i<l.length;){if(l[i]!==P.ghost&&"none"!==v(l[i],"display")&&d(l[i],n,t,!1)&&(o||l[i]!==P.dragged)){if(s===e)return l[i];s++}i++}return null}function K(t,e){var n,o=v(t),i=parseInt(o.width)-parseInt(o.paddingLeft)-parseInt(o.paddingRight)-parseInt(o.borderLeftWidth)-parseInt(o.borderRightWidth),s=U(t,0,e),t=U(t,1,e),e=s&&v(s),l=t&&v(t),r=e&&parseInt(e.marginLeft)+parseInt(e.marginRight)+f(s).width,a=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+f(t).width,c=F||h?"cssFloat":"float";return"flex"===o.display?"column"===o.flexDirection||"column-reverse"===o.flexDirection?"vertical":"horizontal":"grid"===o.display?o.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal":s&&e.float&&"none"!==e.float?(n="left"===e.float?"left":"right",!t||"both"!==l.clear&&l.clear!==n?"horizontal":"vertical"):s&&("block"===e.display||"flex"===e.display||"table"===e.display||"grid"===e.display||i<=r&&"none"===o[c]||t&&"none"===o[c]&&i<r+a)?"vertical":"horizontal"}function m(t,e,n){var o;t&&e&&(t.classList?t.classList[n?"add":"remove"](e):(o=(" "+t.className+" ").replace(L," ").replace(" "+e+" "," "),t.className=(o+(n?" "+e:"")).replace(L," ")))}function g(t,e){if(e&&(">"===e[0]&&(e=e.substring(1)),t))try{if(t.matches)return t.matches(e);if(t.msMatchesSelector)return t.msMatchesSelector(e);if(t.webkitMatchesSelector)return t.webkitMatchesSelector(e)}catch(t){return}}function 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 y(t,e){e=e;t=(t=t).compareDocumentPosition?t.compareDocumentPosition(e):t.contains?(t!=e&&t.contains(e)&&16)+(t!=e&&e.contains(t)&&8)+(0<=t.sourceIndex&&0<=e.sourceIndex?(t.sourceIndex<e.sourceIndex&&4)+(t.sourceIndex>e.sourceIndex&&2):1)+0:0;return 2===t?1:4===t?-1:0}function Z(t){void 0!==t.preventDefault&&t.cancelable&&t.preventDefault()}function w(t){var e=t.sortable,n=t.name,t=t.params,e=e.options[n];"function"==typeof e&&e(Object.assign({},t))}function J(t){this.options=t,this.autoScrollAnimationFrame=null}function Q(t){this.options=t,this.animations=[]}function $(t){this.options=t||{},this.selectedElements=[]}window.requestAnimationFrame||(window.requestAnimationFrame=function(t){return setTimeout(t,17)}),window.cancelAnimationFrame||(window.cancelAnimationFrame=function(t){clearTimeout(t)}),J.prototype={destroy:function(){null!=this.autoScrollAnimationFrame&&(cancelAnimationFrame(this.autoScrollAnimationFrame),this.autoScrollAnimationFrame=null)},update:function(t,e,n){var o=this;cancelAnimationFrame(this.autoScrollAnimationFrame),this.autoScrollAnimationFrame=requestAnimationFrame(function(){e&&n&&o.autoScroll(t,n),o.update(t,e,n)})},autoScroll:function(t,e){var n,o,i,s,l,r,a,c,h,u,d,p,m;t&&void 0!==e.clientX&&void 0!==e.clientY&&(u=f(t))&&(n=e.clientX,e=e.clientY,o=u.top,i=u.right,s=u.bottom,l=u.left,p=u.height,u=u.width,e<o||i<n||s<e||n<l||(r=(a=this.options).scrollThreshold,a=a.scrollSpeed,d=t.scrollTop,c=t.scrollLeft,m=t.scrollHeight,h=0<d&&o<=e&&e<=o+r,u=c+u<t.scrollWidth&&n<=i&&i-r<=n,d=d+p<m&&e<=s&&s-r<=e,(m=p=0)<c&&l<=n&&n<=l+r&&(p=Math.floor(Math.max(-1,(n-l)/r-1)*a.x)),u&&(p=Math.ceil(Math.min(1,(n-i)/r+1)*a.x)),h&&(m=Math.floor(Math.max(-1,(e-o)/r-1)*a.y)),(m=d?Math.ceil(Math.min(1,(e-s)/r+1)*a.y):m)&&(t.scrollTop+=m),p&&(t.scrollLeft+=p)))}},Q.prototype={collect:function(t,e,n,o){if(n){for(var i=Array.prototype.slice.call(n.children),n=this._getRange(i,t,e),t=n.start,s=n.end,l=[],r=t;r<=s;r++){var a=i[r];a&&"none"!==v(a,"display")&&a!==o&&a!==P.ghost&&l.push({node:a,rect:f(a)})}this.animations.push(l)}},animate:function(){for(var t=this.animations.pop(),e=0,n=t.length;e<n;e++){var o=t[e],i=o.node,o=o.rect;this._excute(i,o)}},_excute:function(t,e){var n=e.left,e=e.top,o=f(t),e=e-o.top,n=n-o.left,o=(j(t),c(t,"translate3d(".concat(n,"px, ").concat(e,"px, 0)")),t.offsetWidth,this.options.animation);j(t,o),c(t,"translate3d(0px, 0px, 0px)"),clearTimeout(t.animated),t.animated=setTimeout(function(){j(t),c(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}}},$.prototype={destroy:function(){s=l=r=a=null},active:function(){return!!l},select:function(t){m(t,this.options.selectedClass,!0),this.selectedElements.push(t),this.selectedElements.sort(y)},deselect:function(t){var e=this.selectedElements.indexOf(t);-1<e&&(m(t,this.options.selectedClass,!1),this.selectedElements.splice(e,1))},addSelected:function(t){var e=this;t.forEach(function(t){return e.selectedElements.push(t)})},removeSelected:function(e){this.selectedElements=this.selectedElements.filter(function(t){return e.indexOf(t)<0})},getSelectedElements:function(){return this.selectedElements},getParams:function(){var t;return l?((t={}).nodes=r,a&&(t.clones=a),t):{}},getGhostElement:function(){var n;return l?(n=document.createElement("div"),this.selectedElements.forEach(function(t,e){t=t.cloneNode(!0);t.style="position: absolute;left: 0;top: 0;bottom: 0;right: 0;opacity: ".concat(0===e?1:.5,";z-index: ").concat(e,";"),n.appendChild(t)}),n):null},toggleVisible:function(t){l&&(t?(t=r.indexOf(P.dragged),this._viewElements(r,t,P.dragged)):this._hideElements(r))},onDrag:function(t){var e=P.dragged;!this.options.multiple||!this.selectedElements.length||this.selectedElements.indexOf(e)<0||(this.selectedElements.sort(y),r=this.selectedElements,(s=l=t).animator.collect(e,null,e.parentNode),this._hideElements(r),t.animator.animate())},onChange:function(t){l&&(s=t)},onDrop:function(t,e,n){var o,i;l&&s&&(l=t,t=P.clone,i=r.indexOf(o=P.dragged),s.animator.collect(o,null,o.parentNode),e&&"clone"===n?(v(t,"display","none"),a=r.map(function(t){return t.cloneNode(!0)}),this._viewElements(a,i,t)):a=null,this._viewElements(r,i,o),s.animator.animate(),e)&&(s.multiplayer.addSelected(a||r),"clone"!==n)&&l.multiplayer.removeSelected(r)},onSelect:function(t,e,n,o){var e=G(e),i=e.event,e=e.target;P.dragged||!this._isClick(t,i)||"function"==typeof(t=this.options.selectHandle)&&!t(i)||"string"==typeof t&&!g(e,t)||(e=this.selectedElements.indexOf(n),m(n,this.options.selectedClass,e<0),t={from:o.el,event:i,node:n,index:p(n)},e<0?(this.selectedElements.push(n),w({sortable:o,name:"onSelect",params:t})):(this.selectedElements.splice(e,1),w({sortable:o,name:"onDeselect",params:t})),this.selectedElements.sort(y))},_viewElements:function(t,e,n){for(var o,i=0;i<t.length;i++)v(t[i],"display",""),i<e?n.parentNode.insertBefore(t[i],n):(o=0<i?t[i-1]:n,n.parentNode.insertBefore(t[i],o.nextSibling))},_hideElements:function(t){for(var e=0;e<t.length;e++)t[e]!=P.dragged&&v(t[e],"display","none")},_isClick:function(t,e){var n=e.clientX-t.clientX,e=e.clientY-t.clientY,t=Math.sqrt(n*n+e*e);return 0<=t&&t<=1}};var b,S,tt,_,E,x,D,C,M,N,T,et,o,I,i,O,X,nt,Y,A="Sortable"+Date.now(),ot=[],it=function(t){var e={},n=t.group;n&&"object"==R(n)||(n={name:n,pull:!0,put:!0,revertDrag:!0}),e.name=n.name,e.pull=n.pull,e.put=n.put,e.revertDrag=n.revertDrag,t.group=e};function P(t,e){if(!t||!t.nodeType||1!==t.nodeType)throw"Sortable-dnd: `el` must be an HTMLElement, not ".concat({}.toString.call(t));(t[A]=this).el=t,this.options=e=Object.assign({},e);var n,o,i={store:null,disabled:!1,group:"",animation:150,draggable:null,handle:null,multiple:!1,selectHandle:null,customGhost:null,direction:function(){return K(t,e.draggable)},autoScroll:!0,scrollThreshold:55,scrollSpeed:{x:10,y:10},delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,ghostClass:"",ghostStyle:{},chosenClass:"",selectedClass:"",swapOnDrop:!0,fallbackOnBody:!1,supportTouch:"ontouchstart"in window,emptyInsertThreshold:-5};for(n in i)n in this.options||(this.options[n]=i[n]);for(o in it(e),this)"_"===o.charAt(0)&&"function"==typeof this[o]&&(this[o]=this[o].bind(this));var s=this.options.supportTouch;u(t,s?"touchstart":"mousedown",this._onDrag),ot.push(t),this.autoScroller=new J(this.options),this.multiplayer=new $(this.options),this.animator=new Q(this.options)}P.prototype={constructor:P,_onDrag:function(t){var e,n,o,i,s=this;b||this.options.disabled||!this.options.group.pull||/mousedown|pointerdown/.test(t.type)&&0!==t.button||(t=G(t),e=t.touch,i=t.event,t=t.target,W&&t&&"SELECT"===t.tagName.toUpperCase())||(n=(o=this.options).handle,o=o.draggable,(b=d(t,o,this.el))&&!b.animated&&((D=i).sortable=this,u(N=e?b:document,"mouseup",this._onDrop),u(N,"touchend",this._onDrop),u(N,"touchcancel",this._onDrop),"function"!=typeof n||n(i))&&("string"!=typeof n||g(t,n))&&(i=(o=this.options).delay,t=o.delayOnTouchOnly,!i||t&&!e||F||h?this._onStart(e):(u(this.el.ownerDocument,"touchmove",this._delayMoveHandler),u(this.el.ownerDocument,"mousemove",this._delayMoveHandler),u(this.el.ownerDocument,"mouseup",this._cancelStart),u(this.el.ownerDocument,"touchend",this._cancelStart),u(this.el.ownerDocument,"touchcancel",this._cancelStart),et=setTimeout(function(){return s._onStart(e)},i))))},_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(et),n(this.el.ownerDocument,"touchmove",this._delayMoveHandler),n(this.el.ownerDocument,"mousemove",this._delayMoveHandler),n(this.el.ownerDocument,"mouseup",this._cancelStart),n(this.el.ownerDocument,"touchend",this._cancelStart),n(this.el.ownerDocument,"touchcancel",this._cancelStart)},_onStart:function(t){u(N,t?"touchmove":"mousemove",this._nearestSortable);try{document.selection?setTimeout(function(){return document.selection.empty()},0):window.getSelection().removeAllRanges()}catch(t){}},_onStarted:function(){var t=p(b);o=this.el,I=this.el,nt=X=O=t,x=(Y=b).parentNode,i=this.options.group.pull,m(_=b.cloneNode(!0),this.options.chosenClass,!0),P.clone=_,P.active=this,P.dragged=b,this._appendGhost(),this.multiplayer.onDrag(this),w({sortable:this,name:"onDrag",params:this._getParams(D)}),v(b,"display","none"),b.parentNode.insertBefore(_,b),W&&v(document.body,"user-select","none")},_getGhostElement:function(){var t=this.options.customGhost;return"function"==typeof t?t((t=this.multiplayer.getSelectedElements()).length?t:[b]):this.multiplayer.getGhostElement()||b},_appendGhost:function(){if(!E){var t,e=this.options,n=e.fallbackOnBody,o=e.ghostClass,e=e.ghostStyle,n=n?document.body:this.el,i=this._getGhostElement(),i=(m(E=i.cloneNode(!0),o,!0),f(b)),s=Object.assign({position:"fixed",top:i.top,left:i.left,width:i.width,height:i.height,minWidth:i.width,minHeight:i.height,opacity:"0.8",overflow:"hidden","z-index":"100000","box-sizing":"border-box","pointer-events":"none"},e);for(t in s)v(E,t,s[t]);o="none",E.style["".concat(z.css,"transition")]=o?"none"===o?"none":"".concat(o):"",c(E,"translate3d(0px, 0px, 0px)"),P.ghost=E,n.appendChild(E);e=(D.clientX-i.left)/parseInt(E.style.width)*100,o=(D.clientY-i.top)/parseInt(E.style.height)*100;v(E,"transform-origin","".concat(e,"% ").concat(o,"%")),v(E,"transform","translateZ(0)"),v(E,"will-change","transform")}},_nearestSortable:function(t){var e,n,o,i,s,l,r;Z(t),!D||!b||(o=C||D,i=(e=t).clientX,e=e.clientY,n=i-o.clientX,o=e-o.clientY,void 0!==i&&void 0!==e&&Math.abs(n)<=0&&Math.abs(o)<=0)||(C||this._onStarted(),e=(i=G(t)).event,n=i.target,o=(C=e).clientX-D.clientX,t=e.clientY-D.clientY,c(E,"translate3d(".concat(o,"px, ").concat(t,"px, 0)")),this.options.autoScroll&&(i=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 V();if(o||e)return n;o=!0}}}while(n=n.parentNode)}return V()}(n,!0),this.autoScroller.update(i,D,C)),s=e.clientX,l=e.clientY,ot.some(function(t){var e,n,o=t[A].options.emptyInsertThreshold;if(null!=o)return n=f(t),e=s>=n.left-o&&s<=n.right+o,n=l>=n.top-o&&l<=n.bottom+o,e&&n?r=t:void 0}),r&&r[A]._onMove(e,n))},_allowPut:function(){var t,e,n;return D.sortable.el===this.el||!!this.options.group.put&&(t=(e=this.options.group).name,e=e.put,n=D.sortable.options.group,e.join&&-1<e.indexOf(n.name)||n.name&&t&&n.name===t)},_allowSwap:function(){var t=y(_,S),e=(tt=t<0?S.nextSibling:S,f(S)),n="function"==typeof this.options.direction?this.options.direction.call(C,b,this):this.options.direction,o="vertical"===n,i=o?C.clientY:C.clientX,n=S["vertical"===n?"offsetHeight":"offsetWidth"],i=i>=(o?e.top:e.left)&&i<(o?e.bottom:e.right)-n/2?-1:1;return M!==S?(T=i,!0):T!==i&&((T=i)<0?0<t:t<0)},_onMove:function(t,e){var n,o,i;this._allowPut()&&(w({sortable:this,name:"onMove",params:this._getParams(t)}),this.el===I||e!==this.el&&function(t,e){for(var n=t.lastElementChild;n&&(n===P.ghost||"none"===v(n,"display")||e&&!g(n,e));)n=n.previousElementSibling;return n}(this.el)?(S=d(e,this.options.draggable,this.el))&&!S.animated&&this._allowSwap()&&(M=(S===_||q(S,_)||(this.el!==I?this._onInsert(t):(n=t,o=x,i=i||f(o),n.clientX<=i.right&&n.clientX>=i.left&&n.clientY>=i.top&&n.clientY<=i.bottom&&e===x||this._onChange(t))),S)):(S=M=null,this._onInsert(t)))},_onInsert:function(t){var e=S||_;x=S?S.parentNode:this.el,I[A].animator.collect(_,null,_.parentNode,_),this.animator.collect(null,e,x,_),this.multiplayer.onChange(this),o=this.el,O=p(_),X=p(e),Y=e,"clone"===i&&this.el!==D.sortable.el&&I===D.sortable.el?(this.animator.collect(b,_,b.parentNode),v(b,"display",""),D.sortable.options.group.revertDrag||b.parentNode.insertBefore(b,_),D.sortable.multiplayer.toggleVisible(!0),this.animator.animate()):w({sortable:I[A],name:"onRemove",params:this._getParams(t)}),S?x.insertBefore(_,S):x.appendChild(_),"clone"===i&&this.el===D.sortable.el?(v(b,"display","none"),D.sortable.multiplayer.toggleVisible(!1)):w({sortable:this,name:"onAdd",params:this._getParams(t)}),I[A].animator.animate(),this.animator.animate(),I=this.el},_onChange:function(t){S!==b&&(x=S.parentNode,this.animator.collect(_,S,x),this.multiplayer.onChange(this),O=p(_),X=p(S),Y=S,x.insertBefore(_,tt),w({sortable:this,name:"onChange",params:this._getParams(t)}),this.animator.animate(),I=this.el)},_onDrop:function(t){Z(t),this._cancelStart(),n(N,"touchmove",this._nearestSortable),n(N,"mousemove",this._nearestSortable),n(N,"mouseup",this._onDrop),n(N,"touchend",this._onDrop),n(N,"touchcancel",this._onDrop),b&&D&&C?this._onEnd(t):this.options.multiple&&this.multiplayer.onSelect(D,t,b,this),E&&E.parentNode&&E.parentNode.removeChild(E),this.multiplayer.destroy(),this.autoScroller.destroy(),st()},_onEnd:function(t){I=D.sortable.el,O=nt;var e=I!==o,t=(!this.options.swapOnDrop||"clone"===i&&e||x.insertBefore(b,_),Y===_&&(Y=b),this.multiplayer.onDrop(I[A],e,i),this._getParams(t));e&&w({sortable:I[A],name:"onDrop",params:t}),w({sortable:o[A],name:"onDrop",params:t}),"clone"!==i||!e||this.multiplayer.active()?x.removeChild(_):m(_,this.options.chosenClass,!1),v(b,"display",""),W&&v(document.body,"user-select","")},_getParams:function(t){var e=Object.create(null),t=(e.event=t,e.to=o,e.from=I,e.node=b,e.clone=_,e.target=Y,e.oldIndex=O,e.newIndex=X,e.pullMode=i,e.relative=Y===b?0:y(Y,_),this.multiplayer.getParams());return t.nodes&&(e.nodes=t.nodes),t.clones&&(e.clones=t.clones),e},destroy:function(){st(),this._cancelStart(),n(this.el,"touchstart",this._onDrag),n(this.el,"mousedown",this._onDrag),ot.splice(ot.indexOf(this.el),1),this.el[A]=this.animator=this.multiplayer=this.autoScroller=null},option:function(t,e){if(void 0===e)return this.options[t];this.options[t]=e,this.animator.options[t]=e,this.multiplayer.options[t]=e,this.autoScroller.options[t]=e,"group"===t&&it(this.options)},select:function(t){this.multiplayer.select(t)},deselect:function(t){this.multiplayer.deselect(t)},getSelectedElements:function(){return this.multiplayer.getSelectedElements()}};var st=function(){o=I=b=S=tt=_=E=x=i=O=X=nt=D=C=Y=M=N=T=et=P.clone=P.ghost=P.active=P.dragged=null};return P.utils={on:u,off:n,css:v,index:p,closest:d,getRect:f,toggleClass:m,detectDirection:K},P.get=function(t){return t[A]},P.create=function(t,e){return new P(t,e)},P});
!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 o(t){return(o="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},W=/\s+/g;function t(t){if("undefined"!=typeof window&&window.navigator)return!!navigator.userAgent.match(t)}var R,e,r,l,h=t(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),k=t(/Edge/i),B=t(/safari/i)&&!t(/chrome/i)&&!t(/android/i),F=(R=!1,document.addEventListener("checkIfSupportPassive",null,{get passive(){return R=!0}}),R),j="undefined"==typeof window||"undefined"==typeof document?{}:(e=window.getComputedStyle(document.documentElement,"")||["-moz-hidden-iframe"],e=(Array.prototype.slice.call(e).join("").match(/-(moz|webkit|ms)-/)||""===e.OLink&&["","o"])[1],{dom:"WebKit|Moz|MS|O".match(new RegExp("("+e+")","i"))[1],lowercase:e,css:"-"+e+"-",js:e[0].toUpperCase()+e.substr(1)});function z(t,e){t.style["".concat(j.css,"transition-duration")]=null==e?"":"".concat(e,"ms")}function a(t,e){t.style["".concat(j.css,"transform")]=e?"".concat(e):""}function c(t,e,n){window.addEventListener?t.addEventListener(e,n,!(!F&&h)&&L):window.attachEvent?t.attachEvent("on"+e,n):t["on"+e]=n}function n(t,e,n){window.removeEventListener?t.removeEventListener(e,n,!(!F&&h)&&L):window.detachEvent?t.detachEvent("on"+e,n):t["on"+e]=null}function G(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 V(){return document.scrollingElement||document.documentElement}function f(t,e,n){if(t.getBoundingClientRect||t===window){var o,i,s,r,l,a,c=t!==window&&t.parentNode&&t!==V()?(i=(o=t.getBoundingClientRect()).top,s=o.left,r=o.bottom,l=o.right,a=o.height,o.width):(s=i=0,r=window.innerHeight,l=window.innerWidth,a=window.innerHeight,window.innerWidth);if(e&&t!==window){n=n||t.parentNode;do{if(n&&n.getBoundingClientRect){var h=n.getBoundingClientRect();i-=h.top+parseInt(m(n,"border-top-width")),s-=h.left+parseInt(m(n,"border-left-width")),r=i+o.height,l=s+o.width;break}}while(n=n.parentNode)}return{top:i,left:s,bottom:r,right:l,width:c,height:a}}}function u(t,e,n,o){if(t){n=n||document;do{if(null==e){var i=Array.prototype.slice.call(n.children),s=i.indexOf(t);if(-1<s)return i[s];for(var r=0;r<i.length;r++)if(q(t,i[r]))return i[r]}else if((">"!==e[0]||t.parentNode===n)&&p(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 i(t,e){var n=0;if(!t||!t.parentNode)return-1;for(;t=t.previousElementSibling;)"TEMPLATE"===t.nodeName.toUpperCase()||e&&!p(t,e)||"none"===m(t,"display")||n++;return n}function U(t,e,n,o){for(var i=0,s=0,r=t.children;i<r.length;){if(r[i]!==H.ghost&&"none"!==m(r[i],"display")&&u(r[i],n,t,!1)&&(o||r[i]!==H.dragged)){if(s===e)return r[i];s++}i++}return null}function K(t,e){var n,o=m(t),i=parseInt(o.width)-parseInt(o.paddingLeft)-parseInt(o.paddingRight)-parseInt(o.borderLeftWidth)-parseInt(o.borderRightWidth),s=U(t,0,e),t=U(t,1,e),e=s&&m(s),r=t&&m(t),l=e&&parseInt(e.marginLeft)+parseInt(e.marginRight)+f(s).width,a=r&&parseInt(r.marginLeft)+parseInt(r.marginRight)+f(t).width,c=k||h?"cssFloat":"float";return"flex"===o.display?"column"===o.flexDirection||"column-reverse"===o.flexDirection?"vertical":"horizontal":"grid"===o.display?o.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal":s&&e.float&&"none"!==e.float?(n="left"===e.float?"left":"right",!t||"both"!==r.clear&&r.clear!==n?"horizontal":"vertical"):s&&("block"===e.display||"flex"===e.display||"table"===e.display||"grid"===e.display||i<=l&&"none"===o[c]||t&&"none"===o[c]&&i<l+a)?"vertical":"horizontal"}function d(t,e,n){var o;t&&e&&(t.classList?t.classList[n?"add":"remove"](e):(o=(" "+t.className+" ").replace(W," ").replace(" "+e+" "," "),t.className=(o+(n?" "+e:"")).replace(W," ")))}function p(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 m(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){e=e;t=(t=t).compareDocumentPosition?t.compareDocumentPosition(e):t.contains?(t!=e&&t.contains(e)&&16)+(t!=e&&e.contains(t)&&8)+(0<=t.sourceIndex&&0<=e.sourceIndex?(t.sourceIndex<e.sourceIndex&&4)+(t.sourceIndex>e.sourceIndex&&2):1)+0:0;return 2===t?1:4===t?-1:0}function Z(t){void 0!==t.preventDefault&&t.cancelable&&t.preventDefault()}function g(t){var e=t.sortable,n=t.name,t=t.params,e=e.options[n];"function"==typeof e&&e(Object.assign({},t))}function J(t){this.options=t,this.autoScrollAnimationFrame=null}function Q(t){this.options=t,this.animations=[]}function $(t){this.options=t||{},this.selectedElements=[]}window.requestAnimationFrame||(window.requestAnimationFrame=function(t){return setTimeout(t,17)}),window.cancelAnimationFrame||(window.cancelAnimationFrame=function(t){clearTimeout(t)}),J.prototype={destroy:function(){null!=this.autoScrollAnimationFrame&&(cancelAnimationFrame(this.autoScrollAnimationFrame),this.autoScrollAnimationFrame=null)},update:function(t,e,n){var o=this;cancelAnimationFrame(this.autoScrollAnimationFrame),this.autoScrollAnimationFrame=requestAnimationFrame(function(){e&&n&&o.autoScroll(t,n),o.update(t,e,n)})},autoScroll:function(t,e){var n,o,i,s,r,l,a,c,h,u,d,p,m;t&&void 0!==e.clientX&&void 0!==e.clientY&&(u=f(t))&&(n=e.clientX,e=e.clientY,o=u.top,i=u.right,s=u.bottom,r=u.left,p=u.height,u=u.width,e<o||i<n||s<e||n<r||(l=(a=this.options).scrollThreshold,a=a.scrollSpeed,d=t.scrollTop,c=t.scrollLeft,m=t.scrollHeight,h=0<d&&o<=e&&e<=o+l,u=c+u<t.scrollWidth&&n<=i&&i-l<=n,d=d+p<m&&e<=s&&s-l<=e,(m=p=0)<c&&r<=n&&n<=r+l&&(p=Math.floor(Math.max(-1,(n-r)/l-1)*a.x)),u&&(p=Math.ceil(Math.min(1,(n-i)/l+1)*a.x)),h&&(m=Math.floor(Math.max(-1,(e-o)/l-1)*a.y)),(m=d?Math.ceil(Math.min(1,(e-s)/l+1)*a.y):m)&&(t.scrollTop+=m),p&&(t.scrollLeft+=p)))}},Q.prototype={collect:function(t){if(t){for(var e=f(t),n=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,o=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,i=Math.min(e.right,n),s=Math.min(e.bottom,o),r=Array.prototype.slice.call(t.children),l=[],a=0;a<=r.length;a++){var c=r[a];if(c&&c!==H.ghost&&"none"!==m(c,"display")){var h=f(c);if(!(h.bottom<0||h.right<0)){if(h.top>s||h.left>i)break;l.push({node:c,rect:h})}}}this.animations.push(l)}},animate:function(){for(var t=this.animations.pop(),e=0,n=t.length;e<n;e++){var o=t[e],i=o.node,o=o.rect;this._excute(i,o)}},_excute:function(t,e){var n=e.left,e=e.top,o=f(t);o.top===e&&o.left===n||(e=e-o.top,n=n-o.left,z(t),a(t,"translate3d(".concat(n,"px, ").concat(e,"px, 0)")),t.offsetWidth,z(t,this.options.animation),a(t,"translate3d(0px, 0px, 0px)"),clearTimeout(t.animated),t.animated=setTimeout(function(){z(t),a(t,""),t.animated=null},this.options.animation))}},$.prototype={destroy:function(){r=l=null},active:function(){return!!r},setParams:function(t){t.nodes=r||[],t.clones=l||[]},select:function(t){d(t,this.options.selectedClass,!0),this.selectedElements.push(t),this.selectedElements.sort(s)},deselect:function(t){var e=this.selectedElements.indexOf(t);-1<e&&(d(t,this.options.selectedClass,!1),this.selectedElements.splice(e,1))},getGhostElement:function(){var n;return r?(n=document.createElement("div"),this.selectedElements.forEach(function(t,e){t=t.cloneNode(!0);t.style="position: absolute;left: 0;top: 0;bottom: 0;right: 0;opacity: ".concat(0===e?1:.5,";z-index: ").concat(e,";"),n.appendChild(t)}),n):null},toggleSelected:function(e,t){var n=this;t?e.forEach(function(t){return n.selectedElements.push(t)}):this.selectedElements=this.selectedElements.filter(function(t){return e.indexOf(t)<0})},toggleClass:function(t){if(r)for(var e=0;e<r.length;e++)d(r[e],this.options.chosenClass,t)},toggleVisible:function(t){r&&(t?(t=r.indexOf(H.dragged),this._viewElements(r,t,H.dragged)):this._hideElements(r))},onChoose:function(){!this.options.multiple||!this.selectedElements.length||this.selectedElements.indexOf(H.dragged)<0||(this.selectedElements.sort(s),r=this.selectedElements,this.toggleClass(!0))},onDrag:function(t){r&&(t.animator.collect(H.dragged.parentNode),this._hideElements(r),t.animator.animate(),this.toggleClass(!1))},onDrop:function(t,e,n){var o,i,s;r&&(i=H.clone,s=r.indexOf(o=H.dragged),e.animator.collect(i.parentNode),t!==e&&"clone"===n?(m(i,"display","none"),l=r.map(function(t){return t.cloneNode(!0)}),this._viewElements(l,s,i),this._viewElements(r,s,o)):this._viewElements(r,s,i),e.animator.animate(),t!==e)&&(e.multiplayer.toggleSelected(l||r,!0),"clone"!==n)&&t.multiplayer.toggleSelected(r,!1)},onSelect:function(t,e,n,o){var e=G(e).event;!H.dragged&&this._isClick(t,e)&&(t=this.selectedElements.indexOf(n),d(n,this.options.selectedClass,t<0),e={from:o.el,event:e,node:n,index:i(n)},t<0?(this.selectedElements.push(n),g({sortable:o,name:"onSelect",params:e})):(this.selectedElements.splice(t,1),g({sortable:o,name:"onDeselect",params:e})),this.selectedElements.sort(s))},_viewElements:function(t,e,n){for(var o,i=0;i<t.length;i++)m(t[i],"display",""),i<e?n.parentNode.insertBefore(t[i],n):(o=0<i?t[i-1]:n,n.parentNode.insertBefore(t[i],o.nextSibling))},_hideElements:function(t){for(var e=0;e<t.length;e++)t[e]!=H.dragged&&m(t[e],"display","none")},_isClick:function(t,e){var n=e.clientX-t.clientX,e=e.clientY-t.clientY,t=Math.sqrt(n*n+e*e);return 0<=t&&t<=1}};var v,y,w,tt,b,_,S,E,x,C,D,M,et,N,T,I,O,P,X,Y,A="Sortable"+Date.now(),nt=[],ot=function(t){var e={},n=t.group;n&&"object"==o(n)||(n={name:n,pull:!0,put:!0,revertDrag:!0}),e.name=n.name,e.pull=n.pull,e.put=n.put,e.revertDrag=n.revertDrag,t.group=e};function H(t,e){if(!t||!t.nodeType||1!==t.nodeType)throw"Sortable-dnd: `el` must be an HTMLElement, not ".concat({}.toString.call(t));(t[A]=this).el=t,this.options=e=Object.assign({},e);var n,o,i={store:null,disabled:!1,group:"",animation:150,draggable:null,handle:null,multiple:!1,selectHandle:null,customGhost:null,direction:function(){return K(t,e.draggable)},autoScroll:!0,scrollThreshold:55,scrollSpeed:{x:10,y:10},delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,ghostClass:"",ghostStyle:{},chosenClass:"",selectedClass:"",swapOnDrop:!0,fallbackOnBody:!1,supportTouch:"ontouchstart"in window,emptyInsertThreshold:-5};for(n in i)n in this.options||(this.options[n]=i[n]);for(o in ot(e),this)"_"===o.charAt(0)&&"function"==typeof this[o]&&(this[o]=this[o].bind(this));var s=this.options.supportTouch;c(t,s?"touchstart":"mousedown",this._onDrag),nt.push(t),this.autoScroller=new J(this.options),this.multiplayer=new $(this.options),this.animator=new Q(this.options)}return H.prototype={constructor:H,_onDrag:function(t){var e,n,o,i,s=this;y||this.options.disabled||!this.options.group.pull||/mousedown|pointerdown/.test(t.type)&&0!==t.button||(t=G(t),e=t.touch,n=t.event,t=t.target,B&&t&&"SELECT"===t.tagName.toUpperCase())||!(o=u(t,this.options.draggable,this.el))||o.animated||(y=o,E=n,c(D=e?y:document,"mouseup",this._onDrop),c(D,"touchend",this._onDrop),c(D,"touchcancel",this._onDrop),i=(o=this.options).handle,"function"==typeof(o=o.selectHandle)&&o(n))||"string"==typeof o&&p(t,o)||"function"==typeof i&&!i(n)||"string"==typeof i&&!p(t,i)||(t=(o=this.options).delay,i=o.delayOnTouchOnly,!t||i&&!e||k||h?this._onStart(e,n):(c(this.el.ownerDocument,"touchmove",this._delayMoveHandler),c(this.el.ownerDocument,"mousemove",this._delayMoveHandler),c(this.el.ownerDocument,"mouseup",this._cancelStart),c(this.el.ownerDocument,"touchend",this._cancelStart),c(this.el.ownerDocument,"touchcancel",this._cancelStart),et=setTimeout(function(){return s._onStart(e,n)},t)))},_delayMoveHandler:function(t){t=t.touches?t.touches[0]:t;Math.max(Math.abs(t.clientX-E.clientX),Math.abs(t.clientY-E.clientY))>=Math.floor(this.options.touchStartThreshold/(window.devicePixelRatio||1))&&this._cancelStart()},_cancelStart:function(){clearTimeout(et),n(this.el.ownerDocument,"touchmove",this._delayMoveHandler),n(this.el.ownerDocument,"mousemove",this._delayMoveHandler),n(this.el.ownerDocument,"mouseup",this._cancelStart),n(this.el.ownerDocument,"touchend",this._cancelStart),n(this.el.ownerDocument,"touchcancel",this._cancelStart)},_onStart:function(t,e){var n=i(y);N=this.el,T=this.el,X=P=O=n,Y=y,v=this.el,b=y.cloneNode(!0),S=y.parentNode,I=this.options.group.pull,H.clone=b,H.active=this,d(H.dragged=y,this.options.chosenClass,!0),this.multiplayer.onChoose(),g({sortable:this,name:"onChoose",params:this._getParams(e)}),c(D,t?"touchmove":"mousemove",this._nearestSortable);try{document.selection?setTimeout(function(){return document.selection.empty()},0):window.getSelection().removeAllRanges()}catch(t){}},_onStarted:function(){d(b,this.options.chosenClass,!0),this._appendGhost(),this.multiplayer.onDrag(this),g({sortable:this,name:"onDrag",params:this._getParams(E)}),m(y,"display","none"),d(y,this.options.chosenClass,!1),y.parentNode.insertBefore(b,y),B&&m(document.body,"user-select","none")},_getGhostElement:function(){var t=this.options.customGhost;return"function"==typeof t?t((t=this.multiplayer.selectedElements).length?t:[y]):this.multiplayer.getGhostElement()||y},_appendGhost:function(){if(!_){var t,e=this.options,n=e.fallbackOnBody,o=e.ghostClass,e=e.ghostStyle,n=n?document.body:this.el,i=this._getGhostElement(),i=(d(_=i.cloneNode(!0),o,!0),f(y)),s=Object.assign({position:"fixed",top:i.top,left:i.left,width:i.width,height:i.height,minWidth:i.width,minHeight:i.height,opacity:"0.8",overflow:"hidden","z-index":"100000","box-sizing":"border-box","pointer-events":"none"},e);for(t in s)m(_,t,s[t]);o="none",_.style["".concat(j.css,"transition")]=o?"none"===o?"none":"".concat(o):"",a(_,"translate3d(0px, 0px, 0px)"),H.ghost=_,n.appendChild(_);e=(E.clientX-i.left)/parseInt(_.style.width)*100,o=(E.clientY-i.top)/parseInt(_.style.height)*100;m(_,"transform-origin","".concat(e,"% ").concat(o,"%")),m(_,"transform","translateZ(0)"),m(_,"will-change","transform")}},_nearestSortable:function(t){var e,n,o,i,s,r,l;Z(t),!E||!y||(o=x||E,i=(e=t).clientX,e=e.clientY,n=i-o.clientX,o=e-o.clientY,void 0!==i&&void 0!==e&&Math.abs(n)<=0&&Math.abs(o)<=0)||(x||this._onStarted(),e=(i=G(t)).event,n=i.target,o=(x=e).clientX-E.clientX,t=e.clientY-E.clientY,a(_,"translate3d(".concat(o,"px, ").concat(t,"px, 0)")),this.options.autoScroll&&(i=function(t,e){if(t&&t.getBoundingClientRect){var n=t,o=!1;do{if(n.clientWidth<n.scrollWidth||n.clientHeight<n.scrollHeight){var i=m(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 V();if(o||e)return n;o=!0}}}while(n=n.parentNode)}return V()}(n,!0),this.autoScroller.update(i,E,x)),s=e.clientX,r=e.clientY,nt.some(function(t){var e,n,o=t[A].options.emptyInsertThreshold;if(null!=o)return n=f(t),e=s>=n.left-o&&s<=n.right+o,n=r>=n.top-o&&r<=n.bottom+o,e&&n?l=t:void 0}),l&&l[A]._onMove(e,n))},_allowPut:function(){var t,e,n;return v===this.el||!!this.options.group.put&&(t=(e=this.options.group).name,e=e.put,n=v[A].options.group,e.join&&-1<e.indexOf(n.name)||n.name&&t&&n.name===t)},_allowSwap:function(){var t=s(b,w),e=(tt=t<0?w.nextSibling:w,f(w)),n="function"==typeof this.options.direction?this.options.direction.call(x,y,this):this.options.direction,o="vertical"===n,i=o?x.clientY:x.clientX,n=w["vertical"===n?"offsetHeight":"offsetWidth"],i=i>=(o?e.top:e.left)&&i<(o?e.bottom:e.right)-n/2?-1:1;return C!==w?(M=i,!0):M!==i&&((M=i)<0?0<t:t<0)},_onMove:function(t,e){var n,o,i;this._allowPut()&&(g({sortable:this,name:"onMove",params:this._getParams(t)}),this.el===T||e!==this.el&&function(t,e){for(var n=t.lastElementChild;n&&(n===H.ghost||"none"===m(n,"display")||e&&!p(n,e));)n=n.previousElementSibling;return n}(this.el)?(w=u(e,this.options.draggable,this.el))&&!w.animated&&this._allowSwap()&&(C=(w===b||q(w,b)||(this.el!==T?this._onInsert(t):(n=t,o=S,i=i||f(o),n.clientX<=i.right&&n.clientX>=i.left&&n.clientY>=i.top&&n.clientY<=i.bottom&&e===S||this._onChange(t))),w)):(w=C=null,this._onInsert(t)))},_onInsert:function(t){var e=w||b,n="clone"===I&&this.el!==v&&T===v,o="clone"===I&&this.el===v&&T!==v;N=this.el,O=i(b),Y=e,S=w?w.parentNode:this.el,T[A].animator.collect(b.parentNode),this.animator.collect(S),n&&(m(y,"display",""),v[A].multiplayer.toggleVisible(!0),v[A].options.group.revertDrag||T.insertBefore(y,b)),o&&(O=i(y),m(y,"display","none"),this.multiplayer.toggleVisible(!1)),w?S.insertBefore(b,M<0?w:w.nextSibling):S.appendChild(b),P=i(b),n&&v[A].options.group.revertDrag&&g({sortable:v[A],name:"onChange",params:this._getParams(t,{to:v,target:y,newIndex:X,revertDrag:!0})}),n||g({sortable:T[A],name:"onRemove",params:this._getParams(t)}),o&&w!==y&&g({sortable:this,name:"onChange",params:this._getParams(t,{from:v,backToOrigin:!0})}),o||g({sortable:this,name:"onAdd",params:this._getParams(t)}),T[A].animator.animate(),this.animator.animate(),T=this.el},_onChange:function(t){w!==y&&(S=w.parentNode,O=i(b),Y=w,this.animator.collect(S),S.insertBefore(b,tt),P=i(b),g({sortable:this,name:"onChange",params:this._getParams(t)}),this.animator.animate(),T=this.el)},_onDrop:function(t){Z(t),this._cancelStart(),n(D,"touchmove",this._nearestSortable),n(D,"mousemove",this._nearestSortable),n(D,"mouseup",this._onDrop),n(D,"touchend",this._onDrop),n(D,"touchcancel",this._onDrop),d(y,this.options.chosenClass,!1),v&&(T=v,O=X,Y===b&&(Y=y),this.multiplayer.toggleClass(!1),g({sortable:this,name:"onUnchoose",params:this._getParams(t)}),x)&&this._onEnd(t),!x&&this.options.multiple&&this.multiplayer.onSelect(E,t,y,this),_&&_.parentNode&&_.parentNode.removeChild(_),this.multiplayer.destroy(),this.autoScroller.destroy(),this._nulling()},_onEnd:function(t){t=this._getParams(t);this.multiplayer.onDrop(T[A],N[A],I),!this.options.swapOnDrop||"clone"===I&&T!==N||S.insertBefore(y,b),"clone"!==I||T===N||this.multiplayer.active()?b&&b.parentNode&&b.parentNode.removeChild(b):d(b,this.options.chosenClass,!1),m(y,"display",""),B&&m(document.body,"user-select",""),T!==N&&g({sortable:T[A],name:"onDrop",params:t}),g({sortable:N[A],name:"onDrop",params:t})},_getParams:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},n=Object.create(null);return n.event=t,n.to=N,n.from=T,n.node=y,n.clone=b,n.target=Y,n.oldIndex=O,n.newIndex=P,n.pullMode=I,this.multiplayer.setParams(n),Object.assign(n,e),n.relative=n.target===y?0:s(n.target,b),n},_nulling:function(){N=T=v=y=w=tt=b=_=S=I=O=P=X=E=x=Y=C=D=M=et=H.clone=H.ghost=H.active=H.dragged=null},destroy:function(){this._nulling(),this._cancelStart(),n(this.el,"touchstart",this._onDrag),n(this.el,"mousedown",this._onDrag),nt.splice(nt.indexOf(this.el),1),this.el[A]=this.animator=this.multiplayer=this.autoScroller=null},option:function(t,e){if(void 0===e)return this.options[t];this.options[t]=e,this.animator.options[t]=e,this.multiplayer.options[t]=e,this.autoScroller.options[t]=e,"group"===t&&ot(this.options)},select:function(t){this.multiplayer.select(t)},deselect:function(t){this.multiplayer.deselect(t)},getSelectedElements:function(){return this.multiplayer.selectedElements}},H.utils={on:c,off:n,css:m,index:i,closest:u,getRect:f,toggleClass:d,detectDirection:K},H.get=function(t){return t[A]},H.create=function(t,e){return new H(t,e)},H});
{
"name": "sortable-dnd",
"version": "0.6.1",
"version": "0.6.2",
"description": "JS library for drag-and-drop lists, supports sortable and draggable",

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

@@ -83,33 +83,50 @@ # sortable-dnd

},
// callback functions
// Element is chosen
onChoose: (params) => {
// see @Params
},
// Element is unchosen
onUnchoose: () => {
// see @Params
},
// Element dragging started
onDrag: (params) => {
// Triggered when drag is started
// see @Params
},
// Event when you move an item in the list or between lists
onMove: (params) => {
// Triggered when the dragged element is moving
// see @Params
},
// Element dragging is completed
onDrop: (params) => {
// Triggered when drag is completed
// see @Params
},
// Element is dropped into the current list from another
onAdd: (params) => {
// Triggered when the element is dropped into the list from another
// see @Params
},
// Element is removed from the current list into another
onRemove: (params) => {
// Triggered when the element is removed from the list into another
// see @Params
},
// Called when dragging element changes position in the current list
onChange: (params) => {
// Triggered when the dragged element changes position in the list
// see @Params
},
// Element is selected
onSelect: (params) => {
// Triggered when an element is selected by clicking the mouse
// see @Select
},
// Element is unselected
onDeselect: (params) => {
// Triggered when an element is unselected by clicking the mouse
// see @Select

@@ -131,3 +148,3 @@ },

pull: true | false | 'clone', // whether elements can be moved out of this list.
revertDrag: true | false, // revert cloned element to initial position after moving to a another list.
revertDrag: true | false, // revert drag element to initial position after moving to a another list.
}

@@ -139,3 +156,3 @@ ```

```js
{
let {
from, // previous list

@@ -153,2 +170,4 @@ to, // list, in which moved element.

relative, // Position of the drop element relative to the drag element after swap is complete.
revertDrag, // revert draged element to initial position after moving to a another list in `pull: 'clone'` & `revertDrag: true`.
backToOrigin, // dragged element go back to the original list in `pull: 'clone'`.
} = params

@@ -160,3 +179,3 @@ ```

```js
{
let {
event, // TouchEvent | MouseEvent

@@ -163,0 +182,0 @@ index, // index within parent

@@ -199,2 +199,10 @@ declare class Sortable {

relative: 0 | 1 | -1;
/**
* revert draged element to initial position after moving to a another list in `pull: 'clone'` & `revertDrag: true`.
*/
revertDrag?: boolean;
/**
* dragged element go back to the original list in `pull: 'clone'`.
*/
backToOrigin?: boolean;
}

@@ -204,3 +212,3 @@

/**
* store data
* store data.
* @example

@@ -241,3 +249,3 @@ *

* - string: '...'
* - object: { name: '...', put: true | false, pull: true | false }
* - object: { name: '...', put: true | false, pull: true | false | 'clone', revertDrag: true | false }
* @defaults `' '`

@@ -323,3 +331,3 @@ */

* distance mouse must be from empty sortable to insert drag element into it.
* @defaults `5`
* @defaults `-5`
*/

@@ -365,8 +373,18 @@ emptyInsertThreshold?: number;

/**
* Triggered when the drag is started.
* Element is chosen.
*/
onChoose?: (params: SortableEvent) => void;
/**
* Element is unchosen.
*/
onUnchoose?: (params: SortableEvent) => void;
/**
* Element dragging started.
*/
onDrag?: (params: SortableEvent) => void;
/**
* Triggered when the dragged element is moving.
* Event when you move an item in the list or between lists.
*/

@@ -376,3 +394,3 @@ onMove?: (params: SortableEvent) => void;

/**
* Triggered when the drag is completed.
* Element dragging is completed.
* The params records only the status from the drag to the drop. All operations in the process are ignored.

@@ -383,3 +401,3 @@ */

/**
* Triggered when element is dropped into the current list from another.
* Element is dropped into the current list from another.
*/

@@ -389,3 +407,3 @@ onAdd?: (params: SortableEvent) => void;

/**
* Triggered when element is removed from the current list into another.
* Element is removed from the current list into another.
*/

@@ -395,3 +413,3 @@ onRemove?: (params: SortableEvent) => void;

/**
* Triggered when the dragged element changes position in the current list.
* Called when dragging element changes position in the current list.
*/

@@ -401,3 +419,3 @@ onChange?: (params: SortableEvent) => void;

/**
* Triggered when element is selected.
* Element is selected.
*/

@@ -407,3 +425,3 @@ onSelect?: (params: SelectEvent) => void;

/**
* Triggered when element is unselected.
* Element is unselected.
*/

@@ -410,0 +428,0 @@ onDeselect?: (params: SelectEvent) => void;

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