|
@@ -1,5 +1,5 @@
|
|
|
/**!
|
|
|
- * Sortable 1.10.2
|
|
|
+ * Sortable 1.14.0
|
|
|
* @author RubaXa <[email protected]>
|
|
|
* @author owenm <[email protected]>
|
|
|
* @license MIT
|
|
@@ -8,9 +8,49 @@
|
|
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
|
typeof define === 'function' && define.amd ? define(factory) :
|
|
|
(global = global || self, global.Sortable = factory());
|
|
|
-}(this, function () { 'use strict';
|
|
|
+}(this, (function () { 'use strict';
|
|
|
+
|
|
|
+ function ownKeys(object, enumerableOnly) {
|
|
|
+ var keys = Object.keys(object);
|
|
|
+
|
|
|
+ if (Object.getOwnPropertySymbols) {
|
|
|
+ var symbols = Object.getOwnPropertySymbols(object);
|
|
|
+
|
|
|
+ if (enumerableOnly) {
|
|
|
+ symbols = symbols.filter(function (sym) {
|
|
|
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ keys.push.apply(keys, symbols);
|
|
|
+ }
|
|
|
+
|
|
|
+ return keys;
|
|
|
+ }
|
|
|
+
|
|
|
+ function _objectSpread2(target) {
|
|
|
+ for (var i = 1; i < arguments.length; i++) {
|
|
|
+ var source = arguments[i] != null ? arguments[i] : {};
|
|
|
+
|
|
|
+ if (i % 2) {
|
|
|
+ ownKeys(Object(source), true).forEach(function (key) {
|
|
|
+ _defineProperty(target, key, source[key]);
|
|
|
+ });
|
|
|
+ } else if (Object.getOwnPropertyDescriptors) {
|
|
|
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
|
+ } else {
|
|
|
+ ownKeys(Object(source)).forEach(function (key) {
|
|
|
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return target;
|
|
|
+ }
|
|
|
|
|
|
function _typeof(obj) {
|
|
|
+ "@babel/helpers - typeof";
|
|
|
+
|
|
|
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
|
|
_typeof = function (obj) {
|
|
|
return typeof obj;
|
|
@@ -57,25 +97,6 @@
|
|
|
return _extends.apply(this, arguments);
|
|
|
}
|
|
|
|
|
|
- function _objectSpread(target) {
|
|
|
- for (var i = 1; i < arguments.length; i++) {
|
|
|
- var source = arguments[i] != null ? arguments[i] : {};
|
|
|
- var ownKeys = Object.keys(source);
|
|
|
-
|
|
|
- if (typeof Object.getOwnPropertySymbols === 'function') {
|
|
|
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
|
|
|
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
|
- }));
|
|
|
- }
|
|
|
-
|
|
|
- ownKeys.forEach(function (key) {
|
|
|
- _defineProperty(target, key, source[key]);
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- return target;
|
|
|
- }
|
|
|
-
|
|
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
if (source == null) return {};
|
|
|
var target = {};
|
|
@@ -113,32 +134,43 @@
|
|
|
}
|
|
|
|
|
|
function _toConsumableArray(arr) {
|
|
|
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
|
|
|
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
|
}
|
|
|
|
|
|
function _arrayWithoutHoles(arr) {
|
|
|
- if (Array.isArray(arr)) {
|
|
|
- for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
|
|
|
-
|
|
|
- return arr2;
|
|
|
- }
|
|
|
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
|
}
|
|
|
|
|
|
function _iterableToArray(iter) {
|
|
|
- if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
|
|
|
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
|
+ }
|
|
|
+
|
|
|
+ function _unsupportedIterableToArray(o, minLen) {
|
|
|
+ if (!o) return;
|
|
|
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
|
+ var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
|
+ if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
|
+ if (n === "Map" || n === "Set") return Array.from(o);
|
|
|
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
|
+ }
|
|
|
+
|
|
|
+ function _arrayLikeToArray(arr, len) {
|
|
|
+ if (len == null || len > arr.length) len = arr.length;
|
|
|
+
|
|
|
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
|
+
|
|
|
+ return arr2;
|
|
|
}
|
|
|
|
|
|
function _nonIterableSpread() {
|
|
|
- throw new TypeError("Invalid attempt to spread non-iterable instance");
|
|
|
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
|
}
|
|
|
|
|
|
- var version = "1.10.2";
|
|
|
+ var version = "1.14.0";
|
|
|
|
|
|
function userAgent(pattern) {
|
|
|
if (typeof window !== 'undefined' && window.navigator) {
|
|
|
- return !!
|
|
|
- /*@__PURE__*/
|
|
|
- navigator.userAgent.match(pattern);
|
|
|
+ return !! /*@__PURE__*/navigator.userAgent.match(pattern);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -314,7 +346,7 @@
|
|
|
if (!el.getBoundingClientRect && el !== window) return;
|
|
|
var elRect, top, left, bottom, right, height, width;
|
|
|
|
|
|
- if (el !== window && el !== getWindowScrollingElement()) {
|
|
|
+ if (el !== window && el.parentNode && el !== getWindowScrollingElement()) {
|
|
|
elRect = el.getBoundingClientRect();
|
|
|
top = elRect.top;
|
|
|
left = elRect.left;
|
|
@@ -419,13 +451,13 @@
|
|
|
*/
|
|
|
|
|
|
|
|
|
- function getChild(el, childNum, options) {
|
|
|
+ function getChild(el, childNum, options, includeDragEl) {
|
|
|
var currentChild = 0,
|
|
|
i = 0,
|
|
|
children = el.children;
|
|
|
|
|
|
while (i < children.length) {
|
|
|
- if (children[i].style.display !== 'none' && children[i] !== Sortable.ghost && children[i] !== Sortable.dragged && closest(children[i], options.draggable, el, false)) {
|
|
|
+ if (children[i].style.display !== 'none' && children[i] !== Sortable.ghost && (includeDragEl || children[i] !== Sortable.dragged) && closest(children[i], options.draggable, el, false)) {
|
|
|
if (currentChild === childNum) {
|
|
|
return children[i];
|
|
|
}
|
|
@@ -643,7 +675,7 @@
|
|
|
rect: getRect(child)
|
|
|
});
|
|
|
|
|
|
- var fromRect = _objectSpread({}, animationStates[animationStates.length - 1].rect); // If animating: compensate for current animation
|
|
|
+ var fromRect = _objectSpread2({}, animationStates[animationStates.length - 1].rect); // If animating: compensate for current animation
|
|
|
|
|
|
|
|
|
if (child.thisAnimationDuration) {
|
|
@@ -754,7 +786,7 @@
|
|
|
target.animatingX = !!translateX;
|
|
|
target.animatingY = !!translateY;
|
|
|
css(target, 'transform', 'translate3d(' + translateX + 'px,' + translateY + 'px,0)');
|
|
|
- repaint(target); // repaint
|
|
|
+ this.forRepaintDummy = repaint(target); // repaint
|
|
|
|
|
|
css(target, 'transition', 'transform ' + duration + 'ms' + (this.options.easing ? ' ' + this.options.easing : ''));
|
|
|
css(target, 'transform', 'translate3d(0,0,0)');
|
|
@@ -792,6 +824,11 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ plugins.forEach(function (p) {
|
|
|
+ if (p.pluginName === plugin.pluginName) {
|
|
|
+ throw "Sortable: Cannot mount plugin ".concat(plugin.pluginName, " more than once");
|
|
|
+ }
|
|
|
+ });
|
|
|
plugins.push(plugin);
|
|
|
},
|
|
|
pluginEvent: function pluginEvent(eventName, sortable, evt) {
|
|
@@ -808,7 +845,7 @@
|
|
|
if (!sortable[plugin.pluginName]) return; // Fire global events if it exists in this sortable
|
|
|
|
|
|
if (sortable[plugin.pluginName][eventNameGlobal]) {
|
|
|
- sortable[plugin.pluginName][eventNameGlobal](_objectSpread({
|
|
|
+ sortable[plugin.pluginName][eventNameGlobal](_objectSpread2({
|
|
|
sortable: sortable
|
|
|
}, evt));
|
|
|
} // Only fire plugin event if plugin is enabled in this sortable,
|
|
@@ -816,7 +853,7 @@
|
|
|
|
|
|
|
|
|
if (sortable.options[plugin.pluginName] && sortable[plugin.pluginName][eventName]) {
|
|
|
- sortable[plugin.pluginName][eventName](_objectSpread({
|
|
|
+ sortable[plugin.pluginName][eventName](_objectSpread2({
|
|
|
sortable: sortable
|
|
|
}, evt));
|
|
|
}
|
|
@@ -908,7 +945,7 @@
|
|
|
evt.originalEvent = originalEvent;
|
|
|
evt.pullMode = putSortable ? putSortable.lastPutMode : undefined;
|
|
|
|
|
|
- var allEventProperties = _objectSpread({}, extraEventProperties, PluginManager.getEventProperties(name, sortable));
|
|
|
+ var allEventProperties = _objectSpread2(_objectSpread2({}, extraEventProperties), PluginManager.getEventProperties(name, sortable));
|
|
|
|
|
|
for (var option in allEventProperties) {
|
|
|
evt[option] = allEventProperties[option];
|
|
@@ -923,12 +960,14 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ var _excluded = ["evt"];
|
|
|
+
|
|
|
var pluginEvent = function pluginEvent(eventName, sortable) {
|
|
|
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
|
originalEvent = _ref.evt,
|
|
|
- data = _objectWithoutProperties(_ref, ["evt"]);
|
|
|
+ data = _objectWithoutProperties(_ref, _excluded);
|
|
|
|
|
|
- PluginManager.pluginEvent.bind(Sortable)(eventName, sortable, _objectSpread({
|
|
|
+ PluginManager.pluginEvent.bind(Sortable)(eventName, sortable, _objectSpread2({
|
|
|
dragEl: dragEl,
|
|
|
parentEl: parentEl,
|
|
|
ghostEl: ghostEl,
|
|
@@ -964,7 +1003,7 @@
|
|
|
};
|
|
|
|
|
|
function _dispatchEvent(info) {
|
|
|
- dispatchEvent(_objectSpread({
|
|
|
+ dispatchEvent(_objectSpread2({
|
|
|
putSortable: putSortable,
|
|
|
cloneEl: cloneEl,
|
|
|
targetEl: dragEl,
|
|
@@ -1073,13 +1112,13 @@
|
|
|
_detectNearestEmptySortable = function _detectNearestEmptySortable(x, y) {
|
|
|
var ret;
|
|
|
sortables.some(function (sortable) {
|
|
|
- if (lastChild(sortable)) return;
|
|
|
+ var threshold = sortable[expando].options.emptyInsertThreshold;
|
|
|
+ if (!threshold || lastChild(sortable)) return;
|
|
|
var rect = getRect(sortable),
|
|
|
- threshold = sortable[expando].options.emptyInsertThreshold,
|
|
|
insideHorizontally = x >= rect.left - threshold && x <= rect.right + threshold,
|
|
|
insideVertically = y >= rect.top - threshold && y <= rect.bottom + threshold;
|
|
|
|
|
|
- if (threshold && insideHorizontally && insideVertically) {
|
|
|
+ if (insideHorizontally && insideVertically) {
|
|
|
return ret = sortable;
|
|
|
}
|
|
|
});
|
|
@@ -1235,7 +1274,7 @@
|
|
|
x: 0,
|
|
|
y: 0
|
|
|
},
|
|
|
- supportPointer: Sortable.supportPointer !== false && 'PointerEvent' in window,
|
|
|
+ supportPointer: Sortable.supportPointer !== false && 'PointerEvent' in window && !Safari,
|
|
|
emptyInsertThreshold: 5
|
|
|
};
|
|
|
PluginManager.initializePlugins(this, el, defaults); // Set default options
|
|
@@ -1322,6 +1361,11 @@
|
|
|
|
|
|
if (originalTarget.isContentEditable) {
|
|
|
return;
|
|
|
+ } // Safari ignores further event handling after mousedown
|
|
|
+
|
|
|
+
|
|
|
+ if (!this.nativeDraggable && Safari && target && target.tagName.toUpperCase() === 'SELECT') {
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
target = closest(target, options.draggable, el, false);
|
|
@@ -1825,7 +1869,7 @@
|
|
|
if (_silent) return;
|
|
|
|
|
|
function dragOverEvent(name, extra) {
|
|
|
- pluginEvent(name, _this, _objectSpread({
|
|
|
+ pluginEvent(name, _this, _objectSpread2({
|
|
|
evt: evt,
|
|
|
isOwner: isOwner,
|
|
|
axis: vertical ? 'vertical' : 'horizontal',
|
|
@@ -1942,7 +1986,7 @@
|
|
|
|
|
|
ignoreNextClick = false;
|
|
|
|
|
|
- if (activeSortable && !options.disabled && (isOwner ? canSort || (revert = !rootEl.contains(dragEl)) // Reverting item into the original list
|
|
|
+ if (activeSortable && !options.disabled && (isOwner ? canSort || (revert = parentEl !== rootEl) // Reverting item into the original list
|
|
|
: putSortable === this || (this.lastPutMode = activeGroup.checkPull(this, activeSortable, dragEl, evt)) && group.checkPut(this, activeSortable, dragEl, evt))) {
|
|
|
vertical = this._getDirection(evt, target) === 'vertical';
|
|
|
dragRect = getRect(dragEl);
|
|
@@ -1972,10 +2016,11 @@
|
|
|
var elLastChild = lastChild(el, options.draggable);
|
|
|
|
|
|
if (!elLastChild || _ghostIsLast(evt, vertical, this) && !elLastChild.animated) {
|
|
|
+ // Insert to end of list
|
|
|
// If already at end of list: Do not insert
|
|
|
if (elLastChild === dragEl) {
|
|
|
return completed(false);
|
|
|
- } // assign target only if condition is true
|
|
|
+ } // if there is a last element, it is the target
|
|
|
|
|
|
|
|
|
if (elLastChild && el === evt.target) {
|
|
@@ -1991,6 +2036,25 @@
|
|
|
el.appendChild(dragEl);
|
|
|
parentEl = el; // actualization
|
|
|
|
|
|
+ changed();
|
|
|
+ return completed(true);
|
|
|
+ }
|
|
|
+ } else if (elLastChild && _ghostIsFirst(evt, vertical, this)) {
|
|
|
+ // Insert to start of list
|
|
|
+ var firstChild = getChild(el, 0, options, true);
|
|
|
+
|
|
|
+ if (firstChild === dragEl) {
|
|
|
+ return completed(false);
|
|
|
+ }
|
|
|
+
|
|
|
+ target = firstChild;
|
|
|
+ targetRect = getRect(target);
|
|
|
+
|
|
|
+ if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, false) !== false) {
|
|
|
+ capture();
|
|
|
+ el.insertBefore(dragEl, firstChild);
|
|
|
+ parentEl = el; // actualization
|
|
|
+
|
|
|
changed();
|
|
|
return completed(true);
|
|
|
}
|
|
@@ -2319,7 +2383,7 @@
|
|
|
* Sorts the elements according to the array.
|
|
|
* @param {String[]} order order of the items
|
|
|
*/
|
|
|
- sort: function sort(order) {
|
|
|
+ sort: function sort(order, useAnimation) {
|
|
|
var items = {},
|
|
|
rootEl = this.el;
|
|
|
this.toArray().forEach(function (id, i) {
|
|
@@ -2329,12 +2393,14 @@
|
|
|
items[id] = el;
|
|
|
}
|
|
|
}, this);
|
|
|
+ useAnimation && this.captureAnimationState();
|
|
|
order.forEach(function (id) {
|
|
|
if (items[id]) {
|
|
|
rootEl.removeChild(items[id]);
|
|
|
rootEl.appendChild(items[id]);
|
|
|
}
|
|
|
});
|
|
|
+ useAnimation && this.animateAll();
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -2433,7 +2499,7 @@
|
|
|
pluginEvent('showClone', this);
|
|
|
if (Sortable.eventCanceled) return; // show clone at dragEl or original position
|
|
|
|
|
|
- if (rootEl.contains(dragEl) && !this.options.group.revertClone) {
|
|
|
+ if (dragEl.parentNode == rootEl && !this.options.group.revertClone) {
|
|
|
rootEl.insertBefore(cloneEl, dragEl);
|
|
|
} else if (nextEl) {
|
|
|
rootEl.insertBefore(cloneEl, nextEl);
|
|
@@ -2502,6 +2568,12 @@
|
|
|
_silent = false;
|
|
|
}
|
|
|
|
|
|
+ function _ghostIsFirst(evt, vertical, sortable) {
|
|
|
+ var rect = getRect(getChild(sortable.el, 0, sortable.options, true));
|
|
|
+ var spacer = 10;
|
|
|
+ return vertical ? evt.clientX < rect.left - spacer || evt.clientY < rect.top && evt.clientX < rect.right : evt.clientY < rect.top - spacer || evt.clientY < rect.bottom && evt.clientX < rect.left;
|
|
|
+ }
|
|
|
+
|
|
|
function _ghostIsLast(evt, vertical, sortable) {
|
|
|
var rect = getRect(lastChild(sortable.el, sortable.options.draggable));
|
|
|
var spacer = 10;
|
|
@@ -2662,7 +2734,7 @@
|
|
|
throw "Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(plugin));
|
|
|
}
|
|
|
|
|
|
- if (plugin.utils) Sortable.utils = _objectSpread({}, Sortable.utils, plugin.utils);
|
|
|
+ if (plugin.utils) Sortable.utils = _objectSpread2(_objectSpread2({}, Sortable.utils), plugin.utils);
|
|
|
PluginManager.mount(plugin);
|
|
|
});
|
|
|
};
|
|
@@ -2693,6 +2765,7 @@
|
|
|
function AutoScroll() {
|
|
|
this.defaults = {
|
|
|
scroll: true,
|
|
|
+ forceAutoScrollFallback: false,
|
|
|
scrollSensitivity: 30,
|
|
|
scrollSpeed: 10,
|
|
|
bubbleScroll: true
|
|
@@ -2760,7 +2833,7 @@
|
|
|
// MACOS Safari does not have autoscroll,
|
|
|
// Firefox and Chrome are good
|
|
|
|
|
|
- if (fallback || Edge || IE11OrLess || Safari) {
|
|
|
+ if (fallback || this.options.forceAutoScrollFallback || Edge || IE11OrLess || Safari) {
|
|
|
autoScroll(evt, this.options, elem, fallback); // Listener for pointer element change
|
|
|
|
|
|
var ogElemScroller = getParentAutoScrollElement(elem, true);
|
|
@@ -3460,7 +3533,8 @@
|
|
|
|
|
|
|
|
|
if (dragStarted && this.isMultiDrag) {
|
|
|
- // Do not "unfold" after around dragEl if reverted
|
|
|
+ folding = false; // Do not "unfold" after around dragEl if reverted
|
|
|
+
|
|
|
if ((parentEl[expando].options.sort || parentEl !== rootEl) && multiDragElements.length > 1) {
|
|
|
var dragRect = getRect(dragEl$1),
|
|
|
multiDragIndex = index(dragEl$1, ':not(.' + this.options.selectedClass + ')');
|
|
@@ -3706,4 +3780,4 @@
|
|
|
|
|
|
return Sortable;
|
|
|
|
|
|
-}));
|
|
|
+})));
|