sortablejs 1.10.0-rc2 → 1.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +813 -774
- package/Sortable.js +438 -372
- package/Sortable.min.js +2 -2
- package/modular/sortable.complete.esm.js +438 -372
- package/modular/sortable.core.esm.js +438 -372
- package/modular/sortable.esm.js +438 -372
- package/package.json +12 -7
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**!
|
|
2
|
-
* Sortable 1.10.
|
|
2
|
+
* Sortable 1.10.2
|
|
3
3
|
* @author RubaXa <trash@rubaxa.org>
|
|
4
4
|
* @author owenm <owen23355@gmail.com>
|
|
5
5
|
* @license MIT
|
|
@@ -126,27 +126,22 @@ function _nonIterableSpread() {
|
|
|
126
126
|
throw new TypeError("Invalid attempt to spread non-iterable instance");
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
var version = "1.10.
|
|
129
|
+
var version = "1.10.2";
|
|
130
130
|
|
|
131
131
|
function userAgent(pattern) {
|
|
132
|
-
|
|
132
|
+
if (typeof window !== 'undefined' && window.navigator) {
|
|
133
|
+
return !!
|
|
134
|
+
/*@__PURE__*/
|
|
135
|
+
navigator.userAgent.match(pattern);
|
|
136
|
+
}
|
|
133
137
|
}
|
|
134
138
|
|
|
135
|
-
var IE11OrLess =
|
|
136
|
-
|
|
137
|
-
userAgent(/
|
|
138
|
-
var
|
|
139
|
-
|
|
140
|
-
userAgent(/
|
|
141
|
-
var FireFox =
|
|
142
|
-
/*@__PURE__*/
|
|
143
|
-
userAgent(/firefox/i);
|
|
144
|
-
var Safari =
|
|
145
|
-
/*@__PURE__*/
|
|
146
|
-
userAgent(/safari/i) && !userAgent(/chrome/i) && !userAgent(/android/i);
|
|
147
|
-
var IOS =
|
|
148
|
-
/*@__PURE__*/
|
|
149
|
-
userAgent(/iP(ad|od|hone)/i);
|
|
139
|
+
var IE11OrLess = userAgent(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i);
|
|
140
|
+
var Edge = userAgent(/Edge/i);
|
|
141
|
+
var FireFox = userAgent(/firefox/i);
|
|
142
|
+
var Safari = userAgent(/safari/i) && !userAgent(/chrome/i) && !userAgent(/android/i);
|
|
143
|
+
var IOS = userAgent(/iP(ad|od|hone)/i);
|
|
144
|
+
var ChromeForAndroid = userAgent(/chrome/i) && userAgent(/android/i);
|
|
150
145
|
|
|
151
146
|
var captureMode = {
|
|
152
147
|
capture: false,
|
|
@@ -251,17 +246,21 @@ function css(el, prop, val) {
|
|
|
251
246
|
function matrix(el, selfOnly) {
|
|
252
247
|
var appliedTransforms = '';
|
|
253
248
|
|
|
254
|
-
|
|
255
|
-
|
|
249
|
+
if (typeof el === 'string') {
|
|
250
|
+
appliedTransforms = el;
|
|
251
|
+
} else {
|
|
252
|
+
do {
|
|
253
|
+
var transform = css(el, 'transform');
|
|
256
254
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
255
|
+
if (transform && transform !== 'none') {
|
|
256
|
+
appliedTransforms = transform + ' ' + appliedTransforms;
|
|
257
|
+
}
|
|
258
|
+
/* jshint boss:true */
|
|
261
259
|
|
|
262
|
-
|
|
260
|
+
} while (!selfOnly && (el = el.parentNode));
|
|
261
|
+
}
|
|
263
262
|
|
|
264
|
-
var matrixFn = window.DOMMatrix || window.WebKitCSSMatrix || window.CSSMatrix;
|
|
263
|
+
var matrixFn = window.DOMMatrix || window.WebKitCSSMatrix || window.CSSMatrix || window.MSCSSMatrix;
|
|
265
264
|
/*jshint -W056 */
|
|
266
265
|
|
|
267
266
|
return matrixFn && new matrixFn(appliedTransforms);
|
|
@@ -286,20 +285,22 @@ function find(ctx, tagName, iterator) {
|
|
|
286
285
|
}
|
|
287
286
|
|
|
288
287
|
function getWindowScrollingElement() {
|
|
289
|
-
|
|
290
|
-
|
|
288
|
+
var scrollingElement = document.scrollingElement;
|
|
289
|
+
|
|
290
|
+
if (scrollingElement) {
|
|
291
|
+
return scrollingElement;
|
|
291
292
|
} else {
|
|
292
|
-
return document.
|
|
293
|
+
return document.documentElement;
|
|
293
294
|
}
|
|
294
295
|
}
|
|
295
|
-
/**
|
|
296
|
-
* Returns the "bounding client rect" of given element
|
|
297
|
-
* @param {HTMLElement} el The element whose boundingClientRect is wanted
|
|
298
|
-
* @param {[Boolean]} relativeToContainingBlock Whether the rect should be relative to the containing block of (including) the container
|
|
299
|
-
* @param {[Boolean]} relativeToNonStaticParent Whether the rect should be relative to the relative parent of (including) the contaienr
|
|
300
|
-
* @param {[Boolean]} undoScale Whether the container's scale() should be undone
|
|
301
|
-
* @param {[HTMLElement]} container The parent the element will be placed in
|
|
302
|
-
* @return {Object} The boundingClientRect of el, with specified adjustments
|
|
296
|
+
/**
|
|
297
|
+
* Returns the "bounding client rect" of given element
|
|
298
|
+
* @param {HTMLElement} el The element whose boundingClientRect is wanted
|
|
299
|
+
* @param {[Boolean]} relativeToContainingBlock Whether the rect should be relative to the containing block of (including) the container
|
|
300
|
+
* @param {[Boolean]} relativeToNonStaticParent Whether the rect should be relative to the relative parent of (including) the contaienr
|
|
301
|
+
* @param {[Boolean]} undoScale Whether the container's scale() should be undone
|
|
302
|
+
* @param {[HTMLElement]} container The parent the element will be placed in
|
|
303
|
+
* @return {Object} The boundingClientRect of el, with specified adjustments
|
|
303
304
|
*/
|
|
304
305
|
|
|
305
306
|
|
|
@@ -371,19 +372,18 @@ function getRect(el, relativeToContainingBlock, relativeToNonStaticParent, undoS
|
|
|
371
372
|
height: height
|
|
372
373
|
};
|
|
373
374
|
}
|
|
374
|
-
/**
|
|
375
|
-
* Checks if a side of an element is scrolled past a side of its parents
|
|
376
|
-
* @param {HTMLElement} el The element who's side being scrolled out of view is in question
|
|
377
|
-
* @param {
|
|
378
|
-
* @param {String}
|
|
379
|
-
* @
|
|
380
|
-
* @return {HTMLElement} The parent scroll element that the el's side is scrolled past, or null if there is no such element
|
|
375
|
+
/**
|
|
376
|
+
* Checks if a side of an element is scrolled past a side of its parents
|
|
377
|
+
* @param {HTMLElement} el The element who's side being scrolled out of view is in question
|
|
378
|
+
* @param {String} elSide Side of the element in question ('top', 'left', 'right', 'bottom')
|
|
379
|
+
* @param {String} parentSide Side of the parent in question ('top', 'left', 'right', 'bottom')
|
|
380
|
+
* @return {HTMLElement} The parent scroll element that the el's side is scrolled past, or null if there is no such element
|
|
381
381
|
*/
|
|
382
382
|
|
|
383
383
|
|
|
384
|
-
function isScrolledPast(el,
|
|
384
|
+
function isScrolledPast(el, elSide, parentSide) {
|
|
385
385
|
var parent = getParentAutoScrollElement(el, true),
|
|
386
|
-
elSideVal =
|
|
386
|
+
elSideVal = getRect(el)[elSide];
|
|
387
387
|
/* jshint boss:true */
|
|
388
388
|
|
|
389
389
|
while (parent) {
|
|
@@ -403,13 +403,13 @@ function isScrolledPast(el, rect, elSide, parentSide) {
|
|
|
403
403
|
|
|
404
404
|
return false;
|
|
405
405
|
}
|
|
406
|
-
/**
|
|
407
|
-
* Gets nth child of el, ignoring hidden children, sortable's elements (does not ignore clone if it's visible)
|
|
408
|
-
* and non-draggable elements
|
|
409
|
-
* @param {HTMLElement} el The parent element
|
|
410
|
-
* @param {Number} childNum The index of the child
|
|
411
|
-
* @param {Object} options Parent Sortable's options
|
|
412
|
-
* @return {HTMLElement} The child at index childNum, or null if not found
|
|
406
|
+
/**
|
|
407
|
+
* Gets nth child of el, ignoring hidden children, sortable's elements (does not ignore clone if it's visible)
|
|
408
|
+
* and non-draggable elements
|
|
409
|
+
* @param {HTMLElement} el The parent element
|
|
410
|
+
* @param {Number} childNum The index of the child
|
|
411
|
+
* @param {Object} options Parent Sortable's options
|
|
412
|
+
* @return {HTMLElement} The child at index childNum, or null if not found
|
|
413
413
|
*/
|
|
414
414
|
|
|
415
415
|
|
|
@@ -432,11 +432,11 @@ function getChild(el, childNum, options) {
|
|
|
432
432
|
|
|
433
433
|
return null;
|
|
434
434
|
}
|
|
435
|
-
/**
|
|
436
|
-
* Gets the last child in the el, ignoring ghostEl or invisible elements (clones)
|
|
437
|
-
* @param {HTMLElement} el Parent element
|
|
438
|
-
* @param {selector} selector Any other elements that should be ignored
|
|
439
|
-
* @return {HTMLElement} The last child, ignoring ghostEl
|
|
435
|
+
/**
|
|
436
|
+
* Gets the last child in the el, ignoring ghostEl or invisible elements (clones)
|
|
437
|
+
* @param {HTMLElement} el Parent element
|
|
438
|
+
* @param {selector} selector Any other elements that should be ignored
|
|
439
|
+
* @return {HTMLElement} The last child, ignoring ghostEl
|
|
440
440
|
*/
|
|
441
441
|
|
|
442
442
|
|
|
@@ -449,12 +449,12 @@ function lastChild(el, selector) {
|
|
|
449
449
|
|
|
450
450
|
return last || null;
|
|
451
451
|
}
|
|
452
|
-
/**
|
|
453
|
-
* Returns the index of an element within its parent for a selected set of
|
|
454
|
-
* elements
|
|
455
|
-
* @param {HTMLElement} el
|
|
456
|
-
* @param {selector} selector
|
|
457
|
-
* @return {number}
|
|
452
|
+
/**
|
|
453
|
+
* Returns the index of an element within its parent for a selected set of
|
|
454
|
+
* elements
|
|
455
|
+
* @param {HTMLElement} el
|
|
456
|
+
* @param {selector} selector
|
|
457
|
+
* @return {number}
|
|
458
458
|
*/
|
|
459
459
|
|
|
460
460
|
|
|
@@ -475,11 +475,11 @@ function index(el, selector) {
|
|
|
475
475
|
|
|
476
476
|
return index;
|
|
477
477
|
}
|
|
478
|
-
/**
|
|
479
|
-
* Returns the scroll offset of the given element, added with all the scroll offsets of parent elements.
|
|
480
|
-
* The value is returned in real pixels.
|
|
481
|
-
* @param {HTMLElement} el
|
|
482
|
-
* @return {Array} Offsets in the format of [left, top]
|
|
478
|
+
/**
|
|
479
|
+
* Returns the scroll offset of the given element, added with all the scroll offsets of parent elements.
|
|
480
|
+
* The value is returned in real pixels.
|
|
481
|
+
* @param {HTMLElement} el
|
|
482
|
+
* @return {Array} Offsets in the format of [left, top]
|
|
483
483
|
*/
|
|
484
484
|
|
|
485
485
|
|
|
@@ -500,18 +500,20 @@ function getRelativeScrollOffset(el) {
|
|
|
500
500
|
|
|
501
501
|
return [offsetLeft, offsetTop];
|
|
502
502
|
}
|
|
503
|
-
/**
|
|
504
|
-
* Returns the index of the object within the given array
|
|
505
|
-
* @param {Array} arr Array that may or may not hold the object
|
|
506
|
-
* @param {Object} obj An object that has a key-value pair unique to and identical to a key-value pair in the object you want to find
|
|
507
|
-
* @return {Number} The index of the object in the array, or -1
|
|
503
|
+
/**
|
|
504
|
+
* Returns the index of the object within the given array
|
|
505
|
+
* @param {Array} arr Array that may or may not hold the object
|
|
506
|
+
* @param {Object} obj An object that has a key-value pair unique to and identical to a key-value pair in the object you want to find
|
|
507
|
+
* @return {Number} The index of the object in the array, or -1
|
|
508
508
|
*/
|
|
509
509
|
|
|
510
510
|
|
|
511
511
|
function indexOfObject(arr, obj) {
|
|
512
512
|
for (var i in arr) {
|
|
513
|
+
if (!arr.hasOwnProperty(i)) continue;
|
|
514
|
+
|
|
513
515
|
for (var key in obj) {
|
|
514
|
-
if (obj[key] === arr[i][key]) return Number(i);
|
|
516
|
+
if (obj.hasOwnProperty(key) && obj[key] === arr[i][key]) return Number(i);
|
|
515
517
|
}
|
|
516
518
|
}
|
|
517
519
|
|
|
@@ -628,17 +630,18 @@ function AnimationStateManager() {
|
|
|
628
630
|
animationStates = [];
|
|
629
631
|
if (!this.options.animation) return;
|
|
630
632
|
var children = [].slice.call(this.el.children);
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
if (css(children[i], 'display') === 'none' || children[i] === Sortable.ghost) continue;
|
|
633
|
+
children.forEach(function (child) {
|
|
634
|
+
if (css(child, 'display') === 'none' || child === Sortable.ghost) return;
|
|
634
635
|
animationStates.push({
|
|
635
|
-
target:
|
|
636
|
-
rect: getRect(
|
|
636
|
+
target: child,
|
|
637
|
+
rect: getRect(child)
|
|
637
638
|
});
|
|
638
|
-
var fromRect = getRect(children[i]); // If animating: compensate for current animation
|
|
639
639
|
|
|
640
|
-
|
|
641
|
-
|
|
640
|
+
var fromRect = _objectSpread({}, animationStates[animationStates.length - 1].rect); // If animating: compensate for current animation
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
if (child.thisAnimationDuration) {
|
|
644
|
+
var childMatrix = matrix(child, true);
|
|
642
645
|
|
|
643
646
|
if (childMatrix) {
|
|
644
647
|
fromRect.top -= childMatrix.f;
|
|
@@ -646,8 +649,8 @@ function AnimationStateManager() {
|
|
|
646
649
|
}
|
|
647
650
|
}
|
|
648
651
|
|
|
649
|
-
|
|
650
|
-
}
|
|
652
|
+
child.fromRect = fromRect;
|
|
653
|
+
});
|
|
651
654
|
},
|
|
652
655
|
addAnimationState: function addAnimationState(state) {
|
|
653
656
|
animationStates.push(state);
|
|
@@ -658,6 +661,8 @@ function AnimationStateManager() {
|
|
|
658
661
|
}), 1);
|
|
659
662
|
},
|
|
660
663
|
animateAll: function animateAll(callback) {
|
|
664
|
+
var _this = this;
|
|
665
|
+
|
|
661
666
|
if (!this.options.animation) {
|
|
662
667
|
clearTimeout(animationCallbackId);
|
|
663
668
|
if (typeof callback === 'function') callback();
|
|
@@ -666,15 +671,14 @@ function AnimationStateManager() {
|
|
|
666
671
|
|
|
667
672
|
var animating = false,
|
|
668
673
|
animationTime = 0;
|
|
669
|
-
|
|
670
|
-
for (var i in animationStates) {
|
|
674
|
+
animationStates.forEach(function (state) {
|
|
671
675
|
var time = 0,
|
|
672
|
-
target =
|
|
676
|
+
target = state.target,
|
|
673
677
|
fromRect = target.fromRect,
|
|
674
678
|
toRect = getRect(target),
|
|
675
679
|
prevFromRect = target.prevFromRect,
|
|
676
680
|
prevToRect = target.prevToRect,
|
|
677
|
-
animatingRect =
|
|
681
|
+
animatingRect = state.rect,
|
|
678
682
|
targetMatrix = matrix(target, true);
|
|
679
683
|
|
|
680
684
|
if (targetMatrix) {
|
|
@@ -683,16 +687,14 @@ function AnimationStateManager() {
|
|
|
683
687
|
toRect.left -= targetMatrix.e;
|
|
684
688
|
}
|
|
685
689
|
|
|
686
|
-
target.toRect = toRect;
|
|
687
|
-
|
|
688
|
-
if ((isScrolledPast(target, toRect, 'bottom', 'top') || isScrolledPast(target, toRect, 'top', 'bottom') || isScrolledPast(target, toRect, 'right', 'left') || isScrolledPast(target, toRect, 'left', 'right')) && (isScrolledPast(target, animatingRect, 'bottom', 'top') || isScrolledPast(target, animatingRect, 'top', 'bottom') || isScrolledPast(target, animatingRect, 'right', 'left') || isScrolledPast(target, animatingRect, 'left', 'right')) && (isScrolledPast(target, fromRect, 'bottom', 'top') || isScrolledPast(target, fromRect, 'top', 'bottom') || isScrolledPast(target, fromRect, 'right', 'left') || isScrolledPast(target, fromRect, 'left', 'right'))) continue;
|
|
690
|
+
target.toRect = toRect;
|
|
689
691
|
|
|
690
692
|
if (target.thisAnimationDuration) {
|
|
691
693
|
// Could also check if animatingRect is between fromRect and toRect
|
|
692
694
|
if (isRectEqual(prevFromRect, toRect) && !isRectEqual(fromRect, toRect) && // Make sure animatingRect is on line between toRect & fromRect
|
|
693
695
|
(animatingRect.top - toRect.top) / (animatingRect.left - toRect.left) === (fromRect.top - toRect.top) / (fromRect.left - toRect.left)) {
|
|
694
696
|
// If returning to same place as started from animation and on same axis
|
|
695
|
-
time = calculateRealTime(animatingRect, prevFromRect, prevToRect,
|
|
697
|
+
time = calculateRealTime(animatingRect, prevFromRect, prevToRect, _this.options);
|
|
696
698
|
}
|
|
697
699
|
} // if fromRect != toRect: animate
|
|
698
700
|
|
|
@@ -702,10 +704,10 @@ function AnimationStateManager() {
|
|
|
702
704
|
target.prevToRect = toRect;
|
|
703
705
|
|
|
704
706
|
if (!time) {
|
|
705
|
-
time =
|
|
707
|
+
time = _this.options.animation;
|
|
706
708
|
}
|
|
707
709
|
|
|
708
|
-
|
|
710
|
+
_this.animate(target, animatingRect, toRect, time);
|
|
709
711
|
}
|
|
710
712
|
|
|
711
713
|
if (time) {
|
|
@@ -713,19 +715,15 @@ function AnimationStateManager() {
|
|
|
713
715
|
animationTime = Math.max(animationTime, time);
|
|
714
716
|
clearTimeout(target.animationResetTimer);
|
|
715
717
|
target.animationResetTimer = setTimeout(function () {
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
}
|
|
722
|
-
animationStates: animationStates,
|
|
723
|
-
i: Number(i)
|
|
724
|
-
}), time);
|
|
718
|
+
target.animationTime = 0;
|
|
719
|
+
target.prevFromRect = null;
|
|
720
|
+
target.fromRect = null;
|
|
721
|
+
target.prevToRect = null;
|
|
722
|
+
target.thisAnimationDuration = null;
|
|
723
|
+
}, time);
|
|
725
724
|
target.thisAnimationDuration = time;
|
|
726
725
|
}
|
|
727
|
-
}
|
|
728
|
-
|
|
726
|
+
});
|
|
729
727
|
clearTimeout(animationCallbackId);
|
|
730
728
|
|
|
731
729
|
if (!animating) {
|
|
@@ -738,16 +736,15 @@ function AnimationStateManager() {
|
|
|
738
736
|
|
|
739
737
|
animationStates = [];
|
|
740
738
|
},
|
|
741
|
-
animate: function animate(target,
|
|
739
|
+
animate: function animate(target, currentRect, toRect, duration) {
|
|
742
740
|
if (duration) {
|
|
743
741
|
css(target, 'transition', '');
|
|
744
742
|
css(target, 'transform', '');
|
|
745
|
-
var
|
|
746
|
-
elMatrix = matrix(this.el),
|
|
743
|
+
var elMatrix = matrix(this.el),
|
|
747
744
|
scaleX = elMatrix && elMatrix.a,
|
|
748
745
|
scaleY = elMatrix && elMatrix.d,
|
|
749
|
-
translateX = (
|
|
750
|
-
translateY = (
|
|
746
|
+
translateX = (currentRect.left - toRect.left) / (scaleX || 1),
|
|
747
|
+
translateY = (currentRect.top - toRect.top) / (scaleY || 1);
|
|
751
748
|
target.animatingX = !!translateX;
|
|
752
749
|
target.animatingY = !!translateY;
|
|
753
750
|
css(target, 'transform', 'translate3d(' + translateX + 'px,' + translateY + 'px,0)');
|
|
@@ -784,45 +781,55 @@ var PluginManager = {
|
|
|
784
781
|
mount: function mount(plugin) {
|
|
785
782
|
// Set default static properties
|
|
786
783
|
for (var option in defaults) {
|
|
787
|
-
|
|
784
|
+
if (defaults.hasOwnProperty(option) && !(option in plugin)) {
|
|
785
|
+
plugin[option] = defaults[option];
|
|
786
|
+
}
|
|
788
787
|
}
|
|
789
788
|
|
|
790
789
|
plugins.push(plugin);
|
|
791
790
|
},
|
|
792
791
|
pluginEvent: function pluginEvent(eventName, sortable, evt) {
|
|
792
|
+
var _this = this;
|
|
793
|
+
|
|
793
794
|
this.eventCanceled = false;
|
|
794
|
-
var eventNameGlobal = eventName + 'Global';
|
|
795
795
|
|
|
796
|
-
|
|
797
|
-
|
|
796
|
+
evt.cancel = function () {
|
|
797
|
+
_this.eventCanceled = true;
|
|
798
|
+
};
|
|
798
799
|
|
|
799
|
-
|
|
800
|
-
|
|
800
|
+
var eventNameGlobal = eventName + 'Global';
|
|
801
|
+
plugins.forEach(function (plugin) {
|
|
802
|
+
if (!sortable[plugin.pluginName]) return; // Fire global events if it exists in this sortable
|
|
803
|
+
|
|
804
|
+
if (sortable[plugin.pluginName][eventNameGlobal]) {
|
|
805
|
+
sortable[plugin.pluginName][eventNameGlobal](_objectSpread({
|
|
801
806
|
sortable: sortable
|
|
802
807
|
}, evt));
|
|
803
808
|
} // Only fire plugin event if plugin is enabled in this sortable,
|
|
804
809
|
// and plugin has event defined
|
|
805
810
|
|
|
806
811
|
|
|
807
|
-
if (sortable.options[
|
|
808
|
-
|
|
812
|
+
if (sortable.options[plugin.pluginName] && sortable[plugin.pluginName][eventName]) {
|
|
813
|
+
sortable[plugin.pluginName][eventName](_objectSpread({
|
|
809
814
|
sortable: sortable
|
|
810
815
|
}, evt));
|
|
811
816
|
}
|
|
812
|
-
}
|
|
817
|
+
});
|
|
813
818
|
},
|
|
814
|
-
initializePlugins: function initializePlugins(sortable, el, defaults) {
|
|
815
|
-
|
|
816
|
-
var pluginName =
|
|
817
|
-
if (!sortable.options[pluginName] && !
|
|
818
|
-
var initialized = new
|
|
819
|
+
initializePlugins: function initializePlugins(sortable, el, defaults, options) {
|
|
820
|
+
plugins.forEach(function (plugin) {
|
|
821
|
+
var pluginName = plugin.pluginName;
|
|
822
|
+
if (!sortable.options[pluginName] && !plugin.initializeByDefault) return;
|
|
823
|
+
var initialized = new plugin(sortable, el, sortable.options);
|
|
819
824
|
initialized.sortable = sortable;
|
|
825
|
+
initialized.options = sortable.options;
|
|
820
826
|
sortable[pluginName] = initialized; // Add default options from plugin
|
|
821
827
|
|
|
822
|
-
_extends(defaults, initialized.
|
|
823
|
-
}
|
|
828
|
+
_extends(defaults, initialized.defaults);
|
|
829
|
+
});
|
|
824
830
|
|
|
825
831
|
for (var option in sortable.options) {
|
|
832
|
+
if (!sortable.options.hasOwnProperty(option)) continue;
|
|
826
833
|
var modified = this.modifyOption(sortable, option, sortable.options[option]);
|
|
827
834
|
|
|
828
835
|
if (typeof modified !== 'undefined') {
|
|
@@ -830,29 +837,25 @@ var PluginManager = {
|
|
|
830
837
|
}
|
|
831
838
|
}
|
|
832
839
|
},
|
|
833
|
-
|
|
834
|
-
var
|
|
840
|
+
getEventProperties: function getEventProperties(name, sortable) {
|
|
841
|
+
var eventProperties = {};
|
|
842
|
+
plugins.forEach(function (plugin) {
|
|
843
|
+
if (typeof plugin.eventProperties !== 'function') return;
|
|
835
844
|
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
_extends(eventOptions, plugins[i].eventOptions.call(sortable, name));
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
return eventOptions;
|
|
845
|
+
_extends(eventProperties, plugin.eventProperties.call(sortable[plugin.pluginName], name));
|
|
846
|
+
});
|
|
847
|
+
return eventProperties;
|
|
843
848
|
},
|
|
844
849
|
modifyOption: function modifyOption(sortable, name, value) {
|
|
845
850
|
var modifiedValue;
|
|
846
|
-
|
|
847
|
-
for (var i in plugins) {
|
|
851
|
+
plugins.forEach(function (plugin) {
|
|
848
852
|
// Plugin must exist on the Sortable
|
|
849
|
-
if (!sortable[
|
|
853
|
+
if (!sortable[plugin.pluginName]) return; // If static option listener exists for this option, call in the context of the Sortable's instance of this plugin
|
|
850
854
|
|
|
851
|
-
if (
|
|
852
|
-
modifiedValue =
|
|
855
|
+
if (plugin.optionListeners && typeof plugin.optionListeners[name] === 'function') {
|
|
856
|
+
modifiedValue = plugin.optionListeners[name].call(sortable[plugin.pluginName], value);
|
|
853
857
|
}
|
|
854
|
-
}
|
|
855
|
-
|
|
858
|
+
});
|
|
856
859
|
return modifiedValue;
|
|
857
860
|
}
|
|
858
861
|
};
|
|
@@ -871,8 +874,9 @@ function dispatchEvent(_ref) {
|
|
|
871
874
|
newDraggableIndex = _ref.newDraggableIndex,
|
|
872
875
|
originalEvent = _ref.originalEvent,
|
|
873
876
|
putSortable = _ref.putSortable,
|
|
874
|
-
|
|
875
|
-
sortable = sortable || rootEl[expando];
|
|
877
|
+
extraEventProperties = _ref.extraEventProperties;
|
|
878
|
+
sortable = sortable || rootEl && rootEl[expando];
|
|
879
|
+
if (!sortable) return;
|
|
876
880
|
var evt,
|
|
877
881
|
options = sortable.options,
|
|
878
882
|
onName = 'on' + name.charAt(0).toUpperCase() + name.substr(1); // Support for new CustomEvent feature
|
|
@@ -898,10 +902,10 @@ function dispatchEvent(_ref) {
|
|
|
898
902
|
evt.originalEvent = originalEvent;
|
|
899
903
|
evt.pullMode = putSortable ? putSortable.lastPutMode : undefined;
|
|
900
904
|
|
|
901
|
-
var
|
|
905
|
+
var allEventProperties = _objectSpread({}, extraEventProperties, PluginManager.getEventProperties(name, sortable));
|
|
902
906
|
|
|
903
|
-
for (var option in
|
|
904
|
-
evt[option] =
|
|
907
|
+
for (var option in allEventProperties) {
|
|
908
|
+
evt[option] = allEventProperties[option];
|
|
905
909
|
}
|
|
906
910
|
|
|
907
911
|
if (rootEl) {
|
|
@@ -966,10 +970,6 @@ function _dispatchEvent(info) {
|
|
|
966
970
|
}, info));
|
|
967
971
|
}
|
|
968
972
|
|
|
969
|
-
if (typeof window === "undefined" || !window.document) {
|
|
970
|
-
throw new Error("Sortable.js requires a window with a document");
|
|
971
|
-
}
|
|
972
|
-
|
|
973
973
|
var dragEl,
|
|
974
974
|
parentEl,
|
|
975
975
|
ghostEl,
|
|
@@ -989,6 +989,10 @@ var dragEl,
|
|
|
989
989
|
sortables = [],
|
|
990
990
|
tapEvt,
|
|
991
991
|
touchEvt,
|
|
992
|
+
lastDx,
|
|
993
|
+
lastDy,
|
|
994
|
+
tapDistanceLeft,
|
|
995
|
+
tapDistanceTop,
|
|
992
996
|
moved,
|
|
993
997
|
lastTarget,
|
|
994
998
|
lastDirection,
|
|
@@ -1003,12 +1007,14 @@ _silent = false,
|
|
|
1003
1007
|
savedInputChecked = [];
|
|
1004
1008
|
/** @const */
|
|
1005
1009
|
|
|
1006
|
-
var
|
|
1010
|
+
var documentExists = typeof document !== 'undefined',
|
|
1011
|
+
PositionGhostAbsolutely = IOS,
|
|
1007
1012
|
CSSFloatProperty = Edge || IE11OrLess ? 'cssFloat' : 'float',
|
|
1008
1013
|
// This will not pass for IE9, because IE9 DnD only works on anchors
|
|
1009
|
-
supportDraggable = 'draggable' in document.createElement('div'),
|
|
1014
|
+
supportDraggable = documentExists && !ChromeForAndroid && !IOS && 'draggable' in document.createElement('div'),
|
|
1010
1015
|
supportCssPointerEvents = function () {
|
|
1011
|
-
// false when <= IE11
|
|
1016
|
+
if (!documentExists) return; // false when <= IE11
|
|
1017
|
+
|
|
1012
1018
|
if (IE11OrLess) {
|
|
1013
1019
|
return false;
|
|
1014
1020
|
}
|
|
@@ -1035,7 +1041,7 @@ supportDraggable = 'draggable' in document.createElement('div'),
|
|
|
1035
1041
|
return elCSS.gridTemplateColumns.split(' ').length <= 1 ? 'vertical' : 'horizontal';
|
|
1036
1042
|
}
|
|
1037
1043
|
|
|
1038
|
-
if (child1 && firstChildCSS["float"] !== 'none') {
|
|
1044
|
+
if (child1 && firstChildCSS["float"] && firstChildCSS["float"] !== 'none') {
|
|
1039
1045
|
var touchingSideChild2 = firstChildCSS["float"] === 'left' ? 'left' : 'right';
|
|
1040
1046
|
return child2 && (secondChildCSS.clear === 'both' || secondChildCSS.clear === touchingSideChild2) ? 'vertical' : 'horizontal';
|
|
1041
1047
|
}
|
|
@@ -1059,17 +1065,19 @@ supportDraggable = 'draggable' in document.createElement('div'),
|
|
|
1059
1065
|
* @return {HTMLElement} Element of the first found nearest Sortable
|
|
1060
1066
|
*/
|
|
1061
1067
|
_detectNearestEmptySortable = function _detectNearestEmptySortable(x, y) {
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1068
|
+
var ret;
|
|
1069
|
+
sortables.some(function (sortable) {
|
|
1070
|
+
if (lastChild(sortable)) return;
|
|
1071
|
+
var rect = getRect(sortable),
|
|
1072
|
+
threshold = sortable[expando].options.emptyInsertThreshold,
|
|
1066
1073
|
insideHorizontally = x >= rect.left - threshold && x <= rect.right + threshold,
|
|
1067
1074
|
insideVertically = y >= rect.top - threshold && y <= rect.bottom + threshold;
|
|
1068
1075
|
|
|
1069
1076
|
if (threshold && insideHorizontally && insideVertically) {
|
|
1070
|
-
return
|
|
1077
|
+
return ret = sortable;
|
|
1071
1078
|
}
|
|
1072
|
-
}
|
|
1079
|
+
});
|
|
1080
|
+
return ret;
|
|
1073
1081
|
},
|
|
1074
1082
|
_prepareGroup = function _prepareGroup(options) {
|
|
1075
1083
|
function toFn(value, pull) {
|
|
@@ -1120,15 +1128,17 @@ _detectNearestEmptySortable = function _detectNearestEmptySortable(x, y) {
|
|
|
1120
1128
|
}; // #1184 fix - Prevent click event on fallback if dragged but item not changed position
|
|
1121
1129
|
|
|
1122
1130
|
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
}
|
|
1131
|
+
if (documentExists) {
|
|
1132
|
+
document.addEventListener('click', function (evt) {
|
|
1133
|
+
if (ignoreNextClick) {
|
|
1134
|
+
evt.preventDefault();
|
|
1135
|
+
evt.stopPropagation && evt.stopPropagation();
|
|
1136
|
+
evt.stopImmediatePropagation && evt.stopImmediatePropagation();
|
|
1137
|
+
ignoreNextClick = false;
|
|
1138
|
+
return false;
|
|
1139
|
+
}
|
|
1140
|
+
}, true);
|
|
1141
|
+
}
|
|
1132
1142
|
|
|
1133
1143
|
var nearestEmptyInsertDetectEvent = function nearestEmptyInsertDetectEvent(evt) {
|
|
1134
1144
|
if (dragEl) {
|
|
@@ -1141,7 +1151,9 @@ var nearestEmptyInsertDetectEvent = function nearestEmptyInsertDetectEvent(evt)
|
|
|
1141
1151
|
var event = {};
|
|
1142
1152
|
|
|
1143
1153
|
for (var i in evt) {
|
|
1144
|
-
|
|
1154
|
+
if (evt.hasOwnProperty(i)) {
|
|
1155
|
+
event[i] = evt[i];
|
|
1156
|
+
}
|
|
1145
1157
|
}
|
|
1146
1158
|
|
|
1147
1159
|
event.target = event.rootEl = nearest;
|
|
@@ -1208,7 +1220,7 @@ function Sortable(el, options) {
|
|
|
1208
1220
|
dataIdAttr: 'data-id',
|
|
1209
1221
|
delay: 0,
|
|
1210
1222
|
delayOnTouchOnly: false,
|
|
1211
|
-
touchStartThreshold: Number.parseInt(window.devicePixelRatio, 10) || 1,
|
|
1223
|
+
touchStartThreshold: (Number.parseInt ? Number : window).parseInt(window.devicePixelRatio, 10) || 1,
|
|
1212
1224
|
forceFallback: false,
|
|
1213
1225
|
fallbackClass: 'sortable-fallback',
|
|
1214
1226
|
fallbackOnBody: false,
|
|
@@ -1285,7 +1297,7 @@ Sortable.prototype =
|
|
|
1285
1297
|
options = this.options,
|
|
1286
1298
|
preventOnFilter = options.preventOnFilter,
|
|
1287
1299
|
type = evt.type,
|
|
1288
|
-
touch = evt.touches && evt.touches[0],
|
|
1300
|
+
touch = evt.touches && evt.touches[0] || evt.pointerType && evt.pointerType === 'touch' && evt,
|
|
1289
1301
|
target = (touch || evt).target,
|
|
1290
1302
|
originalTarget = evt.target.shadowRoot && (evt.path && evt.path[0] || evt.composedPath && evt.composedPath()[0]) || target,
|
|
1291
1303
|
filter = options.filter;
|
|
@@ -1386,6 +1398,7 @@ Sortable.prototype =
|
|
|
1386
1398
|
dragStartFn;
|
|
1387
1399
|
|
|
1388
1400
|
if (target && !dragEl && target.parentNode === el) {
|
|
1401
|
+
var dragRect = getRect(target);
|
|
1389
1402
|
rootEl = el;
|
|
1390
1403
|
dragEl = target;
|
|
1391
1404
|
parentEl = dragEl.parentNode;
|
|
@@ -1398,6 +1411,8 @@ Sortable.prototype =
|
|
|
1398
1411
|
clientX: (touch || evt).clientX,
|
|
1399
1412
|
clientY: (touch || evt).clientY
|
|
1400
1413
|
};
|
|
1414
|
+
tapDistanceLeft = tapEvt.clientX - dragRect.left;
|
|
1415
|
+
tapDistanceTop = tapEvt.clientY - dragRect.top;
|
|
1401
1416
|
this._lastX = (touch || evt).clientX;
|
|
1402
1417
|
this._lastY = (touch || evt).clientY;
|
|
1403
1418
|
dragEl.style['will-change'] = 'all';
|
|
@@ -1506,7 +1521,7 @@ Sortable.prototype =
|
|
|
1506
1521
|
evt,
|
|
1507
1522
|
/** Touch */
|
|
1508
1523
|
touch) {
|
|
1509
|
-
touch = touch ||
|
|
1524
|
+
touch = touch || evt.pointerType == 'touch' && evt;
|
|
1510
1525
|
|
|
1511
1526
|
if (!this.nativeDraggable || touch) {
|
|
1512
1527
|
if (this.options.supportPointer) {
|
|
@@ -1612,13 +1627,12 @@ Sortable.prototype =
|
|
|
1612
1627
|
fallbackTolerance = options.fallbackTolerance,
|
|
1613
1628
|
fallbackOffset = options.fallbackOffset,
|
|
1614
1629
|
touch = evt.touches ? evt.touches[0] : evt,
|
|
1615
|
-
ghostMatrix = ghostEl && matrix(ghostEl),
|
|
1630
|
+
ghostMatrix = ghostEl && matrix(ghostEl, true),
|
|
1616
1631
|
scaleX = ghostEl && ghostMatrix && ghostMatrix.a,
|
|
1617
1632
|
scaleY = ghostEl && ghostMatrix && ghostMatrix.d,
|
|
1618
1633
|
relativeScrollOffset = PositionGhostAbsolutely && ghostRelativeParent && getRelativeScrollOffset(ghostRelativeParent),
|
|
1619
1634
|
dx = (touch.clientX - tapEvt.clientX + fallbackOffset.x) / (scaleX || 1) + (relativeScrollOffset ? relativeScrollOffset[0] - ghostRelativeParentInitialScroll[0] : 0) / (scaleX || 1),
|
|
1620
|
-
dy = (touch.clientY - tapEvt.clientY + fallbackOffset.y) / (scaleY || 1) + (relativeScrollOffset ? relativeScrollOffset[1] - ghostRelativeParentInitialScroll[1] : 0) / (scaleY || 1),
|
|
1621
|
-
translate3d = evt.touches ? 'translate3d(' + dx + 'px,' + dy + 'px,0)' : 'translate(' + dx + 'px,' + dy + 'px)'; // only set the status to dragging, when we are actually dragging
|
|
1635
|
+
dy = (touch.clientY - tapEvt.clientY + fallbackOffset.y) / (scaleY || 1) + (relativeScrollOffset ? relativeScrollOffset[1] - ghostRelativeParentInitialScroll[1] : 0) / (scaleY || 1); // only set the status to dragging, when we are actually dragging
|
|
1622
1636
|
|
|
1623
1637
|
if (!Sortable.active && !awaitingDragStarted) {
|
|
1624
1638
|
if (fallbackTolerance && Math.max(Math.abs(touch.clientX - this._lastX), Math.abs(touch.clientY - this._lastY)) < fallbackTolerance) {
|
|
@@ -1628,11 +1642,31 @@ Sortable.prototype =
|
|
|
1628
1642
|
this._onDragStart(evt, true);
|
|
1629
1643
|
}
|
|
1630
1644
|
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1645
|
+
if (ghostEl) {
|
|
1646
|
+
if (ghostMatrix) {
|
|
1647
|
+
ghostMatrix.e += dx - (lastDx || 0);
|
|
1648
|
+
ghostMatrix.f += dy - (lastDy || 0);
|
|
1649
|
+
} else {
|
|
1650
|
+
ghostMatrix = {
|
|
1651
|
+
a: 1,
|
|
1652
|
+
b: 0,
|
|
1653
|
+
c: 0,
|
|
1654
|
+
d: 1,
|
|
1655
|
+
e: dx,
|
|
1656
|
+
f: dy
|
|
1657
|
+
};
|
|
1658
|
+
}
|
|
1659
|
+
|
|
1660
|
+
var cssMatrix = "matrix(".concat(ghostMatrix.a, ",").concat(ghostMatrix.b, ",").concat(ghostMatrix.c, ",").concat(ghostMatrix.d, ",").concat(ghostMatrix.e, ",").concat(ghostMatrix.f, ")");
|
|
1661
|
+
css(ghostEl, 'webkitTransform', cssMatrix);
|
|
1662
|
+
css(ghostEl, 'mozTransform', cssMatrix);
|
|
1663
|
+
css(ghostEl, 'msTransform', cssMatrix);
|
|
1664
|
+
css(ghostEl, 'transform', cssMatrix);
|
|
1665
|
+
lastDx = dx;
|
|
1666
|
+
lastDy = dy;
|
|
1667
|
+
touchEvt = touch;
|
|
1668
|
+
}
|
|
1669
|
+
|
|
1636
1670
|
evt.cancelable && evt.preventDefault();
|
|
1637
1671
|
}
|
|
1638
1672
|
},
|
|
@@ -1680,7 +1714,9 @@ Sortable.prototype =
|
|
|
1680
1714
|
css(ghostEl, 'zIndex', '100000');
|
|
1681
1715
|
css(ghostEl, 'pointerEvents', 'none');
|
|
1682
1716
|
Sortable.ghost = ghostEl;
|
|
1683
|
-
container.appendChild(ghostEl);
|
|
1717
|
+
container.appendChild(ghostEl); // Set transform-origin
|
|
1718
|
+
|
|
1719
|
+
css(ghostEl, 'transform-origin', tapDistanceLeft / parseInt(ghostEl.style.width) * 100 + '% ' + tapDistanceTop / parseInt(ghostEl.style.height) * 100 + '%');
|
|
1684
1720
|
}
|
|
1685
1721
|
},
|
|
1686
1722
|
_onDragStart: function _onDragStart(
|
|
@@ -1959,7 +1995,7 @@ Sortable.prototype =
|
|
|
1959
1995
|
differentLevel = dragEl.parentNode !== el,
|
|
1960
1996
|
differentRowCol = !_dragElInRowColumn(dragEl.animated && dragEl.toRect || dragRect, target.animated && target.toRect || targetRect, vertical),
|
|
1961
1997
|
side1 = vertical ? 'top' : 'left',
|
|
1962
|
-
scrolledPastTop = isScrolledPast(target,
|
|
1998
|
+
scrolledPastTop = isScrolledPast(target, 'top', 'top') || isScrolledPast(dragEl, 'top', 'top'),
|
|
1963
1999
|
scrollBefore = scrolledPastTop ? scrolledPastTop.scrollTop : void 0;
|
|
1964
2000
|
|
|
1965
2001
|
if (lastTarget !== target) {
|
|
@@ -1968,7 +2004,7 @@ Sortable.prototype =
|
|
|
1968
2004
|
isCircumstantialInvert = !differentRowCol && options.invertSwap || differentLevel;
|
|
1969
2005
|
}
|
|
1970
2006
|
|
|
1971
|
-
direction = _getSwapDirection(evt, target, vertical, differentRowCol ? 1 : options.swapThreshold, options.invertedSwapThreshold == null ? options.swapThreshold : options.invertedSwapThreshold, isCircumstantialInvert, lastTarget === target);
|
|
2007
|
+
direction = _getSwapDirection(evt, target, targetRect, vertical, differentRowCol ? 1 : options.swapThreshold, options.invertedSwapThreshold == null ? options.swapThreshold : options.invertedSwapThreshold, isCircumstantialInvert, lastTarget === target);
|
|
1972
2008
|
var sibling;
|
|
1973
2009
|
|
|
1974
2010
|
if (direction !== 0) {
|
|
@@ -2060,7 +2096,8 @@ Sortable.prototype =
|
|
|
2060
2096
|
newDraggableIndex = index(dragEl, options.draggable);
|
|
2061
2097
|
pluginEvent('drop', this, {
|
|
2062
2098
|
evt: evt
|
|
2063
|
-
});
|
|
2099
|
+
});
|
|
2100
|
+
parentEl = dragEl && dragEl.parentNode; // Get again after plugin event
|
|
2064
2101
|
|
|
2065
2102
|
newIndex = index(dragEl);
|
|
2066
2103
|
newDraggableIndex = index(dragEl, options.draggable);
|
|
@@ -2095,6 +2132,8 @@ Sortable.prototype =
|
|
|
2095
2132
|
css(document.body, 'user-select', '');
|
|
2096
2133
|
}
|
|
2097
2134
|
|
|
2135
|
+
css(dragEl, 'transform', '');
|
|
2136
|
+
|
|
2098
2137
|
if (evt) {
|
|
2099
2138
|
if (moved) {
|
|
2100
2139
|
evt.cancelable && evt.preventDefault();
|
|
@@ -2219,7 +2258,7 @@ Sortable.prototype =
|
|
|
2219
2258
|
savedInputChecked.forEach(function (el) {
|
|
2220
2259
|
el.checked = true;
|
|
2221
2260
|
});
|
|
2222
|
-
savedInputChecked.length = 0;
|
|
2261
|
+
savedInputChecked.length = lastDx = lastDy = 0;
|
|
2223
2262
|
},
|
|
2224
2263
|
handleEvent: function handleEvent(
|
|
2225
2264
|
/**Event*/
|
|
@@ -2359,6 +2398,8 @@ Sortable.prototype =
|
|
|
2359
2398
|
|
|
2360
2399
|
this._onDrop();
|
|
2361
2400
|
|
|
2401
|
+
this._disableDelayedDragEvents();
|
|
2402
|
+
|
|
2362
2403
|
sortables.splice(sortables.indexOf(this.el), 1);
|
|
2363
2404
|
this.el = el = null;
|
|
2364
2405
|
},
|
|
@@ -2395,7 +2436,7 @@ Sortable.prototype =
|
|
|
2395
2436
|
}
|
|
2396
2437
|
|
|
2397
2438
|
if (this.options.group.revertClone) {
|
|
2398
|
-
this.
|
|
2439
|
+
this.animate(dragEl, cloneEl);
|
|
2399
2440
|
}
|
|
2400
2441
|
|
|
2401
2442
|
css(cloneEl, 'display', '');
|
|
@@ -2461,9 +2502,8 @@ function _ghostIsLast(evt, vertical, sortable) {
|
|
|
2461
2502
|
return vertical ? evt.clientX > rect.right + spacer || evt.clientX <= rect.right && evt.clientY > rect.bottom && evt.clientX >= rect.left : evt.clientX > rect.right && evt.clientY > rect.top || evt.clientX <= rect.right && evt.clientY > rect.bottom + spacer;
|
|
2462
2503
|
}
|
|
2463
2504
|
|
|
2464
|
-
function _getSwapDirection(evt, target, vertical, swapThreshold, invertedSwapThreshold, invertSwap, isLastTarget) {
|
|
2465
|
-
var
|
|
2466
|
-
mouseOnAxis = vertical ? evt.clientY : evt.clientX,
|
|
2505
|
+
function _getSwapDirection(evt, target, targetRect, vertical, swapThreshold, invertedSwapThreshold, invertSwap, isLastTarget) {
|
|
2506
|
+
var mouseOnAxis = vertical ? evt.clientY : evt.clientX,
|
|
2467
2507
|
targetLength = vertical ? targetRect.height : targetRect.width,
|
|
2468
2508
|
targetS1 = vertical ? targetRect.top : targetRect.left,
|
|
2469
2509
|
targetS2 = vertical ? targetRect.bottom : targetRect.right,
|
|
@@ -2548,8 +2588,8 @@ function _saveInputCheckedState(root) {
|
|
|
2548
2588
|
var idx = inputs.length;
|
|
2549
2589
|
|
|
2550
2590
|
while (idx--) {
|
|
2551
|
-
var
|
|
2552
|
-
|
|
2591
|
+
var el = inputs[idx];
|
|
2592
|
+
el.checked && savedInputChecked.push(el);
|
|
2553
2593
|
}
|
|
2554
2594
|
}
|
|
2555
2595
|
|
|
@@ -2562,11 +2602,14 @@ function _cancelNextTick(id) {
|
|
|
2562
2602
|
} // Fixed #973:
|
|
2563
2603
|
|
|
2564
2604
|
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
evt.
|
|
2568
|
-
|
|
2569
|
-
}
|
|
2605
|
+
if (documentExists) {
|
|
2606
|
+
on(document, 'touchmove', function (evt) {
|
|
2607
|
+
if ((Sortable.active || awaitingDragStarted) && evt.cancelable) {
|
|
2608
|
+
evt.preventDefault();
|
|
2609
|
+
}
|
|
2610
|
+
});
|
|
2611
|
+
} // Export utils
|
|
2612
|
+
|
|
2570
2613
|
|
|
2571
2614
|
Sortable.utils = {
|
|
2572
2615
|
on: on,
|
|
@@ -2587,28 +2630,35 @@ Sortable.utils = {
|
|
|
2587
2630
|
detectDirection: _detectDirection,
|
|
2588
2631
|
getChild: getChild
|
|
2589
2632
|
};
|
|
2633
|
+
/**
|
|
2634
|
+
* Get the Sortable instance of an element
|
|
2635
|
+
* @param {HTMLElement} element The element
|
|
2636
|
+
* @return {Sortable|undefined} The instance of Sortable
|
|
2637
|
+
*/
|
|
2638
|
+
|
|
2639
|
+
Sortable.get = function (element) {
|
|
2640
|
+
return element[expando];
|
|
2641
|
+
};
|
|
2590
2642
|
/**
|
|
2591
2643
|
* Mount a plugin to Sortable
|
|
2592
2644
|
* @param {...SortablePlugin|SortablePlugin[]} plugins Plugins being mounted
|
|
2593
2645
|
*/
|
|
2594
2646
|
|
|
2647
|
+
|
|
2595
2648
|
Sortable.mount = function () {
|
|
2596
2649
|
for (var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2597
2650
|
plugins[_key] = arguments[_key];
|
|
2598
2651
|
}
|
|
2599
2652
|
|
|
2600
2653
|
if (plugins[0].constructor === Array) plugins = plugins[0];
|
|
2601
|
-
|
|
2602
|
-
for (var i in plugins) {
|
|
2603
|
-
var plugin = plugins[i];
|
|
2604
|
-
|
|
2654
|
+
plugins.forEach(function (plugin) {
|
|
2605
2655
|
if (!plugin.prototype || !plugin.prototype.constructor) {
|
|
2606
|
-
throw "Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(
|
|
2656
|
+
throw "Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(plugin));
|
|
2607
2657
|
}
|
|
2608
2658
|
|
|
2609
2659
|
if (plugin.utils) Sortable.utils = _objectSpread({}, Sortable.utils, plugin.utils);
|
|
2610
2660
|
PluginManager.mount(plugin);
|
|
2611
|
-
}
|
|
2661
|
+
});
|
|
2612
2662
|
};
|
|
2613
2663
|
/**
|
|
2614
2664
|
* Create sortable instance
|
|
@@ -2635,7 +2685,7 @@ var autoScrolls = [],
|
|
|
2635
2685
|
|
|
2636
2686
|
function AutoScrollPlugin() {
|
|
2637
2687
|
function AutoScroll() {
|
|
2638
|
-
this.
|
|
2688
|
+
this.defaults = {
|
|
2639
2689
|
scroll: true,
|
|
2640
2690
|
scrollSensitivity: 30,
|
|
2641
2691
|
scrollSpeed: 10,
|
|
@@ -2656,7 +2706,7 @@ function AutoScrollPlugin() {
|
|
|
2656
2706
|
if (this.sortable.nativeDraggable) {
|
|
2657
2707
|
on(document, 'dragover', this._handleAutoScroll);
|
|
2658
2708
|
} else {
|
|
2659
|
-
if (this.
|
|
2709
|
+
if (this.options.supportPointer) {
|
|
2660
2710
|
on(document, 'pointermove', this._handleFallbackAutoScroll);
|
|
2661
2711
|
} else if (originalEvent.touches) {
|
|
2662
2712
|
on(document, 'touchmove', this._handleFallbackAutoScroll);
|
|
@@ -2669,7 +2719,7 @@ function AutoScrollPlugin() {
|
|
|
2669
2719
|
var originalEvent = _ref2.originalEvent;
|
|
2670
2720
|
|
|
2671
2721
|
// For when bubbling is canceled and using fallback (fallback 'touchmove' always reached)
|
|
2672
|
-
if (!this.
|
|
2722
|
+
if (!this.options.dragOverBubble && !originalEvent.rootEl) {
|
|
2673
2723
|
this._handleAutoScroll(originalEvent);
|
|
2674
2724
|
}
|
|
2675
2725
|
},
|
|
@@ -2696,8 +2746,8 @@ function AutoScrollPlugin() {
|
|
|
2696
2746
|
_handleAutoScroll: function _handleAutoScroll(evt, fallback) {
|
|
2697
2747
|
var _this = this;
|
|
2698
2748
|
|
|
2699
|
-
var x = evt.clientX,
|
|
2700
|
-
y = evt.clientY,
|
|
2749
|
+
var x = (evt.touches ? evt.touches[0] : evt).clientX,
|
|
2750
|
+
y = (evt.touches ? evt.touches[0] : evt).clientY,
|
|
2701
2751
|
elem = document.elementFromPoint(x, y);
|
|
2702
2752
|
touchEvt$1 = evt; // IE does not seem to have native autoscroll,
|
|
2703
2753
|
// Edge's autoscroll seems too conditional,
|
|
@@ -2727,7 +2777,7 @@ function AutoScrollPlugin() {
|
|
|
2727
2777
|
}
|
|
2728
2778
|
} else {
|
|
2729
2779
|
// if DnD is enabled (and browser has good autoscrolling), first autoscroll will already scroll, so get parent autoscroll of first autoscroll
|
|
2730
|
-
if (!this.
|
|
2780
|
+
if (!this.options.bubbleScroll || getParentAutoScrollElement(elem, true) === getWindowScrollingElement()) {
|
|
2731
2781
|
clearAutoScrolls();
|
|
2732
2782
|
return;
|
|
2733
2783
|
}
|
|
@@ -2756,7 +2806,9 @@ function clearPointerElemChangedInterval() {
|
|
|
2756
2806
|
var autoScroll = throttle(function (evt, options, rootEl, isFallback) {
|
|
2757
2807
|
// Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=505521
|
|
2758
2808
|
if (!options.scroll) return;
|
|
2759
|
-
var
|
|
2809
|
+
var x = (evt.touches ? evt.touches[0] : evt).clientX,
|
|
2810
|
+
y = (evt.touches ? evt.touches[0] : evt).clientY,
|
|
2811
|
+
sens = options.scrollSensitivity,
|
|
2760
2812
|
speed = options.scrollSpeed,
|
|
2761
2813
|
winScroller = getWindowScrollingElement();
|
|
2762
2814
|
var scrollThisInstance = false,
|
|
@@ -2801,8 +2853,8 @@ var autoScroll = throttle(function (evt, options, rootEl, isFallback) {
|
|
|
2801
2853
|
canScrollY = height < scrollHeight && (elCSS.overflowY === 'auto' || elCSS.overflowY === 'scroll');
|
|
2802
2854
|
}
|
|
2803
2855
|
|
|
2804
|
-
var vx = canScrollX && (Math.abs(right -
|
|
2805
|
-
var vy = canScrollY && (Math.abs(bottom -
|
|
2856
|
+
var vx = canScrollX && (Math.abs(right - x) <= sens && scrollPosX + width < scrollWidth) - (Math.abs(left - x) <= sens && !!scrollPosX);
|
|
2857
|
+
var vy = canScrollY && (Math.abs(bottom - y) <= sens && scrollPosY + height < scrollHeight) - (Math.abs(top - y) <= sens && !!scrollPosY);
|
|
2806
2858
|
|
|
2807
2859
|
if (!autoScrolls[layersOut]) {
|
|
2808
2860
|
for (var i = 0; i <= layersOut; i++) {
|
|
@@ -2859,14 +2911,19 @@ var drop = function drop(_ref) {
|
|
|
2859
2911
|
dispatchSortableEvent = _ref.dispatchSortableEvent,
|
|
2860
2912
|
hideGhostForTarget = _ref.hideGhostForTarget,
|
|
2861
2913
|
unhideGhostForTarget = _ref.unhideGhostForTarget;
|
|
2914
|
+
if (!originalEvent) return;
|
|
2862
2915
|
var toSortable = putSortable || activeSortable;
|
|
2863
2916
|
hideGhostForTarget();
|
|
2864
|
-
var
|
|
2917
|
+
var touch = originalEvent.changedTouches && originalEvent.changedTouches.length ? originalEvent.changedTouches[0] : originalEvent;
|
|
2918
|
+
var target = document.elementFromPoint(touch.clientX, touch.clientY);
|
|
2865
2919
|
unhideGhostForTarget();
|
|
2866
2920
|
|
|
2867
2921
|
if (toSortable && !toSortable.el.contains(target)) {
|
|
2868
2922
|
dispatchSortableEvent('spill');
|
|
2869
|
-
this.onSpill(
|
|
2923
|
+
this.onSpill({
|
|
2924
|
+
dragEl: dragEl,
|
|
2925
|
+
putSortable: putSortable
|
|
2926
|
+
});
|
|
2870
2927
|
}
|
|
2871
2928
|
};
|
|
2872
2929
|
|
|
@@ -2878,9 +2935,16 @@ Revert.prototype = {
|
|
|
2878
2935
|
var oldDraggableIndex = _ref2.oldDraggableIndex;
|
|
2879
2936
|
this.startIndex = oldDraggableIndex;
|
|
2880
2937
|
},
|
|
2881
|
-
onSpill: function onSpill(
|
|
2938
|
+
onSpill: function onSpill(_ref3) {
|
|
2939
|
+
var dragEl = _ref3.dragEl,
|
|
2940
|
+
putSortable = _ref3.putSortable;
|
|
2882
2941
|
this.sortable.captureAnimationState();
|
|
2883
|
-
|
|
2942
|
+
|
|
2943
|
+
if (putSortable) {
|
|
2944
|
+
putSortable.captureAnimationState();
|
|
2945
|
+
}
|
|
2946
|
+
|
|
2947
|
+
var nextSibling = getChild(this.sortable.el, this.startIndex, this.options);
|
|
2884
2948
|
|
|
2885
2949
|
if (nextSibling) {
|
|
2886
2950
|
this.sortable.el.insertBefore(dragEl, nextSibling);
|
|
@@ -2889,6 +2953,10 @@ Revert.prototype = {
|
|
|
2889
2953
|
}
|
|
2890
2954
|
|
|
2891
2955
|
this.sortable.animateAll();
|
|
2956
|
+
|
|
2957
|
+
if (putSortable) {
|
|
2958
|
+
putSortable.animateAll();
|
|
2959
|
+
}
|
|
2892
2960
|
},
|
|
2893
2961
|
drop: drop
|
|
2894
2962
|
};
|
|
@@ -2900,10 +2968,13 @@ _extends(Revert, {
|
|
|
2900
2968
|
function Remove() {}
|
|
2901
2969
|
|
|
2902
2970
|
Remove.prototype = {
|
|
2903
|
-
onSpill: function onSpill(
|
|
2904
|
-
|
|
2971
|
+
onSpill: function onSpill(_ref4) {
|
|
2972
|
+
var dragEl = _ref4.dragEl,
|
|
2973
|
+
putSortable = _ref4.putSortable;
|
|
2974
|
+
var parentSortable = putSortable || this.sortable;
|
|
2975
|
+
parentSortable.captureAnimationState();
|
|
2905
2976
|
dragEl.parentNode && dragEl.parentNode.removeChild(dragEl);
|
|
2906
|
-
|
|
2977
|
+
parentSortable.animateAll();
|
|
2907
2978
|
},
|
|
2908
2979
|
drop: drop
|
|
2909
2980
|
};
|
|
@@ -2918,7 +2989,7 @@ var lastSwapEl;
|
|
|
2918
2989
|
|
|
2919
2990
|
function SwapPlugin() {
|
|
2920
2991
|
function Swap() {
|
|
2921
|
-
this.
|
|
2992
|
+
this.defaults = {
|
|
2922
2993
|
swapClass: 'sortable-swap-highlight'
|
|
2923
2994
|
};
|
|
2924
2995
|
}
|
|
@@ -2933,10 +3004,11 @@ function SwapPlugin() {
|
|
|
2933
3004
|
target = _ref2.target,
|
|
2934
3005
|
onMove = _ref2.onMove,
|
|
2935
3006
|
activeSortable = _ref2.activeSortable,
|
|
2936
|
-
changed = _ref2.changed
|
|
3007
|
+
changed = _ref2.changed,
|
|
3008
|
+
cancel = _ref2.cancel;
|
|
2937
3009
|
if (!activeSortable.options.swap) return;
|
|
2938
3010
|
var el = this.sortable.el,
|
|
2939
|
-
options = this.
|
|
3011
|
+
options = this.options;
|
|
2940
3012
|
|
|
2941
3013
|
if (target && target !== el) {
|
|
2942
3014
|
var prevSwapEl = lastSwapEl;
|
|
@@ -2954,14 +3026,15 @@ function SwapPlugin() {
|
|
|
2954
3026
|
}
|
|
2955
3027
|
|
|
2956
3028
|
changed();
|
|
2957
|
-
|
|
3029
|
+
completed(true);
|
|
3030
|
+
cancel();
|
|
2958
3031
|
},
|
|
2959
3032
|
drop: function drop(_ref3) {
|
|
2960
3033
|
var activeSortable = _ref3.activeSortable,
|
|
2961
3034
|
putSortable = _ref3.putSortable,
|
|
2962
3035
|
dragEl = _ref3.dragEl;
|
|
2963
3036
|
var toSortable = putSortable || this.sortable;
|
|
2964
|
-
var options = this.
|
|
3037
|
+
var options = this.options;
|
|
2965
3038
|
lastSwapEl && toggleClass(lastSwapEl, options.swapClass, false);
|
|
2966
3039
|
|
|
2967
3040
|
if (lastSwapEl && (options.swap || putSortable && putSortable.options.swap)) {
|
|
@@ -2980,7 +3053,7 @@ function SwapPlugin() {
|
|
|
2980
3053
|
};
|
|
2981
3054
|
return _extends(Swap, {
|
|
2982
3055
|
pluginName: 'swap',
|
|
2983
|
-
|
|
3056
|
+
eventProperties: function eventProperties() {
|
|
2984
3057
|
return {
|
|
2985
3058
|
swapItem: lastSwapEl
|
|
2986
3059
|
};
|
|
@@ -3037,16 +3110,16 @@ function MultiDragPlugin() {
|
|
|
3037
3110
|
|
|
3038
3111
|
on(document, 'keydown', this._checkKeyDown);
|
|
3039
3112
|
on(document, 'keyup', this._checkKeyUp);
|
|
3040
|
-
this.
|
|
3113
|
+
this.defaults = {
|
|
3041
3114
|
selectedClass: 'sortable-selected',
|
|
3042
3115
|
multiDragKey: null,
|
|
3043
3116
|
setData: function setData(dataTransfer, dragEl) {
|
|
3044
3117
|
var data = '';
|
|
3045
3118
|
|
|
3046
3119
|
if (multiDragElements.length && multiDragSortable === sortable) {
|
|
3047
|
-
|
|
3048
|
-
data += (!i ? '' : ', ') +
|
|
3049
|
-
}
|
|
3120
|
+
multiDragElements.forEach(function (multiDragElement, i) {
|
|
3121
|
+
data += (!i ? '' : ', ') + multiDragElement.textContent;
|
|
3122
|
+
});
|
|
3050
3123
|
} else {
|
|
3051
3124
|
data = dragEl.textContent;
|
|
3052
3125
|
}
|
|
@@ -3067,66 +3140,68 @@ function MultiDragPlugin() {
|
|
|
3067
3140
|
this.isMultiDrag = ~multiDragElements.indexOf(dragEl$1);
|
|
3068
3141
|
},
|
|
3069
3142
|
setupClone: function setupClone(_ref2) {
|
|
3070
|
-
var sortable = _ref2.sortable
|
|
3143
|
+
var sortable = _ref2.sortable,
|
|
3144
|
+
cancel = _ref2.cancel;
|
|
3071
3145
|
if (!this.isMultiDrag) return;
|
|
3072
3146
|
|
|
3073
|
-
for (var i
|
|
3147
|
+
for (var i = 0; i < multiDragElements.length; i++) {
|
|
3074
3148
|
multiDragClones.push(clone(multiDragElements[i]));
|
|
3075
3149
|
multiDragClones[i].sortableIndex = multiDragElements[i].sortableIndex;
|
|
3076
3150
|
multiDragClones[i].draggable = false;
|
|
3077
3151
|
multiDragClones[i].style['will-change'] = '';
|
|
3078
|
-
toggleClass(multiDragClones[i],
|
|
3079
|
-
multiDragElements[i] === dragEl$1 && toggleClass(multiDragClones[i],
|
|
3152
|
+
toggleClass(multiDragClones[i], this.options.selectedClass, false);
|
|
3153
|
+
multiDragElements[i] === dragEl$1 && toggleClass(multiDragClones[i], this.options.chosenClass, false);
|
|
3080
3154
|
}
|
|
3081
3155
|
|
|
3082
3156
|
sortable._hideClone();
|
|
3083
3157
|
|
|
3084
|
-
|
|
3158
|
+
cancel();
|
|
3085
3159
|
},
|
|
3086
3160
|
clone: function clone(_ref3) {
|
|
3087
3161
|
var sortable = _ref3.sortable,
|
|
3088
3162
|
rootEl = _ref3.rootEl,
|
|
3089
|
-
dispatchSortableEvent = _ref3.dispatchSortableEvent
|
|
3163
|
+
dispatchSortableEvent = _ref3.dispatchSortableEvent,
|
|
3164
|
+
cancel = _ref3.cancel;
|
|
3090
3165
|
if (!this.isMultiDrag) return;
|
|
3091
3166
|
|
|
3092
|
-
if (!
|
|
3167
|
+
if (!this.options.removeCloneOnHide) {
|
|
3093
3168
|
if (multiDragElements.length && multiDragSortable === sortable) {
|
|
3094
3169
|
insertMultiDragClones(true, rootEl);
|
|
3095
3170
|
dispatchSortableEvent('clone');
|
|
3096
|
-
|
|
3171
|
+
cancel();
|
|
3097
3172
|
}
|
|
3098
3173
|
}
|
|
3099
3174
|
},
|
|
3100
3175
|
showClone: function showClone(_ref4) {
|
|
3101
3176
|
var cloneNowShown = _ref4.cloneNowShown,
|
|
3102
|
-
rootEl = _ref4.rootEl
|
|
3177
|
+
rootEl = _ref4.rootEl,
|
|
3178
|
+
cancel = _ref4.cancel;
|
|
3103
3179
|
if (!this.isMultiDrag) return;
|
|
3104
3180
|
insertMultiDragClones(false, rootEl);
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
}
|
|
3109
|
-
|
|
3181
|
+
multiDragClones.forEach(function (clone) {
|
|
3182
|
+
css(clone, 'display', '');
|
|
3183
|
+
});
|
|
3110
3184
|
cloneNowShown();
|
|
3111
3185
|
clonesHidden = false;
|
|
3112
|
-
|
|
3186
|
+
cancel();
|
|
3113
3187
|
},
|
|
3114
3188
|
hideClone: function hideClone(_ref5) {
|
|
3189
|
+
var _this = this;
|
|
3190
|
+
|
|
3115
3191
|
var sortable = _ref5.sortable,
|
|
3116
|
-
cloneNowHidden = _ref5.cloneNowHidden
|
|
3192
|
+
cloneNowHidden = _ref5.cloneNowHidden,
|
|
3193
|
+
cancel = _ref5.cancel;
|
|
3117
3194
|
if (!this.isMultiDrag) return;
|
|
3195
|
+
multiDragClones.forEach(function (clone) {
|
|
3196
|
+
css(clone, 'display', 'none');
|
|
3118
3197
|
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
if (sortable.options.removeCloneOnHide && multiDragClones[i].parentNode) {
|
|
3123
|
-
multiDragClones[i].parentNode.removeChild(multiDragClones[i]);
|
|
3198
|
+
if (_this.options.removeCloneOnHide && clone.parentNode) {
|
|
3199
|
+
clone.parentNode.removeChild(clone);
|
|
3124
3200
|
}
|
|
3125
|
-
}
|
|
3126
|
-
|
|
3201
|
+
});
|
|
3127
3202
|
cloneNowHidden();
|
|
3128
3203
|
clonesHidden = true;
|
|
3129
|
-
|
|
3204
|
+
cancel();
|
|
3130
3205
|
},
|
|
3131
3206
|
dragStartGlobal: function dragStartGlobal(_ref6) {
|
|
3132
3207
|
var sortable = _ref6.sortable;
|
|
@@ -3135,10 +3210,9 @@ function MultiDragPlugin() {
|
|
|
3135
3210
|
multiDragSortable.multiDrag._deselectMultiDrag();
|
|
3136
3211
|
}
|
|
3137
3212
|
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
} // Sort multi-drag elements
|
|
3141
|
-
|
|
3213
|
+
multiDragElements.forEach(function (multiDragElement) {
|
|
3214
|
+
multiDragElement.sortableIndex = index(multiDragElement);
|
|
3215
|
+
}); // Sort multi-drag elements
|
|
3142
3216
|
|
|
3143
3217
|
multiDragElements = multiDragElements.sort(function (a, b) {
|
|
3144
3218
|
return a.sortableIndex - b.sortableIndex;
|
|
@@ -3146,10 +3220,12 @@ function MultiDragPlugin() {
|
|
|
3146
3220
|
dragStarted = true;
|
|
3147
3221
|
},
|
|
3148
3222
|
dragStarted: function dragStarted(_ref7) {
|
|
3223
|
+
var _this2 = this;
|
|
3224
|
+
|
|
3149
3225
|
var sortable = _ref7.sortable;
|
|
3150
3226
|
if (!this.isMultiDrag) return;
|
|
3151
3227
|
|
|
3152
|
-
if (
|
|
3228
|
+
if (this.options.sort) {
|
|
3153
3229
|
// Capture rects,
|
|
3154
3230
|
// hide multi drag elements (by positioning them absolute),
|
|
3155
3231
|
// set multi drag elements rects to dragRect,
|
|
@@ -3158,19 +3234,16 @@ function MultiDragPlugin() {
|
|
|
3158
3234
|
// unset rects & remove from DOM
|
|
3159
3235
|
sortable.captureAnimationState();
|
|
3160
3236
|
|
|
3161
|
-
if (
|
|
3162
|
-
|
|
3163
|
-
if (
|
|
3164
|
-
css(
|
|
3165
|
-
}
|
|
3166
|
-
|
|
3237
|
+
if (this.options.animation) {
|
|
3238
|
+
multiDragElements.forEach(function (multiDragElement) {
|
|
3239
|
+
if (multiDragElement === dragEl$1) return;
|
|
3240
|
+
css(multiDragElement, 'position', 'absolute');
|
|
3241
|
+
});
|
|
3167
3242
|
var dragRect = getRect(dragEl$1, false, true, true);
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
}
|
|
3173
|
-
|
|
3243
|
+
multiDragElements.forEach(function (multiDragElement) {
|
|
3244
|
+
if (multiDragElement === dragEl$1) return;
|
|
3245
|
+
setRect(multiDragElement, dragRect);
|
|
3246
|
+
});
|
|
3174
3247
|
folding = true;
|
|
3175
3248
|
initialFolding = true;
|
|
3176
3249
|
}
|
|
@@ -3180,24 +3253,26 @@ function MultiDragPlugin() {
|
|
|
3180
3253
|
folding = false;
|
|
3181
3254
|
initialFolding = false;
|
|
3182
3255
|
|
|
3183
|
-
if (
|
|
3184
|
-
|
|
3185
|
-
unsetRect(
|
|
3186
|
-
}
|
|
3256
|
+
if (_this2.options.animation) {
|
|
3257
|
+
multiDragElements.forEach(function (multiDragElement) {
|
|
3258
|
+
unsetRect(multiDragElement);
|
|
3259
|
+
});
|
|
3187
3260
|
} // Remove all auxiliary multidrag items from el, if sorting enabled
|
|
3188
3261
|
|
|
3189
3262
|
|
|
3190
|
-
if (
|
|
3263
|
+
if (_this2.options.sort) {
|
|
3191
3264
|
removeMultiDragElements();
|
|
3192
3265
|
}
|
|
3193
3266
|
});
|
|
3194
3267
|
},
|
|
3195
3268
|
dragOver: function dragOver(_ref8) {
|
|
3196
3269
|
var target = _ref8.target,
|
|
3197
|
-
completed = _ref8.completed
|
|
3270
|
+
completed = _ref8.completed,
|
|
3271
|
+
cancel = _ref8.cancel;
|
|
3198
3272
|
|
|
3199
3273
|
if (folding && ~multiDragElements.indexOf(target)) {
|
|
3200
|
-
|
|
3274
|
+
completed(false);
|
|
3275
|
+
cancel();
|
|
3201
3276
|
}
|
|
3202
3277
|
},
|
|
3203
3278
|
revert: function revert(_ref9) {
|
|
@@ -3208,18 +3283,17 @@ function MultiDragPlugin() {
|
|
|
3208
3283
|
|
|
3209
3284
|
if (multiDragElements.length > 1) {
|
|
3210
3285
|
// Setup unfold animation
|
|
3211
|
-
|
|
3286
|
+
multiDragElements.forEach(function (multiDragElement) {
|
|
3212
3287
|
sortable.addAnimationState({
|
|
3213
|
-
target:
|
|
3214
|
-
rect: folding ? getRect(
|
|
3288
|
+
target: multiDragElement,
|
|
3289
|
+
rect: folding ? getRect(multiDragElement) : dragRect
|
|
3215
3290
|
});
|
|
3216
|
-
unsetRect(
|
|
3217
|
-
|
|
3218
|
-
fromSortable.removeAnimationState(
|
|
3219
|
-
}
|
|
3220
|
-
|
|
3291
|
+
unsetRect(multiDragElement);
|
|
3292
|
+
multiDragElement.fromRect = dragRect;
|
|
3293
|
+
fromSortable.removeAnimationState(multiDragElement);
|
|
3294
|
+
});
|
|
3221
3295
|
folding = false;
|
|
3222
|
-
insertMultiDragElements(!
|
|
3296
|
+
insertMultiDragElements(!this.options.removeCloneOnHide, rootEl);
|
|
3223
3297
|
}
|
|
3224
3298
|
},
|
|
3225
3299
|
dragOverCompleted: function dragOverCompleted(_ref10) {
|
|
@@ -3229,7 +3303,7 @@ function MultiDragPlugin() {
|
|
|
3229
3303
|
activeSortable = _ref10.activeSortable,
|
|
3230
3304
|
parentEl = _ref10.parentEl,
|
|
3231
3305
|
putSortable = _ref10.putSortable;
|
|
3232
|
-
var options =
|
|
3306
|
+
var options = this.options;
|
|
3233
3307
|
|
|
3234
3308
|
if (insertion) {
|
|
3235
3309
|
// Clones must be hidden before folding animation to capture dragRectAbsolute properly
|
|
@@ -3242,15 +3316,13 @@ function MultiDragPlugin() {
|
|
|
3242
3316
|
if (options.animation && multiDragElements.length > 1 && (folding || !isOwner && !activeSortable.options.sort && !putSortable)) {
|
|
3243
3317
|
// Fold: Set all multi drag elements's rects to dragEl's rect when multi-drag elements are invisible
|
|
3244
3318
|
var dragRectAbsolute = getRect(dragEl$1, false, true, true);
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
setRect(multiDragElements[i], dragRectAbsolute); // Move element(s) to end of parentEl so that it does not interfere with multi-drag clones insertion if they are inserted
|
|
3319
|
+
multiDragElements.forEach(function (multiDragElement) {
|
|
3320
|
+
if (multiDragElement === dragEl$1) return;
|
|
3321
|
+
setRect(multiDragElement, dragRectAbsolute); // Move element(s) to end of parentEl so that it does not interfere with multi-drag clones insertion if they are inserted
|
|
3249
3322
|
// while folding, and so that we can capture them again because old sortable will no longer be fromSortable
|
|
3250
3323
|
|
|
3251
|
-
parentEl.appendChild(
|
|
3252
|
-
}
|
|
3253
|
-
|
|
3324
|
+
parentEl.appendChild(multiDragElement);
|
|
3325
|
+
});
|
|
3254
3326
|
folding = true;
|
|
3255
3327
|
} // Clones must be shown (and check to remove multi drags) after folding when interfering multiDragElements are moved out
|
|
3256
3328
|
|
|
@@ -3268,14 +3340,14 @@ function MultiDragPlugin() {
|
|
|
3268
3340
|
|
|
3269
3341
|
|
|
3270
3342
|
if (activeSortable.options.animation && !clonesHidden && clonesHiddenBefore) {
|
|
3271
|
-
|
|
3343
|
+
multiDragClones.forEach(function (clone) {
|
|
3272
3344
|
activeSortable.addAnimationState({
|
|
3273
|
-
target:
|
|
3345
|
+
target: clone,
|
|
3274
3346
|
rect: clonesFromRect
|
|
3275
3347
|
});
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
}
|
|
3348
|
+
clone.fromRect = clonesFromRect;
|
|
3349
|
+
clone.thisAnimationDuration = null;
|
|
3350
|
+
});
|
|
3279
3351
|
}
|
|
3280
3352
|
} else {
|
|
3281
3353
|
activeSortable._showClone(sortable);
|
|
@@ -3287,10 +3359,9 @@ function MultiDragPlugin() {
|
|
|
3287
3359
|
var dragRect = _ref11.dragRect,
|
|
3288
3360
|
isOwner = _ref11.isOwner,
|
|
3289
3361
|
activeSortable = _ref11.activeSortable;
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
}
|
|
3362
|
+
multiDragElements.forEach(function (multiDragElement) {
|
|
3363
|
+
multiDragElement.thisAnimationDuration = null;
|
|
3364
|
+
});
|
|
3294
3365
|
|
|
3295
3366
|
if (activeSortable.options.animation && !isOwner && activeSortable.multiDrag.isMultiDrag) {
|
|
3296
3367
|
clonesFromRect = _extends({}, dragRect);
|
|
@@ -3315,7 +3386,7 @@ function MultiDragPlugin() {
|
|
|
3315
3386
|
putSortable = _ref12.putSortable;
|
|
3316
3387
|
var toSortable = putSortable || this.sortable;
|
|
3317
3388
|
if (!evt) return;
|
|
3318
|
-
var options =
|
|
3389
|
+
var options = this.options,
|
|
3319
3390
|
children = parentEl.children; // Multi-drag selection
|
|
3320
3391
|
|
|
3321
3392
|
if (!dragStarted) {
|
|
@@ -3335,7 +3406,7 @@ function MultiDragPlugin() {
|
|
|
3335
3406
|
originalEvt: evt
|
|
3336
3407
|
}); // Modifier activated, select from last to dragEl
|
|
3337
3408
|
|
|
3338
|
-
if (
|
|
3409
|
+
if (evt.shiftKey && lastMultiDragSelect && sortable.el.contains(lastMultiDragSelect)) {
|
|
3339
3410
|
var lastIndex = index(lastMultiDragSelect),
|
|
3340
3411
|
currentIndex = index(dragEl$1);
|
|
3341
3412
|
|
|
@@ -3395,48 +3466,44 @@ function MultiDragPlugin() {
|
|
|
3395
3466
|
if (!initialFolding) {
|
|
3396
3467
|
if (options.animation) {
|
|
3397
3468
|
dragEl$1.fromRect = dragRect;
|
|
3469
|
+
multiDragElements.forEach(function (multiDragElement) {
|
|
3470
|
+
multiDragElement.thisAnimationDuration = null;
|
|
3398
3471
|
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
if (multiDragElements[_i4] !== dragEl$1) {
|
|
3403
|
-
var rect = folding ? getRect(multiDragElements[_i4]) : dragRect;
|
|
3404
|
-
multiDragElements[_i4].fromRect = rect; // Prepare unfold animation
|
|
3472
|
+
if (multiDragElement !== dragEl$1) {
|
|
3473
|
+
var rect = folding ? getRect(multiDragElement) : dragRect;
|
|
3474
|
+
multiDragElement.fromRect = rect; // Prepare unfold animation
|
|
3405
3475
|
|
|
3406
3476
|
toSortable.addAnimationState({
|
|
3407
|
-
target:
|
|
3477
|
+
target: multiDragElement,
|
|
3408
3478
|
rect: rect
|
|
3409
3479
|
});
|
|
3410
3480
|
}
|
|
3411
|
-
}
|
|
3481
|
+
});
|
|
3412
3482
|
} // Multi drag elements are not necessarily removed from the DOM on drop, so to reinsert
|
|
3413
3483
|
// properly they must all be removed
|
|
3414
3484
|
|
|
3415
3485
|
|
|
3416
3486
|
removeMultiDragElements();
|
|
3417
|
-
|
|
3418
|
-
for (var _i5 in multiDragElements) {
|
|
3487
|
+
multiDragElements.forEach(function (multiDragElement) {
|
|
3419
3488
|
if (children[multiDragIndex]) {
|
|
3420
|
-
parentEl.insertBefore(
|
|
3489
|
+
parentEl.insertBefore(multiDragElement, children[multiDragIndex]);
|
|
3421
3490
|
} else {
|
|
3422
|
-
parentEl.appendChild(
|
|
3491
|
+
parentEl.appendChild(multiDragElement);
|
|
3423
3492
|
}
|
|
3424
3493
|
|
|
3425
3494
|
multiDragIndex++;
|
|
3426
|
-
} // If initial folding is done, the elements may have changed position because they are now
|
|
3495
|
+
}); // If initial folding is done, the elements may have changed position because they are now
|
|
3427
3496
|
// unfolding around dragEl, even though dragEl may not have his index changed, so update event
|
|
3428
3497
|
// must be fired here as Sortable will not.
|
|
3429
3498
|
|
|
3430
|
-
|
|
3431
3499
|
if (oldIndex === index(dragEl$1)) {
|
|
3432
3500
|
var update = false;
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
if (multiDragElements[_i6].sortableIndex !== index(multiDragElements[_i6])) {
|
|
3501
|
+
multiDragElements.forEach(function (multiDragElement) {
|
|
3502
|
+
if (multiDragElement.sortableIndex !== index(multiDragElement)) {
|
|
3436
3503
|
update = true;
|
|
3437
|
-
|
|
3504
|
+
return;
|
|
3438
3505
|
}
|
|
3439
|
-
}
|
|
3506
|
+
});
|
|
3440
3507
|
|
|
3441
3508
|
if (update) {
|
|
3442
3509
|
dispatchSortableEvent('update');
|
|
@@ -3445,10 +3512,9 @@ function MultiDragPlugin() {
|
|
|
3445
3512
|
} // Must be done after capturing individual rects (scroll bar)
|
|
3446
3513
|
|
|
3447
3514
|
|
|
3448
|
-
|
|
3449
|
-
unsetRect(
|
|
3450
|
-
}
|
|
3451
|
-
|
|
3515
|
+
multiDragElements.forEach(function (multiDragElement) {
|
|
3516
|
+
unsetRect(multiDragElement);
|
|
3517
|
+
});
|
|
3452
3518
|
toSortable.animateAll();
|
|
3453
3519
|
}
|
|
3454
3520
|
|
|
@@ -3457,16 +3523,16 @@ function MultiDragPlugin() {
|
|
|
3457
3523
|
|
|
3458
3524
|
|
|
3459
3525
|
if (rootEl === parentEl || putSortable && putSortable.lastPutMode !== 'clone') {
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
}
|
|
3526
|
+
multiDragClones.forEach(function (clone) {
|
|
3527
|
+
clone.parentNode && clone.parentNode.removeChild(clone);
|
|
3528
|
+
});
|
|
3463
3529
|
}
|
|
3464
3530
|
},
|
|
3465
3531
|
nullingGlobal: function nullingGlobal() {
|
|
3466
3532
|
this.isMultiDrag = dragStarted = false;
|
|
3467
3533
|
multiDragClones.length = 0;
|
|
3468
3534
|
},
|
|
3469
|
-
|
|
3535
|
+
destroyGlobal: function destroyGlobal() {
|
|
3470
3536
|
this._deselectMultiDrag();
|
|
3471
3537
|
|
|
3472
3538
|
off(document, 'pointerup', this._deselectMultiDrag);
|
|
@@ -3476,17 +3542,17 @@ function MultiDragPlugin() {
|
|
|
3476
3542
|
off(document, 'keyup', this._checkKeyUp);
|
|
3477
3543
|
},
|
|
3478
3544
|
_deselectMultiDrag: function _deselectMultiDrag(evt) {
|
|
3479
|
-
if (dragStarted) return; // Only deselect if selection is in this sortable
|
|
3545
|
+
if (typeof dragStarted !== "undefined" && dragStarted) return; // Only deselect if selection is in this sortable
|
|
3480
3546
|
|
|
3481
3547
|
if (multiDragSortable !== this.sortable) return; // Only deselect if target is not item in this sortable
|
|
3482
3548
|
|
|
3483
|
-
if (evt && closest(evt.target, this.
|
|
3549
|
+
if (evt && closest(evt.target, this.options.draggable, this.sortable.el, false)) return; // Only deselect if left click
|
|
3484
3550
|
|
|
3485
3551
|
if (evt && evt.button !== 0) return;
|
|
3486
3552
|
|
|
3487
3553
|
while (multiDragElements.length) {
|
|
3488
3554
|
var el = multiDragElements[0];
|
|
3489
|
-
toggleClass(el, this.
|
|
3555
|
+
toggleClass(el, this.options.selectedClass, false);
|
|
3490
3556
|
multiDragElements.shift();
|
|
3491
3557
|
dispatchEvent({
|
|
3492
3558
|
sortable: this.sortable,
|
|
@@ -3498,12 +3564,12 @@ function MultiDragPlugin() {
|
|
|
3498
3564
|
}
|
|
3499
3565
|
},
|
|
3500
3566
|
_checkKeyDown: function _checkKeyDown(evt) {
|
|
3501
|
-
if (evt.key === this.
|
|
3567
|
+
if (evt.key === this.options.multiDragKey) {
|
|
3502
3568
|
this.multiDragKeyDown = true;
|
|
3503
3569
|
}
|
|
3504
3570
|
},
|
|
3505
3571
|
_checkKeyUp: function _checkKeyUp(evt) {
|
|
3506
|
-
if (evt.key === this.
|
|
3572
|
+
if (evt.key === this.options.multiDragKey) {
|
|
3507
3573
|
this.multiDragKeyDown = false;
|
|
3508
3574
|
}
|
|
3509
3575
|
}
|
|
@@ -3512,9 +3578,9 @@ function MultiDragPlugin() {
|
|
|
3512
3578
|
// Static methods & properties
|
|
3513
3579
|
pluginName: 'multiDrag',
|
|
3514
3580
|
utils: {
|
|
3515
|
-
/**
|
|
3516
|
-
* Selects the provided multi-drag item
|
|
3517
|
-
* @param {HTMLElement} el The element to be selected
|
|
3581
|
+
/**
|
|
3582
|
+
* Selects the provided multi-drag item
|
|
3583
|
+
* @param {HTMLElement} el The element to be selected
|
|
3518
3584
|
*/
|
|
3519
3585
|
select: function select(el) {
|
|
3520
3586
|
var sortable = el.parentNode[expando];
|
|
@@ -3530,9 +3596,9 @@ function MultiDragPlugin() {
|
|
|
3530
3596
|
multiDragElements.push(el);
|
|
3531
3597
|
},
|
|
3532
3598
|
|
|
3533
|
-
/**
|
|
3534
|
-
* Deselects the provided multi-drag item
|
|
3535
|
-
* @param {HTMLElement} el The element to be deselected
|
|
3599
|
+
/**
|
|
3600
|
+
* Deselects the provided multi-drag item
|
|
3601
|
+
* @param {HTMLElement} el The element to be deselected
|
|
3536
3602
|
*/
|
|
3537
3603
|
deselect: function deselect(el) {
|
|
3538
3604
|
var sortable = el.parentNode[expando],
|
|
@@ -3542,29 +3608,29 @@ function MultiDragPlugin() {
|
|
|
3542
3608
|
multiDragElements.splice(index, 1);
|
|
3543
3609
|
}
|
|
3544
3610
|
},
|
|
3545
|
-
|
|
3546
|
-
var
|
|
3611
|
+
eventProperties: function eventProperties() {
|
|
3612
|
+
var _this3 = this;
|
|
3547
3613
|
|
|
3548
3614
|
var oldIndicies = [],
|
|
3549
3615
|
newIndicies = [];
|
|
3550
|
-
multiDragElements.forEach(function (
|
|
3616
|
+
multiDragElements.forEach(function (multiDragElement) {
|
|
3551
3617
|
oldIndicies.push({
|
|
3552
|
-
|
|
3553
|
-
index:
|
|
3618
|
+
multiDragElement: multiDragElement,
|
|
3619
|
+
index: multiDragElement.sortableIndex
|
|
3554
3620
|
}); // multiDragElements will already be sorted if folding
|
|
3555
3621
|
|
|
3556
3622
|
var newIndex;
|
|
3557
3623
|
|
|
3558
|
-
if (folding &&
|
|
3624
|
+
if (folding && multiDragElement !== dragEl$1) {
|
|
3559
3625
|
newIndex = -1;
|
|
3560
3626
|
} else if (folding) {
|
|
3561
|
-
newIndex = index(
|
|
3627
|
+
newIndex = index(multiDragElement, ':not(.' + _this3.options.selectedClass + ')');
|
|
3562
3628
|
} else {
|
|
3563
|
-
newIndex = index(
|
|
3629
|
+
newIndex = index(multiDragElement);
|
|
3564
3630
|
}
|
|
3565
3631
|
|
|
3566
3632
|
newIndicies.push({
|
|
3567
|
-
|
|
3633
|
+
multiDragElement: multiDragElement,
|
|
3568
3634
|
index: newIndex
|
|
3569
3635
|
});
|
|
3570
3636
|
});
|
|
@@ -3592,40 +3658,40 @@ function MultiDragPlugin() {
|
|
|
3592
3658
|
}
|
|
3593
3659
|
|
|
3594
3660
|
function insertMultiDragElements(clonesInserted, rootEl) {
|
|
3595
|
-
|
|
3596
|
-
var target = rootEl.children[
|
|
3661
|
+
multiDragElements.forEach(function (multiDragElement, i) {
|
|
3662
|
+
var target = rootEl.children[multiDragElement.sortableIndex + (clonesInserted ? Number(i) : 0)];
|
|
3597
3663
|
|
|
3598
3664
|
if (target) {
|
|
3599
|
-
rootEl.insertBefore(
|
|
3665
|
+
rootEl.insertBefore(multiDragElement, target);
|
|
3600
3666
|
} else {
|
|
3601
|
-
rootEl.appendChild(
|
|
3667
|
+
rootEl.appendChild(multiDragElement);
|
|
3602
3668
|
}
|
|
3603
|
-
}
|
|
3669
|
+
});
|
|
3604
3670
|
}
|
|
3605
|
-
/**
|
|
3606
|
-
* Insert multi-drag clones
|
|
3607
|
-
* @param {[Boolean]} elementsInserted Whether the multi-drag elements are inserted
|
|
3608
|
-
* @param {HTMLElement} rootEl
|
|
3671
|
+
/**
|
|
3672
|
+
* Insert multi-drag clones
|
|
3673
|
+
* @param {[Boolean]} elementsInserted Whether the multi-drag elements are inserted
|
|
3674
|
+
* @param {HTMLElement} rootEl
|
|
3609
3675
|
*/
|
|
3610
3676
|
|
|
3611
3677
|
|
|
3612
3678
|
function insertMultiDragClones(elementsInserted, rootEl) {
|
|
3613
|
-
|
|
3614
|
-
var target = rootEl.children[
|
|
3679
|
+
multiDragClones.forEach(function (clone, i) {
|
|
3680
|
+
var target = rootEl.children[clone.sortableIndex + (elementsInserted ? Number(i) : 0)];
|
|
3615
3681
|
|
|
3616
3682
|
if (target) {
|
|
3617
|
-
rootEl.insertBefore(
|
|
3683
|
+
rootEl.insertBefore(clone, target);
|
|
3618
3684
|
} else {
|
|
3619
|
-
rootEl.appendChild(
|
|
3685
|
+
rootEl.appendChild(clone);
|
|
3620
3686
|
}
|
|
3621
|
-
}
|
|
3687
|
+
});
|
|
3622
3688
|
}
|
|
3623
3689
|
|
|
3624
3690
|
function removeMultiDragElements() {
|
|
3625
|
-
|
|
3626
|
-
if (
|
|
3627
|
-
|
|
3628
|
-
}
|
|
3691
|
+
multiDragElements.forEach(function (multiDragElement) {
|
|
3692
|
+
if (multiDragElement === dragEl$1) return;
|
|
3693
|
+
multiDragElement.parentNode && multiDragElement.parentNode.removeChild(multiDragElement);
|
|
3694
|
+
});
|
|
3629
3695
|
}
|
|
3630
3696
|
|
|
3631
3697
|
export default Sortable;
|