-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
11,374 additions
and
2,707 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/**! | ||
* Sortable 1.13.0 | ||
* 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.13.0"; | ||
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); | ||
} | ||
} | ||
|
||
|
@@ -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) { | ||
|
@@ -813,15 +845,15 @@ | |
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, | ||
// and plugin has event defined | ||
|
||
|
||
if (sortable.options[plugin.pluginName] && sortable[plugin.pluginName][eventName]) { | ||
sortable[plugin.pluginName][eventName](_objectSpread({ | ||
sortable[plugin.pluginName][eventName](_objectSpread2({ | ||
sortable: sortable | ||
}, evt)); | ||
} | ||
|
@@ -913,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]; | ||
|
@@ -928,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, | ||
|
@@ -969,7 +1003,7 @@ | |
}; | ||
|
||
function _dispatchEvent(info) { | ||
dispatchEvent(_objectSpread({ | ||
dispatchEvent(_objectSpread2({ | ||
putSortable: putSortable, | ||
cloneEl: cloneEl, | ||
targetEl: dragEl, | ||
|
@@ -1078,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; | ||
} | ||
}); | ||
|
@@ -1835,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', | ||
|
@@ -1952,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); | ||
|
@@ -1982,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) { | ||
|
@@ -2001,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); | ||
} | ||
|
@@ -2514,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; | ||
|
@@ -2674,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); | ||
}); | ||
}; | ||
|
@@ -2705,6 +2765,7 @@ | |
function AutoScroll() { | ||
this.defaults = { | ||
scroll: true, | ||
forceAutoScrollFallback: false, | ||
scrollSensitivity: 30, | ||
scrollSpeed: 10, | ||
bubbleScroll: true | ||
|
@@ -2772,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); | ||
|
@@ -3472,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 + ')'); | ||
|
@@ -3718,4 +3780,4 @@ | |
|
||
return Sortable; | ||
|
||
})); | ||
}))); |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.