infotable 1.4.1 → 1.5.0

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.
@@ -0,0 +1,3363 @@
1
+ /**!
2
+ * Sortable 1.15.7
3
+ * @author RubaXa <trash@rubaxa.org>
4
+ * @author owenm <owen23355@gmail.com>
5
+ * @license MIT
6
+ */
7
+ function _arrayLikeToArray(r, a) {
8
+ (null == a || a > r.length) && (a = r.length);
9
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
10
+ return n;
11
+ }
12
+ function _arrayWithoutHoles(r) {
13
+ if (Array.isArray(r)) return _arrayLikeToArray(r);
14
+ }
15
+ function _defineProperty(e, r, t) {
16
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
17
+ value: t,
18
+ enumerable: !0,
19
+ configurable: !0,
20
+ writable: !0
21
+ }) : e[r] = t, e;
22
+ }
23
+ function _extends() {
24
+ return _extends = Object.assign ? Object.assign.bind() : function (n) {
25
+ for (var e = 1; e < arguments.length; e++) {
26
+ var t = arguments[e];
27
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
28
+ }
29
+ return n;
30
+ }, _extends.apply(null, arguments);
31
+ }
32
+ function _iterableToArray(r) {
33
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
34
+ }
35
+ function _nonIterableSpread() {
36
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
37
+ }
38
+ function ownKeys(e, r) {
39
+ var t = Object.keys(e);
40
+ if (Object.getOwnPropertySymbols) {
41
+ var o = Object.getOwnPropertySymbols(e);
42
+ r && (o = o.filter(function (r) {
43
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
44
+ })), t.push.apply(t, o);
45
+ }
46
+ return t;
47
+ }
48
+ function _objectSpread2(e) {
49
+ for (var r = 1; r < arguments.length; r++) {
50
+ var t = null != arguments[r] ? arguments[r] : {};
51
+ r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
52
+ _defineProperty(e, r, t[r]);
53
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
54
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
55
+ });
56
+ }
57
+ return e;
58
+ }
59
+ function _objectWithoutProperties(e, t) {
60
+ if (null == e) return {};
61
+ var o,
62
+ r,
63
+ i = _objectWithoutPropertiesLoose(e, t);
64
+ if (Object.getOwnPropertySymbols) {
65
+ var n = Object.getOwnPropertySymbols(e);
66
+ for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
67
+ }
68
+ return i;
69
+ }
70
+ function _objectWithoutPropertiesLoose(r, e) {
71
+ if (null == r) return {};
72
+ var t = {};
73
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
74
+ if (-1 !== e.indexOf(n)) continue;
75
+ t[n] = r[n];
76
+ }
77
+ return t;
78
+ }
79
+ function _toConsumableArray(r) {
80
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
81
+ }
82
+ function _toPrimitive(t, r) {
83
+ if ("object" != typeof t || !t) return t;
84
+ var e = t[Symbol.toPrimitive];
85
+ if (void 0 !== e) {
86
+ var i = e.call(t, r || "default");
87
+ if ("object" != typeof i) return i;
88
+ throw new TypeError("@@toPrimitive must return a primitive value.");
89
+ }
90
+ return ("string" === r ? String : Number)(t);
91
+ }
92
+ function _toPropertyKey(t) {
93
+ var i = _toPrimitive(t, "string");
94
+ return "symbol" == typeof i ? i : i + "";
95
+ }
96
+ function _typeof(o) {
97
+ "@babel/helpers - typeof";
98
+
99
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
100
+ return typeof o;
101
+ } : function (o) {
102
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
103
+ }, _typeof(o);
104
+ }
105
+ function _unsupportedIterableToArray(r, a) {
106
+ if (r) {
107
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
108
+ var t = {}.toString.call(r).slice(8, -1);
109
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
110
+ }
111
+ }
112
+
113
+ var version = "1.15.7";
114
+
115
+ function userAgent(pattern) {
116
+ if (typeof window !== 'undefined' && window.navigator) {
117
+ return !! /*@__PURE__*/navigator.userAgent.match(pattern);
118
+ }
119
+ }
120
+ var IE11OrLess = userAgent(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i);
121
+ var Edge = userAgent(/Edge/i);
122
+ var FireFox = userAgent(/firefox/i);
123
+ var Safari = userAgent(/safari/i) && !userAgent(/chrome/i) && !userAgent(/android/i);
124
+ var IOS = userAgent(/iP(ad|od|hone)/i);
125
+ var ChromeForAndroid = userAgent(/chrome/i) && userAgent(/android/i);
126
+
127
+ var captureMode = {
128
+ capture: false,
129
+ passive: false
130
+ };
131
+ function on(el, event, fn) {
132
+ el.addEventListener(event, fn, !IE11OrLess && captureMode);
133
+ }
134
+ function off(el, event, fn) {
135
+ el.removeEventListener(event, fn, !IE11OrLess && captureMode);
136
+ }
137
+ function matches( /**HTMLElement*/el, /**String*/selector) {
138
+ if (!selector) return;
139
+ selector[0] === '>' && (selector = selector.substring(1));
140
+ if (el) {
141
+ try {
142
+ if (el.matches) {
143
+ return el.matches(selector);
144
+ } else if (el.msMatchesSelector) {
145
+ return el.msMatchesSelector(selector);
146
+ } else if (el.webkitMatchesSelector) {
147
+ return el.webkitMatchesSelector(selector);
148
+ }
149
+ } catch (_) {
150
+ return false;
151
+ }
152
+ }
153
+ return false;
154
+ }
155
+ function getParentOrHost(el) {
156
+ return el.host && el !== document && el.host.nodeType && el.host !== el ? el.host : el.parentNode;
157
+ }
158
+ function closest( /**HTMLElement*/el, /**String*/selector, /**HTMLElement*/ctx, includeCTX) {
159
+ if (el) {
160
+ ctx = ctx || document;
161
+ do {
162
+ if (selector != null && (selector[0] === '>' ? el.parentNode === ctx && matches(el, selector) : matches(el, selector)) || includeCTX && el === ctx) {
163
+ return el;
164
+ }
165
+ if (el === ctx) break;
166
+ /* jshint boss:true */
167
+ } while (el = getParentOrHost(el));
168
+ }
169
+ return null;
170
+ }
171
+ var R_SPACE = /\s+/g;
172
+ function toggleClass(el, name, state) {
173
+ if (el && name) {
174
+ if (el.classList) {
175
+ el.classList[state ? 'add' : 'remove'](name);
176
+ } else {
177
+ var className = (' ' + el.className + ' ').replace(R_SPACE, ' ').replace(' ' + name + ' ', ' ');
178
+ el.className = (className + (state ? ' ' + name : '')).replace(R_SPACE, ' ');
179
+ }
180
+ }
181
+ }
182
+ function css(el, prop, val) {
183
+ var style = el && el.style;
184
+ if (style) {
185
+ if (val === void 0) {
186
+ if (document.defaultView && document.defaultView.getComputedStyle) {
187
+ val = document.defaultView.getComputedStyle(el, '');
188
+ } else if (el.currentStyle) {
189
+ val = el.currentStyle;
190
+ }
191
+ return prop === void 0 ? val : val[prop];
192
+ } else {
193
+ if (!(prop in style) && prop.indexOf('webkit') === -1) {
194
+ prop = '-webkit-' + prop;
195
+ }
196
+ style[prop] = val + (typeof val === 'string' ? '' : 'px');
197
+ }
198
+ }
199
+ }
200
+ function matrix(el, selfOnly) {
201
+ var appliedTransforms = '';
202
+ if (typeof el === 'string') {
203
+ appliedTransforms = el;
204
+ } else {
205
+ do {
206
+ var transform = css(el, 'transform');
207
+ if (transform && transform !== 'none') {
208
+ appliedTransforms = transform + ' ' + appliedTransforms;
209
+ }
210
+ /* jshint boss:true */
211
+ } while (!selfOnly && (el = el.parentNode));
212
+ }
213
+ var matrixFn = window.DOMMatrix || window.WebKitCSSMatrix || window.CSSMatrix || window.MSCSSMatrix;
214
+ /*jshint -W056 */
215
+ return matrixFn && new matrixFn(appliedTransforms);
216
+ }
217
+ function find(ctx, tagName, iterator) {
218
+ if (ctx) {
219
+ var list = ctx.getElementsByTagName(tagName),
220
+ i = 0,
221
+ n = list.length;
222
+ if (iterator) {
223
+ for (; i < n; i++) {
224
+ iterator(list[i], i);
225
+ }
226
+ }
227
+ return list;
228
+ }
229
+ return [];
230
+ }
231
+ function getWindowScrollingElement() {
232
+ var scrollingElement = document.scrollingElement;
233
+ if (scrollingElement) {
234
+ return scrollingElement;
235
+ } else {
236
+ return document.documentElement;
237
+ }
238
+ }
239
+
240
+ /**
241
+ * Returns the "bounding client rect" of given element
242
+ * @param {HTMLElement} el The element whose boundingClientRect is wanted
243
+ * @param {[Boolean]} relativeToContainingBlock Whether the rect should be relative to the containing block of (including) the container
244
+ * @param {[Boolean]} relativeToNonStaticParent Whether the rect should be relative to the relative parent of (including) the contaienr
245
+ * @param {[Boolean]} undoScale Whether the container's scale() should be undone
246
+ * @param {[HTMLElement]} container The parent the element will be placed in
247
+ * @return {Object} The boundingClientRect of el, with specified adjustments
248
+ */
249
+ function getRect(el, relativeToContainingBlock, relativeToNonStaticParent, undoScale, container) {
250
+ if (!el.getBoundingClientRect && el !== window) return;
251
+ var elRect, top, left, bottom, right, height, width;
252
+ if (el !== window && el.parentNode && el !== getWindowScrollingElement()) {
253
+ elRect = el.getBoundingClientRect();
254
+ top = elRect.top;
255
+ left = elRect.left;
256
+ bottom = elRect.bottom;
257
+ right = elRect.right;
258
+ height = elRect.height;
259
+ width = elRect.width;
260
+ } else {
261
+ top = 0;
262
+ left = 0;
263
+ bottom = window.innerHeight;
264
+ right = window.innerWidth;
265
+ height = window.innerHeight;
266
+ width = window.innerWidth;
267
+ }
268
+ if ((relativeToContainingBlock || relativeToNonStaticParent) && el !== window) {
269
+ // Adjust for translate()
270
+ container = container || el.parentNode;
271
+
272
+ // solves #1123 (see: https://stackoverflow.com/a/37953806/6088312)
273
+ // Not needed on <= IE11
274
+ if (!IE11OrLess) {
275
+ do {
276
+ if (container && container.getBoundingClientRect && (css(container, 'transform') !== 'none' || relativeToNonStaticParent && css(container, 'position') !== 'static')) {
277
+ var containerRect = container.getBoundingClientRect();
278
+
279
+ // Set relative to edges of padding box of container
280
+ top -= containerRect.top + parseInt(css(container, 'border-top-width'));
281
+ left -= containerRect.left + parseInt(css(container, 'border-left-width'));
282
+ bottom = top + elRect.height;
283
+ right = left + elRect.width;
284
+ break;
285
+ }
286
+ /* jshint boss:true */
287
+ } while (container = container.parentNode);
288
+ }
289
+ }
290
+ if (undoScale && el !== window) {
291
+ // Adjust for scale()
292
+ var elMatrix = matrix(container || el),
293
+ scaleX = elMatrix && elMatrix.a,
294
+ scaleY = elMatrix && elMatrix.d;
295
+ if (elMatrix) {
296
+ top /= scaleY;
297
+ left /= scaleX;
298
+ width /= scaleX;
299
+ height /= scaleY;
300
+ bottom = top + height;
301
+ right = left + width;
302
+ }
303
+ }
304
+ return {
305
+ top: top,
306
+ left: left,
307
+ bottom: bottom,
308
+ right: right,
309
+ width: width,
310
+ height: height
311
+ };
312
+ }
313
+
314
+ /**
315
+ * Checks if a side of an element is scrolled past a side of its parents
316
+ * @param {HTMLElement} el The element who's side being scrolled out of view is in question
317
+ * @param {String} elSide Side of the element in question ('top', 'left', 'right', 'bottom')
318
+ * @param {String} parentSide Side of the parent in question ('top', 'left', 'right', 'bottom')
319
+ * @return {HTMLElement} The parent scroll element that the el's side is scrolled past, or null if there is no such element
320
+ */
321
+ function isScrolledPast(el, elSide, parentSide) {
322
+ var parent = getParentAutoScrollElement(el, true),
323
+ elSideVal = getRect(el)[elSide];
324
+
325
+ /* jshint boss:true */
326
+ while (parent) {
327
+ var parentSideVal = getRect(parent)[parentSide],
328
+ visible = void 0;
329
+ if (parentSide === 'top' || parentSide === 'left') {
330
+ visible = elSideVal >= parentSideVal;
331
+ } else {
332
+ visible = elSideVal <= parentSideVal;
333
+ }
334
+ if (!visible) return parent;
335
+ if (parent === getWindowScrollingElement()) break;
336
+ parent = getParentAutoScrollElement(parent, false);
337
+ }
338
+ return false;
339
+ }
340
+
341
+ /**
342
+ * Gets nth child of el, ignoring hidden children, sortable's elements (does not ignore clone if it's visible)
343
+ * and non-draggable elements
344
+ * @param {HTMLElement} el The parent element
345
+ * @param {Number} childNum The index of the child
346
+ * @param {Object} options Parent Sortable's options
347
+ * @return {HTMLElement} The child at index childNum, or null if not found
348
+ */
349
+ function getChild(el, childNum, options, includeDragEl) {
350
+ var currentChild = 0,
351
+ i = 0,
352
+ children = el.children;
353
+ while (i < children.length) {
354
+ if (children[i].style.display !== 'none' && children[i] !== Sortable.ghost && (includeDragEl || children[i] !== Sortable.dragged) && closest(children[i], options.draggable, el, false)) {
355
+ if (currentChild === childNum) {
356
+ return children[i];
357
+ }
358
+ currentChild++;
359
+ }
360
+ i++;
361
+ }
362
+ return null;
363
+ }
364
+
365
+ /**
366
+ * Gets the last child in the el, ignoring ghostEl or invisible elements (clones)
367
+ * @param {HTMLElement} el Parent element
368
+ * @param {selector} selector Any other elements that should be ignored
369
+ * @return {HTMLElement} The last child, ignoring ghostEl
370
+ */
371
+ function lastChild(el, selector) {
372
+ var last = el.lastElementChild;
373
+ while (last && (last === Sortable.ghost || css(last, 'display') === 'none' || selector && !matches(last, selector))) {
374
+ last = last.previousElementSibling;
375
+ }
376
+ return last || null;
377
+ }
378
+
379
+ /**
380
+ * Returns the index of an element within its parent for a selected set of
381
+ * elements
382
+ * @param {HTMLElement} el
383
+ * @param {selector} selector
384
+ * @return {number}
385
+ */
386
+ function index(el, selector) {
387
+ var index = 0;
388
+ if (!el || !el.parentNode) {
389
+ return -1;
390
+ }
391
+
392
+ /* jshint boss:true */
393
+ while (el = el.previousElementSibling) {
394
+ if (el.nodeName.toUpperCase() !== 'TEMPLATE' && el !== Sortable.clone && (!selector || matches(el, selector))) {
395
+ index++;
396
+ }
397
+ }
398
+ return index;
399
+ }
400
+
401
+ /**
402
+ * Returns the scroll offset of the given element, added with all the scroll offsets of parent elements.
403
+ * The value is returned in real pixels.
404
+ * @param {HTMLElement} el
405
+ * @return {Array} Offsets in the format of [left, top]
406
+ */
407
+ function getRelativeScrollOffset(el) {
408
+ var offsetLeft = 0,
409
+ offsetTop = 0,
410
+ winScroller = getWindowScrollingElement();
411
+ if (el) {
412
+ do {
413
+ var elMatrix = matrix(el),
414
+ scaleX = elMatrix.a,
415
+ scaleY = elMatrix.d;
416
+ offsetLeft += el.scrollLeft * scaleX;
417
+ offsetTop += el.scrollTop * scaleY;
418
+ } while (el !== winScroller && (el = el.parentNode));
419
+ }
420
+ return [offsetLeft, offsetTop];
421
+ }
422
+
423
+ /**
424
+ * Returns the index of the object within the given array
425
+ * @param {Array} arr Array that may or may not hold the object
426
+ * @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
427
+ * @return {Number} The index of the object in the array, or -1
428
+ */
429
+ function indexOfObject(arr, obj) {
430
+ for (var i in arr) {
431
+ if (!arr.hasOwnProperty(i)) continue;
432
+ for (var key in obj) {
433
+ if (obj.hasOwnProperty(key) && obj[key] === arr[i][key]) return Number(i);
434
+ }
435
+ }
436
+ return -1;
437
+ }
438
+ function getParentAutoScrollElement(el, includeSelf) {
439
+ // skip to window
440
+ if (!el || !el.getBoundingClientRect) return getWindowScrollingElement();
441
+ var elem = el;
442
+ var gotSelf = false;
443
+ do {
444
+ // we don't need to get elem css if it isn't even overflowing in the first place (performance)
445
+ if (elem.clientWidth < elem.scrollWidth || elem.clientHeight < elem.scrollHeight) {
446
+ var elemCSS = css(elem);
447
+ if (elem.clientWidth < elem.scrollWidth && (elemCSS.overflowX == 'auto' || elemCSS.overflowX == 'scroll') || elem.clientHeight < elem.scrollHeight && (elemCSS.overflowY == 'auto' || elemCSS.overflowY == 'scroll')) {
448
+ if (!elem.getBoundingClientRect || elem === document.body) return getWindowScrollingElement();
449
+ if (gotSelf || includeSelf) return elem;
450
+ gotSelf = true;
451
+ }
452
+ }
453
+ /* jshint boss:true */
454
+ } while (elem = elem.parentNode);
455
+ return getWindowScrollingElement();
456
+ }
457
+ function extend(dst, src) {
458
+ if (dst && src) {
459
+ for (var key in src) {
460
+ if (src.hasOwnProperty(key)) {
461
+ dst[key] = src[key];
462
+ }
463
+ }
464
+ }
465
+ return dst;
466
+ }
467
+ function isRectEqual(rect1, rect2) {
468
+ return Math.round(rect1.top) === Math.round(rect2.top) && Math.round(rect1.left) === Math.round(rect2.left) && Math.round(rect1.height) === Math.round(rect2.height) && Math.round(rect1.width) === Math.round(rect2.width);
469
+ }
470
+ var _throttleTimeout;
471
+ function throttle(callback, ms) {
472
+ return function () {
473
+ if (!_throttleTimeout) {
474
+ var args = arguments,
475
+ _this = this;
476
+ if (args.length === 1) {
477
+ callback.call(_this, args[0]);
478
+ } else {
479
+ callback.apply(_this, args);
480
+ }
481
+ _throttleTimeout = setTimeout(function () {
482
+ _throttleTimeout = void 0;
483
+ }, ms);
484
+ }
485
+ };
486
+ }
487
+ function cancelThrottle() {
488
+ clearTimeout(_throttleTimeout);
489
+ _throttleTimeout = void 0;
490
+ }
491
+ function scrollBy(el, x, y) {
492
+ el.scrollLeft += x;
493
+ el.scrollTop += y;
494
+ }
495
+ function clone(el) {
496
+ var Polymer = window.Polymer;
497
+ var $ = window.jQuery || window.Zepto;
498
+ if (Polymer && Polymer.dom) {
499
+ return Polymer.dom(el).cloneNode(true);
500
+ } else if ($) {
501
+ return $(el).clone(true)[0];
502
+ } else {
503
+ return el.cloneNode(true);
504
+ }
505
+ }
506
+ function setRect(el, rect) {
507
+ css(el, 'position', 'absolute');
508
+ css(el, 'top', rect.top);
509
+ css(el, 'left', rect.left);
510
+ css(el, 'width', rect.width);
511
+ css(el, 'height', rect.height);
512
+ }
513
+ function unsetRect(el) {
514
+ css(el, 'position', '');
515
+ css(el, 'top', '');
516
+ css(el, 'left', '');
517
+ css(el, 'width', '');
518
+ css(el, 'height', '');
519
+ }
520
+ function getChildContainingRectFromElement(container, options, ghostEl) {
521
+ var rect = {};
522
+ Array.from(container.children).forEach(function (child) {
523
+ var _rect$left, _rect$top, _rect$right, _rect$bottom;
524
+ if (!closest(child, options.draggable, container, false) || child.animated || child === ghostEl) return;
525
+ var childRect = getRect(child);
526
+ rect.left = Math.min((_rect$left = rect.left) !== null && _rect$left !== void 0 ? _rect$left : Infinity, childRect.left);
527
+ rect.top = Math.min((_rect$top = rect.top) !== null && _rect$top !== void 0 ? _rect$top : Infinity, childRect.top);
528
+ rect.right = Math.max((_rect$right = rect.right) !== null && _rect$right !== void 0 ? _rect$right : -Infinity, childRect.right);
529
+ rect.bottom = Math.max((_rect$bottom = rect.bottom) !== null && _rect$bottom !== void 0 ? _rect$bottom : -Infinity, childRect.bottom);
530
+ });
531
+ rect.width = rect.right - rect.left;
532
+ rect.height = rect.bottom - rect.top;
533
+ rect.x = rect.left;
534
+ rect.y = rect.top;
535
+ return rect;
536
+ }
537
+ var expando = 'Sortable' + new Date().getTime();
538
+
539
+ function AnimationStateManager() {
540
+ var animationStates = [],
541
+ animationCallbackId;
542
+ return {
543
+ captureAnimationState: function captureAnimationState() {
544
+ animationStates = [];
545
+ if (!this.options.animation) return;
546
+ var children = [].slice.call(this.el.children);
547
+ children.forEach(function (child) {
548
+ if (css(child, 'display') === 'none' || child === Sortable.ghost) return;
549
+ animationStates.push({
550
+ target: child,
551
+ rect: getRect(child)
552
+ });
553
+ var fromRect = _objectSpread2({}, animationStates[animationStates.length - 1].rect);
554
+
555
+ // If animating: compensate for current animation
556
+ if (child.thisAnimationDuration) {
557
+ var childMatrix = matrix(child, true);
558
+ if (childMatrix) {
559
+ fromRect.top -= childMatrix.f;
560
+ fromRect.left -= childMatrix.e;
561
+ }
562
+ }
563
+ child.fromRect = fromRect;
564
+ });
565
+ },
566
+ addAnimationState: function addAnimationState(state) {
567
+ animationStates.push(state);
568
+ },
569
+ removeAnimationState: function removeAnimationState(target) {
570
+ animationStates.splice(indexOfObject(animationStates, {
571
+ target: target
572
+ }), 1);
573
+ },
574
+ animateAll: function animateAll(callback) {
575
+ var _this = this;
576
+ if (!this.options.animation) {
577
+ clearTimeout(animationCallbackId);
578
+ if (typeof callback === 'function') callback();
579
+ return;
580
+ }
581
+ var animating = false,
582
+ animationTime = 0;
583
+ animationStates.forEach(function (state) {
584
+ var time = 0,
585
+ target = state.target,
586
+ fromRect = target.fromRect,
587
+ toRect = getRect(target),
588
+ prevFromRect = target.prevFromRect,
589
+ prevToRect = target.prevToRect,
590
+ animatingRect = state.rect,
591
+ targetMatrix = matrix(target, true);
592
+ if (targetMatrix) {
593
+ // Compensate for current animation
594
+ toRect.top -= targetMatrix.f;
595
+ toRect.left -= targetMatrix.e;
596
+ }
597
+ target.toRect = toRect;
598
+ if (target.thisAnimationDuration) {
599
+ // Could also check if animatingRect is between fromRect and toRect
600
+ if (isRectEqual(prevFromRect, toRect) && !isRectEqual(fromRect, toRect) &&
601
+ // Make sure animatingRect is on line between toRect & fromRect
602
+ (animatingRect.top - toRect.top) / (animatingRect.left - toRect.left) === (fromRect.top - toRect.top) / (fromRect.left - toRect.left)) {
603
+ // If returning to same place as started from animation and on same axis
604
+ time = calculateRealTime(animatingRect, prevFromRect, prevToRect, _this.options);
605
+ }
606
+ }
607
+
608
+ // if fromRect != toRect: animate
609
+ if (!isRectEqual(toRect, fromRect)) {
610
+ target.prevFromRect = fromRect;
611
+ target.prevToRect = toRect;
612
+ if (!time) {
613
+ time = _this.options.animation;
614
+ }
615
+ _this.animate(target, animatingRect, toRect, time);
616
+ }
617
+ if (time) {
618
+ animating = true;
619
+ animationTime = Math.max(animationTime, time);
620
+ clearTimeout(target.animationResetTimer);
621
+ target.animationResetTimer = setTimeout(function () {
622
+ target.animationTime = 0;
623
+ target.prevFromRect = null;
624
+ target.fromRect = null;
625
+ target.prevToRect = null;
626
+ target.thisAnimationDuration = null;
627
+ }, time);
628
+ target.thisAnimationDuration = time;
629
+ }
630
+ });
631
+ clearTimeout(animationCallbackId);
632
+ if (!animating) {
633
+ if (typeof callback === 'function') callback();
634
+ } else {
635
+ animationCallbackId = setTimeout(function () {
636
+ if (typeof callback === 'function') callback();
637
+ }, animationTime);
638
+ }
639
+ animationStates = [];
640
+ },
641
+ animate: function animate(target, currentRect, toRect, duration) {
642
+ if (duration) {
643
+ css(target, 'transition', '');
644
+ css(target, 'transform', '');
645
+ var elMatrix = matrix(this.el),
646
+ scaleX = elMatrix && elMatrix.a,
647
+ scaleY = elMatrix && elMatrix.d,
648
+ translateX = (currentRect.left - toRect.left) / (scaleX || 1),
649
+ translateY = (currentRect.top - toRect.top) / (scaleY || 1);
650
+ target.animatingX = !!translateX;
651
+ target.animatingY = !!translateY;
652
+ css(target, 'transform', 'translate3d(' + translateX + 'px,' + translateY + 'px,0)');
653
+ this.forRepaintDummy = repaint(target); // repaint
654
+
655
+ css(target, 'transition', 'transform ' + duration + 'ms' + (this.options.easing ? ' ' + this.options.easing : ''));
656
+ css(target, 'transform', 'translate3d(0,0,0)');
657
+ typeof target.animated === 'number' && clearTimeout(target.animated);
658
+ target.animated = setTimeout(function () {
659
+ css(target, 'transition', '');
660
+ css(target, 'transform', '');
661
+ target.animated = false;
662
+ target.animatingX = false;
663
+ target.animatingY = false;
664
+ }, duration);
665
+ }
666
+ }
667
+ };
668
+ }
669
+ function repaint(target) {
670
+ return target.offsetWidth;
671
+ }
672
+ function calculateRealTime(animatingRect, fromRect, toRect, options) {
673
+ return Math.sqrt(Math.pow(fromRect.top - animatingRect.top, 2) + Math.pow(fromRect.left - animatingRect.left, 2)) / Math.sqrt(Math.pow(fromRect.top - toRect.top, 2) + Math.pow(fromRect.left - toRect.left, 2)) * options.animation;
674
+ }
675
+
676
+ var plugins = [];
677
+ var defaults = {
678
+ initializeByDefault: true
679
+ };
680
+ var PluginManager = {
681
+ mount: function mount(plugin) {
682
+ // Set default static properties
683
+ for (var option in defaults) {
684
+ if (defaults.hasOwnProperty(option) && !(option in plugin)) {
685
+ plugin[option] = defaults[option];
686
+ }
687
+ }
688
+ plugins.forEach(function (p) {
689
+ if (p.pluginName === plugin.pluginName) {
690
+ throw "Sortable: Cannot mount plugin ".concat(plugin.pluginName, " more than once");
691
+ }
692
+ });
693
+ plugins.push(plugin);
694
+ },
695
+ pluginEvent: function pluginEvent(eventName, sortable, evt) {
696
+ var _this = this;
697
+ this.eventCanceled = false;
698
+ evt.cancel = function () {
699
+ _this.eventCanceled = true;
700
+ };
701
+ var eventNameGlobal = eventName + 'Global';
702
+ plugins.forEach(function (plugin) {
703
+ if (!sortable[plugin.pluginName]) return;
704
+ // Fire global events if it exists in this sortable
705
+ if (sortable[plugin.pluginName][eventNameGlobal]) {
706
+ sortable[plugin.pluginName][eventNameGlobal](_objectSpread2({
707
+ sortable: sortable
708
+ }, evt));
709
+ }
710
+
711
+ // Only fire plugin event if plugin is enabled in this sortable,
712
+ // and plugin has event defined
713
+ if (sortable.options[plugin.pluginName] && sortable[plugin.pluginName][eventName]) {
714
+ sortable[plugin.pluginName][eventName](_objectSpread2({
715
+ sortable: sortable
716
+ }, evt));
717
+ }
718
+ });
719
+ },
720
+ initializePlugins: function initializePlugins(sortable, el, defaults, options) {
721
+ plugins.forEach(function (plugin) {
722
+ var pluginName = plugin.pluginName;
723
+ if (!sortable.options[pluginName] && !plugin.initializeByDefault) return;
724
+ var initialized = new plugin(sortable, el, sortable.options);
725
+ initialized.sortable = sortable;
726
+ initialized.options = sortable.options;
727
+ sortable[pluginName] = initialized;
728
+
729
+ // Add default options from plugin
730
+ _extends(defaults, initialized.defaults);
731
+ });
732
+ for (var option in sortable.options) {
733
+ if (!sortable.options.hasOwnProperty(option)) continue;
734
+ var modified = this.modifyOption(sortable, option, sortable.options[option]);
735
+ if (typeof modified !== 'undefined') {
736
+ sortable.options[option] = modified;
737
+ }
738
+ }
739
+ },
740
+ getEventProperties: function getEventProperties(name, sortable) {
741
+ var eventProperties = {};
742
+ plugins.forEach(function (plugin) {
743
+ if (typeof plugin.eventProperties !== 'function') return;
744
+ _extends(eventProperties, plugin.eventProperties.call(sortable[plugin.pluginName], name));
745
+ });
746
+ return eventProperties;
747
+ },
748
+ modifyOption: function modifyOption(sortable, name, value) {
749
+ var modifiedValue;
750
+ plugins.forEach(function (plugin) {
751
+ // Plugin must exist on the Sortable
752
+ if (!sortable[plugin.pluginName]) return;
753
+
754
+ // If static option listener exists for this option, call in the context of the Sortable's instance of this plugin
755
+ if (plugin.optionListeners && typeof plugin.optionListeners[name] === 'function') {
756
+ modifiedValue = plugin.optionListeners[name].call(sortable[plugin.pluginName], value);
757
+ }
758
+ });
759
+ return modifiedValue;
760
+ }
761
+ };
762
+
763
+ function dispatchEvent(_ref) {
764
+ var sortable = _ref.sortable,
765
+ rootEl = _ref.rootEl,
766
+ name = _ref.name,
767
+ targetEl = _ref.targetEl,
768
+ cloneEl = _ref.cloneEl,
769
+ toEl = _ref.toEl,
770
+ fromEl = _ref.fromEl,
771
+ oldIndex = _ref.oldIndex,
772
+ newIndex = _ref.newIndex,
773
+ oldDraggableIndex = _ref.oldDraggableIndex,
774
+ newDraggableIndex = _ref.newDraggableIndex,
775
+ originalEvent = _ref.originalEvent,
776
+ putSortable = _ref.putSortable,
777
+ extraEventProperties = _ref.extraEventProperties;
778
+ sortable = sortable || rootEl && rootEl[expando];
779
+ if (!sortable) return;
780
+ var evt,
781
+ options = sortable.options,
782
+ onName = 'on' + name.charAt(0).toUpperCase() + name.substr(1);
783
+ // Support for new CustomEvent feature
784
+ if (window.CustomEvent && !IE11OrLess && !Edge) {
785
+ evt = new CustomEvent(name, {
786
+ bubbles: true,
787
+ cancelable: true
788
+ });
789
+ } else {
790
+ evt = document.createEvent('Event');
791
+ evt.initEvent(name, true, true);
792
+ }
793
+ evt.to = toEl || rootEl;
794
+ evt.from = fromEl || rootEl;
795
+ evt.item = targetEl || rootEl;
796
+ evt.clone = cloneEl;
797
+ evt.oldIndex = oldIndex;
798
+ evt.newIndex = newIndex;
799
+ evt.oldDraggableIndex = oldDraggableIndex;
800
+ evt.newDraggableIndex = newDraggableIndex;
801
+ evt.originalEvent = originalEvent;
802
+ evt.pullMode = putSortable ? putSortable.lastPutMode : undefined;
803
+ var allEventProperties = _objectSpread2(_objectSpread2({}, extraEventProperties), PluginManager.getEventProperties(name, sortable));
804
+ for (var option in allEventProperties) {
805
+ evt[option] = allEventProperties[option];
806
+ }
807
+ if (rootEl) {
808
+ rootEl.dispatchEvent(evt);
809
+ }
810
+ if (options[onName]) {
811
+ options[onName].call(sortable, evt);
812
+ }
813
+ }
814
+
815
+ var _excluded = ["evt"];
816
+ var pluginEvent = function pluginEvent(eventName, sortable) {
817
+ var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
818
+ originalEvent = _ref.evt,
819
+ data = _objectWithoutProperties(_ref, _excluded);
820
+ PluginManager.pluginEvent.bind(Sortable)(eventName, sortable, _objectSpread2({
821
+ dragEl: dragEl,
822
+ parentEl: parentEl,
823
+ ghostEl: ghostEl,
824
+ rootEl: rootEl,
825
+ nextEl: nextEl,
826
+ lastDownEl: lastDownEl,
827
+ cloneEl: cloneEl,
828
+ cloneHidden: cloneHidden,
829
+ dragStarted: moved,
830
+ putSortable: putSortable,
831
+ activeSortable: Sortable.active,
832
+ originalEvent: originalEvent,
833
+ oldIndex: oldIndex,
834
+ oldDraggableIndex: oldDraggableIndex,
835
+ newIndex: newIndex,
836
+ newDraggableIndex: newDraggableIndex,
837
+ hideGhostForTarget: _hideGhostForTarget,
838
+ unhideGhostForTarget: _unhideGhostForTarget,
839
+ cloneNowHidden: function cloneNowHidden() {
840
+ cloneHidden = true;
841
+ },
842
+ cloneNowShown: function cloneNowShown() {
843
+ cloneHidden = false;
844
+ },
845
+ dispatchSortableEvent: function dispatchSortableEvent(name) {
846
+ _dispatchEvent({
847
+ sortable: sortable,
848
+ name: name,
849
+ originalEvent: originalEvent
850
+ });
851
+ }
852
+ }, data));
853
+ };
854
+ function _dispatchEvent(info) {
855
+ dispatchEvent(_objectSpread2({
856
+ putSortable: putSortable,
857
+ cloneEl: cloneEl,
858
+ targetEl: dragEl,
859
+ rootEl: rootEl,
860
+ oldIndex: oldIndex,
861
+ oldDraggableIndex: oldDraggableIndex,
862
+ newIndex: newIndex,
863
+ newDraggableIndex: newDraggableIndex
864
+ }, info));
865
+ }
866
+ var dragEl,
867
+ parentEl,
868
+ ghostEl,
869
+ rootEl,
870
+ nextEl,
871
+ lastDownEl,
872
+ cloneEl,
873
+ cloneHidden,
874
+ oldIndex,
875
+ newIndex,
876
+ oldDraggableIndex,
877
+ newDraggableIndex,
878
+ activeGroup,
879
+ putSortable,
880
+ awaitingDragStarted = false,
881
+ ignoreNextClick = false,
882
+ sortables = [],
883
+ tapEvt,
884
+ touchEvt,
885
+ lastDx,
886
+ lastDy,
887
+ tapDistanceLeft,
888
+ tapDistanceTop,
889
+ moved,
890
+ lastTarget,
891
+ lastDirection,
892
+ pastFirstInvertThresh = false,
893
+ isCircumstantialInvert = false,
894
+ targetMoveDistance,
895
+ // For positioning ghost absolutely
896
+ ghostRelativeParent,
897
+ ghostRelativeParentInitialScroll = [],
898
+ // (left, top)
899
+
900
+ _silent = false,
901
+ savedInputChecked = [];
902
+
903
+ /** @const */
904
+ var documentExists = typeof document !== 'undefined',
905
+ PositionGhostAbsolutely = IOS,
906
+ CSSFloatProperty = Edge || IE11OrLess ? 'cssFloat' : 'float',
907
+ // This will not pass for IE9, because IE9 DnD only works on anchors
908
+ supportDraggable = documentExists && !ChromeForAndroid && !IOS && 'draggable' in document.createElement('div'),
909
+ supportCssPointerEvents = function () {
910
+ if (!documentExists) return;
911
+ // false when <= IE11
912
+ if (IE11OrLess) {
913
+ return false;
914
+ }
915
+ var el = document.createElement('x');
916
+ el.style.cssText = 'pointer-events:auto';
917
+ return el.style.pointerEvents === 'auto';
918
+ }(),
919
+ _detectDirection = function _detectDirection(el, options) {
920
+ var elCSS = css(el),
921
+ elWidth = parseInt(elCSS.width) - parseInt(elCSS.paddingLeft) - parseInt(elCSS.paddingRight) - parseInt(elCSS.borderLeftWidth) - parseInt(elCSS.borderRightWidth),
922
+ child1 = getChild(el, 0, options),
923
+ child2 = getChild(el, 1, options),
924
+ firstChildCSS = child1 && css(child1),
925
+ secondChildCSS = child2 && css(child2),
926
+ firstChildWidth = firstChildCSS && parseInt(firstChildCSS.marginLeft) + parseInt(firstChildCSS.marginRight) + getRect(child1).width,
927
+ secondChildWidth = secondChildCSS && parseInt(secondChildCSS.marginLeft) + parseInt(secondChildCSS.marginRight) + getRect(child2).width;
928
+ if (elCSS.display === 'flex') {
929
+ return elCSS.flexDirection === 'column' || elCSS.flexDirection === 'column-reverse' ? 'vertical' : 'horizontal';
930
+ }
931
+ if (elCSS.display === 'grid') {
932
+ return elCSS.gridTemplateColumns.split(' ').length <= 1 ? 'vertical' : 'horizontal';
933
+ }
934
+ if (child1 && firstChildCSS["float"] && firstChildCSS["float"] !== 'none') {
935
+ var touchingSideChild2 = firstChildCSS["float"] === 'left' ? 'left' : 'right';
936
+ return child2 && (secondChildCSS.clear === 'both' || secondChildCSS.clear === touchingSideChild2) ? 'vertical' : 'horizontal';
937
+ }
938
+ return child1 && (firstChildCSS.display === 'block' || firstChildCSS.display === 'flex' || firstChildCSS.display === 'table' || firstChildCSS.display === 'grid' || firstChildWidth >= elWidth && elCSS[CSSFloatProperty] === 'none' || child2 && elCSS[CSSFloatProperty] === 'none' && firstChildWidth + secondChildWidth > elWidth) ? 'vertical' : 'horizontal';
939
+ },
940
+ _dragElInRowColumn = function _dragElInRowColumn(dragRect, targetRect, vertical) {
941
+ var dragElS1Opp = vertical ? dragRect.left : dragRect.top,
942
+ dragElS2Opp = vertical ? dragRect.right : dragRect.bottom,
943
+ dragElOppLength = vertical ? dragRect.width : dragRect.height,
944
+ targetS1Opp = vertical ? targetRect.left : targetRect.top,
945
+ targetS2Opp = vertical ? targetRect.right : targetRect.bottom,
946
+ targetOppLength = vertical ? targetRect.width : targetRect.height;
947
+ return dragElS1Opp === targetS1Opp || dragElS2Opp === targetS2Opp || dragElS1Opp + dragElOppLength / 2 === targetS1Opp + targetOppLength / 2;
948
+ },
949
+ /**
950
+ * Detects first nearest empty sortable to X and Y position using emptyInsertThreshold.
951
+ * @param {Number} x X position
952
+ * @param {Number} y Y position
953
+ * @return {HTMLElement} Element of the first found nearest Sortable
954
+ */
955
+ _detectNearestEmptySortable = function _detectNearestEmptySortable(x, y) {
956
+ var ret;
957
+ sortables.some(function (sortable) {
958
+ var threshold = sortable[expando].options.emptyInsertThreshold;
959
+ if (!threshold || lastChild(sortable)) return;
960
+ var rect = getRect(sortable),
961
+ insideHorizontally = x >= rect.left - threshold && x <= rect.right + threshold,
962
+ insideVertically = y >= rect.top - threshold && y <= rect.bottom + threshold;
963
+ if (insideHorizontally && insideVertically) {
964
+ return ret = sortable;
965
+ }
966
+ });
967
+ return ret;
968
+ },
969
+ _prepareGroup = function _prepareGroup(options) {
970
+ function toFn(value, pull) {
971
+ return function (to, from, dragEl, evt) {
972
+ var sameGroup = to.options.group.name && from.options.group.name && to.options.group.name === from.options.group.name;
973
+ if (value == null && (pull || sameGroup)) {
974
+ // Default pull value
975
+ // Default pull and put value if same group
976
+ return true;
977
+ } else if (value == null || value === false) {
978
+ return false;
979
+ } else if (pull && value === 'clone') {
980
+ return value;
981
+ } else if (typeof value === 'function') {
982
+ return toFn(value(to, from, dragEl, evt), pull)(to, from, dragEl, evt);
983
+ } else {
984
+ var otherGroup = (pull ? to : from).options.group.name;
985
+ return value === true || typeof value === 'string' && value === otherGroup || value.join && value.indexOf(otherGroup) > -1;
986
+ }
987
+ };
988
+ }
989
+ var group = {};
990
+ var originalGroup = options.group;
991
+ if (!originalGroup || _typeof(originalGroup) != 'object') {
992
+ originalGroup = {
993
+ name: originalGroup
994
+ };
995
+ }
996
+ group.name = originalGroup.name;
997
+ group.checkPull = toFn(originalGroup.pull, true);
998
+ group.checkPut = toFn(originalGroup.put);
999
+ group.revertClone = originalGroup.revertClone;
1000
+ options.group = group;
1001
+ },
1002
+ _hideGhostForTarget = function _hideGhostForTarget() {
1003
+ if (!supportCssPointerEvents && ghostEl) {
1004
+ css(ghostEl, 'display', 'none');
1005
+ }
1006
+ },
1007
+ _unhideGhostForTarget = function _unhideGhostForTarget() {
1008
+ if (!supportCssPointerEvents && ghostEl) {
1009
+ css(ghostEl, 'display', '');
1010
+ }
1011
+ };
1012
+
1013
+ // #1184 fix - Prevent click event on fallback if dragged but item not changed position
1014
+ if (documentExists && !ChromeForAndroid) {
1015
+ document.addEventListener('click', function (evt) {
1016
+ if (ignoreNextClick) {
1017
+ evt.preventDefault();
1018
+ evt.stopPropagation && evt.stopPropagation();
1019
+ evt.stopImmediatePropagation && evt.stopImmediatePropagation();
1020
+ ignoreNextClick = false;
1021
+ return false;
1022
+ }
1023
+ }, true);
1024
+ }
1025
+ var nearestEmptyInsertDetectEvent = function nearestEmptyInsertDetectEvent(evt) {
1026
+ if (dragEl) {
1027
+ evt = evt.touches ? evt.touches[0] : evt;
1028
+ var nearest = _detectNearestEmptySortable(evt.clientX, evt.clientY);
1029
+ if (nearest) {
1030
+ // Create imitation event
1031
+ var event = {};
1032
+ for (var i in evt) {
1033
+ if (evt.hasOwnProperty(i)) {
1034
+ event[i] = evt[i];
1035
+ }
1036
+ }
1037
+ event.target = event.rootEl = nearest;
1038
+ event.preventDefault = void 0;
1039
+ event.stopPropagation = void 0;
1040
+ nearest[expando]._onDragOver(event);
1041
+ }
1042
+ }
1043
+ };
1044
+ var _checkOutsideTargetEl = function _checkOutsideTargetEl(evt) {
1045
+ if (dragEl) {
1046
+ dragEl.parentNode[expando]._isOutsideThisEl(evt.target);
1047
+ }
1048
+ };
1049
+
1050
+ /**
1051
+ * @class Sortable
1052
+ * @param {HTMLElement} el
1053
+ * @param {Object} [options]
1054
+ */
1055
+ function Sortable(el, options) {
1056
+ if (!(el && el.nodeType && el.nodeType === 1)) {
1057
+ throw "Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(el));
1058
+ }
1059
+ this.el = el; // root element
1060
+ this.options = options = _extends({}, options);
1061
+
1062
+ // Export instance
1063
+ el[expando] = this;
1064
+ var defaults = {
1065
+ group: null,
1066
+ sort: true,
1067
+ disabled: false,
1068
+ store: null,
1069
+ handle: null,
1070
+ draggable: /^[uo]l$/i.test(el.nodeName) ? '>li' : '>*',
1071
+ swapThreshold: 1,
1072
+ // percentage; 0 <= x <= 1
1073
+ invertSwap: false,
1074
+ // invert always
1075
+ invertedSwapThreshold: null,
1076
+ // will be set to same as swapThreshold if default
1077
+ removeCloneOnHide: true,
1078
+ direction: function direction() {
1079
+ return _detectDirection(el, this.options);
1080
+ },
1081
+ ghostClass: 'sortable-ghost',
1082
+ chosenClass: 'sortable-chosen',
1083
+ dragClass: 'sortable-drag',
1084
+ ignore: 'a, img',
1085
+ filter: null,
1086
+ preventOnFilter: true,
1087
+ animation: 0,
1088
+ easing: null,
1089
+ setData: function setData(dataTransfer, dragEl) {
1090
+ dataTransfer.setData('Text', dragEl.textContent);
1091
+ },
1092
+ dropBubble: false,
1093
+ dragoverBubble: false,
1094
+ dataIdAttr: 'data-id',
1095
+ delay: 0,
1096
+ delayOnTouchOnly: false,
1097
+ touchStartThreshold: (Number.parseInt ? Number : window).parseInt(window.devicePixelRatio, 10) || 1,
1098
+ forceFallback: false,
1099
+ fallbackClass: 'sortable-fallback',
1100
+ fallbackOnBody: false,
1101
+ fallbackTolerance: 0,
1102
+ fallbackOffset: {
1103
+ x: 0,
1104
+ y: 0
1105
+ },
1106
+ // Disabled on Safari: #1571; Enabled on Safari IOS: #2244
1107
+ supportPointer: Sortable.supportPointer !== false && 'PointerEvent' in window && (!Safari || IOS),
1108
+ emptyInsertThreshold: 5
1109
+ };
1110
+ PluginManager.initializePlugins(this, el, defaults);
1111
+
1112
+ // Set default options
1113
+ for (var name in defaults) {
1114
+ !(name in options) && (options[name] = defaults[name]);
1115
+ }
1116
+ _prepareGroup(options);
1117
+
1118
+ // Bind all private methods
1119
+ for (var fn in this) {
1120
+ if (fn.charAt(0) === '_' && typeof this[fn] === 'function') {
1121
+ this[fn] = this[fn].bind(this);
1122
+ }
1123
+ }
1124
+
1125
+ // Setup drag mode
1126
+ this.nativeDraggable = options.forceFallback ? false : supportDraggable;
1127
+ if (this.nativeDraggable) {
1128
+ // Touch start threshold cannot be greater than the native dragstart threshold
1129
+ this.options.touchStartThreshold = 1;
1130
+ }
1131
+
1132
+ // Bind events
1133
+ if (options.supportPointer) {
1134
+ on(el, 'pointerdown', this._onTapStart);
1135
+ } else {
1136
+ on(el, 'mousedown', this._onTapStart);
1137
+ on(el, 'touchstart', this._onTapStart);
1138
+ }
1139
+ if (this.nativeDraggable) {
1140
+ on(el, 'dragover', this);
1141
+ on(el, 'dragenter', this);
1142
+ }
1143
+ sortables.push(this.el);
1144
+
1145
+ // Restore sorting
1146
+ options.store && options.store.get && this.sort(options.store.get(this) || []);
1147
+
1148
+ // Add animation state manager
1149
+ _extends(this, AnimationStateManager());
1150
+ }
1151
+ Sortable.prototype = /** @lends Sortable.prototype */{
1152
+ constructor: Sortable,
1153
+ _isOutsideThisEl: function _isOutsideThisEl(target) {
1154
+ if (!this.el.contains(target) && target !== this.el) {
1155
+ lastTarget = null;
1156
+ }
1157
+ },
1158
+ _getDirection: function _getDirection(evt, target) {
1159
+ return typeof this.options.direction === 'function' ? this.options.direction.call(this, evt, target, dragEl) : this.options.direction;
1160
+ },
1161
+ _onTapStart: function _onTapStart( /** Event|TouchEvent */evt) {
1162
+ if (!evt.cancelable) return;
1163
+ var _this = this,
1164
+ el = this.el,
1165
+ options = this.options,
1166
+ preventOnFilter = options.preventOnFilter,
1167
+ type = evt.type,
1168
+ touch = evt.touches && evt.touches[0] || evt.pointerType && evt.pointerType === 'touch' && evt,
1169
+ target = (touch || evt).target,
1170
+ originalTarget = evt.target.shadowRoot && (evt.path && evt.path[0] || evt.composedPath && evt.composedPath()[0]) || target,
1171
+ filter = options.filter;
1172
+ _saveInputCheckedState(el);
1173
+
1174
+ // Don't trigger start event when an element is been dragged, otherwise the evt.oldindex always wrong when set option.group.
1175
+ if (dragEl) {
1176
+ return;
1177
+ }
1178
+ if (/mousedown|pointerdown/.test(type) && evt.button !== 0 || options.disabled) {
1179
+ return; // only left button and enabled
1180
+ }
1181
+
1182
+ // cancel dnd if original target is content editable
1183
+ if (originalTarget.isContentEditable) {
1184
+ return;
1185
+ }
1186
+
1187
+ // Safari ignores further event handling after mousedown
1188
+ if (!this.nativeDraggable && Safari && target && target.tagName.toUpperCase() === 'SELECT') {
1189
+ return;
1190
+ }
1191
+ target = closest(target, options.draggable, el, false);
1192
+ if (target && target.animated) {
1193
+ return;
1194
+ }
1195
+ if (lastDownEl === target) {
1196
+ // Ignoring duplicate `down`
1197
+ return;
1198
+ }
1199
+
1200
+ // Get the index of the dragged element within its parent
1201
+ oldIndex = index(target);
1202
+ oldDraggableIndex = index(target, options.draggable);
1203
+
1204
+ // Check filter
1205
+ if (typeof filter === 'function') {
1206
+ if (filter.call(this, evt, target, this)) {
1207
+ _dispatchEvent({
1208
+ sortable: _this,
1209
+ rootEl: originalTarget,
1210
+ name: 'filter',
1211
+ targetEl: target,
1212
+ toEl: el,
1213
+ fromEl: el
1214
+ });
1215
+ pluginEvent('filter', _this, {
1216
+ evt: evt
1217
+ });
1218
+ preventOnFilter && evt.preventDefault();
1219
+ return; // cancel dnd
1220
+ }
1221
+ } else if (filter) {
1222
+ filter = filter.split(',').some(function (criteria) {
1223
+ criteria = closest(originalTarget, criteria.trim(), el, false);
1224
+ if (criteria) {
1225
+ _dispatchEvent({
1226
+ sortable: _this,
1227
+ rootEl: criteria,
1228
+ name: 'filter',
1229
+ targetEl: target,
1230
+ fromEl: el,
1231
+ toEl: el
1232
+ });
1233
+ pluginEvent('filter', _this, {
1234
+ evt: evt
1235
+ });
1236
+ return true;
1237
+ }
1238
+ });
1239
+ if (filter) {
1240
+ preventOnFilter && evt.preventDefault();
1241
+ return; // cancel dnd
1242
+ }
1243
+ }
1244
+ if (options.handle && !closest(originalTarget, options.handle, el, false)) {
1245
+ return;
1246
+ }
1247
+
1248
+ // Prepare `dragstart`
1249
+ this._prepareDragStart(evt, touch, target);
1250
+ },
1251
+ _prepareDragStart: function _prepareDragStart( /** Event */evt, /** Touch */touch, /** HTMLElement */target) {
1252
+ var _this = this,
1253
+ el = _this.el,
1254
+ options = _this.options,
1255
+ ownerDocument = el.ownerDocument,
1256
+ dragStartFn;
1257
+ if (target && !dragEl && target.parentNode === el) {
1258
+ var dragRect = getRect(target);
1259
+ rootEl = el;
1260
+ dragEl = target;
1261
+ parentEl = dragEl.parentNode;
1262
+ nextEl = dragEl.nextSibling;
1263
+ lastDownEl = target;
1264
+ activeGroup = options.group;
1265
+ Sortable.dragged = dragEl;
1266
+ tapEvt = {
1267
+ target: dragEl,
1268
+ clientX: (touch || evt).clientX,
1269
+ clientY: (touch || evt).clientY
1270
+ };
1271
+ tapDistanceLeft = tapEvt.clientX - dragRect.left;
1272
+ tapDistanceTop = tapEvt.clientY - dragRect.top;
1273
+ this._lastX = (touch || evt).clientX;
1274
+ this._lastY = (touch || evt).clientY;
1275
+ dragEl.style['will-change'] = 'all';
1276
+ dragStartFn = function dragStartFn() {
1277
+ pluginEvent('delayEnded', _this, {
1278
+ evt: evt
1279
+ });
1280
+ if (Sortable.eventCanceled) {
1281
+ _this._onDrop();
1282
+ return;
1283
+ }
1284
+ // Delayed drag has been triggered
1285
+ // we can re-enable the events: touchmove/mousemove
1286
+ _this._disableDelayedDragEvents();
1287
+ if (!FireFox && _this.nativeDraggable) {
1288
+ dragEl.draggable = true;
1289
+ }
1290
+
1291
+ // Bind the events: dragstart/dragend
1292
+ _this._triggerDragStart(evt, touch);
1293
+
1294
+ // Drag start event
1295
+ _dispatchEvent({
1296
+ sortable: _this,
1297
+ name: 'choose',
1298
+ originalEvent: evt
1299
+ });
1300
+
1301
+ // Chosen item
1302
+ toggleClass(dragEl, options.chosenClass, true);
1303
+ };
1304
+
1305
+ // Disable "draggable"
1306
+ options.ignore.split(',').forEach(function (criteria) {
1307
+ find(dragEl, criteria.trim(), _disableDraggable);
1308
+ });
1309
+ on(ownerDocument, 'dragover', nearestEmptyInsertDetectEvent);
1310
+ on(ownerDocument, 'mousemove', nearestEmptyInsertDetectEvent);
1311
+ on(ownerDocument, 'touchmove', nearestEmptyInsertDetectEvent);
1312
+ if (options.supportPointer) {
1313
+ on(ownerDocument, 'pointerup', _this._onDrop);
1314
+ // Native D&D triggers pointercancel
1315
+ !this.nativeDraggable && on(ownerDocument, 'pointercancel', _this._onDrop);
1316
+ } else {
1317
+ on(ownerDocument, 'mouseup', _this._onDrop);
1318
+ on(ownerDocument, 'touchend', _this._onDrop);
1319
+ on(ownerDocument, 'touchcancel', _this._onDrop);
1320
+ }
1321
+
1322
+ // Make dragEl draggable (must be before delay for FireFox)
1323
+ if (FireFox && this.nativeDraggable) {
1324
+ this.options.touchStartThreshold = 4;
1325
+ dragEl.draggable = true;
1326
+ }
1327
+ pluginEvent('delayStart', this, {
1328
+ evt: evt
1329
+ });
1330
+
1331
+ // Delay is impossible for native DnD in Edge or IE
1332
+ if (options.delay && (!options.delayOnTouchOnly || touch) && (!this.nativeDraggable || !(Edge || IE11OrLess))) {
1333
+ if (Sortable.eventCanceled) {
1334
+ this._onDrop();
1335
+ return;
1336
+ }
1337
+ // If the user moves the pointer or let go the click or touch
1338
+ // before the delay has been reached:
1339
+ // disable the delayed drag
1340
+ if (options.supportPointer) {
1341
+ on(ownerDocument, 'pointerup', _this._disableDelayedDrag);
1342
+ on(ownerDocument, 'pointercancel', _this._disableDelayedDrag);
1343
+ } else {
1344
+ on(ownerDocument, 'mouseup', _this._disableDelayedDrag);
1345
+ on(ownerDocument, 'touchend', _this._disableDelayedDrag);
1346
+ on(ownerDocument, 'touchcancel', _this._disableDelayedDrag);
1347
+ }
1348
+ on(ownerDocument, 'mousemove', _this._delayedDragTouchMoveHandler);
1349
+ on(ownerDocument, 'touchmove', _this._delayedDragTouchMoveHandler);
1350
+ options.supportPointer && on(ownerDocument, 'pointermove', _this._delayedDragTouchMoveHandler);
1351
+ _this._dragStartTimer = setTimeout(dragStartFn, options.delay);
1352
+ } else {
1353
+ dragStartFn();
1354
+ }
1355
+ }
1356
+ },
1357
+ _delayedDragTouchMoveHandler: function _delayedDragTouchMoveHandler( /** TouchEvent|PointerEvent **/e) {
1358
+ var touch = e.touches ? e.touches[0] : e;
1359
+ if (Math.max(Math.abs(touch.clientX - this._lastX), Math.abs(touch.clientY - this._lastY)) >= Math.floor(this.options.touchStartThreshold / (this.nativeDraggable && window.devicePixelRatio || 1))) {
1360
+ this._disableDelayedDrag();
1361
+ }
1362
+ },
1363
+ _disableDelayedDrag: function _disableDelayedDrag() {
1364
+ dragEl && _disableDraggable(dragEl);
1365
+ clearTimeout(this._dragStartTimer);
1366
+ this._disableDelayedDragEvents();
1367
+ },
1368
+ _disableDelayedDragEvents: function _disableDelayedDragEvents() {
1369
+ var ownerDocument = this.el.ownerDocument;
1370
+ off(ownerDocument, 'mouseup', this._disableDelayedDrag);
1371
+ off(ownerDocument, 'touchend', this._disableDelayedDrag);
1372
+ off(ownerDocument, 'touchcancel', this._disableDelayedDrag);
1373
+ off(ownerDocument, 'pointerup', this._disableDelayedDrag);
1374
+ off(ownerDocument, 'pointercancel', this._disableDelayedDrag);
1375
+ off(ownerDocument, 'mousemove', this._delayedDragTouchMoveHandler);
1376
+ off(ownerDocument, 'touchmove', this._delayedDragTouchMoveHandler);
1377
+ off(ownerDocument, 'pointermove', this._delayedDragTouchMoveHandler);
1378
+ },
1379
+ _triggerDragStart: function _triggerDragStart( /** Event */evt, /** Touch */touch) {
1380
+ touch = touch || evt.pointerType == 'touch' && evt;
1381
+ if (!this.nativeDraggable || touch) {
1382
+ if (this.options.supportPointer) {
1383
+ on(document, 'pointermove', this._onTouchMove);
1384
+ } else if (touch) {
1385
+ on(document, 'touchmove', this._onTouchMove);
1386
+ } else {
1387
+ on(document, 'mousemove', this._onTouchMove);
1388
+ }
1389
+ } else {
1390
+ on(dragEl, 'dragend', this);
1391
+ on(rootEl, 'dragstart', this._onDragStart);
1392
+ }
1393
+ try {
1394
+ if (document.selection) {
1395
+ _nextTick(function () {
1396
+ document.selection.empty();
1397
+ });
1398
+ } else {
1399
+ window.getSelection().removeAllRanges();
1400
+ }
1401
+ } catch (err) {}
1402
+ },
1403
+ _dragStarted: function _dragStarted(fallback, evt) {
1404
+ awaitingDragStarted = false;
1405
+ if (rootEl && dragEl) {
1406
+ pluginEvent('dragStarted', this, {
1407
+ evt: evt
1408
+ });
1409
+ if (this.nativeDraggable) {
1410
+ on(document, 'dragover', _checkOutsideTargetEl);
1411
+ }
1412
+ var options = this.options;
1413
+
1414
+ // Apply effect
1415
+ !fallback && toggleClass(dragEl, options.dragClass, false);
1416
+ toggleClass(dragEl, options.ghostClass, true);
1417
+ Sortable.active = this;
1418
+ fallback && this._appendGhost();
1419
+
1420
+ // Drag start event
1421
+ _dispatchEvent({
1422
+ sortable: this,
1423
+ name: 'start',
1424
+ originalEvent: evt
1425
+ });
1426
+ } else {
1427
+ this._nulling();
1428
+ }
1429
+ },
1430
+ _emulateDragOver: function _emulateDragOver() {
1431
+ if (touchEvt) {
1432
+ this._lastX = touchEvt.clientX;
1433
+ this._lastY = touchEvt.clientY;
1434
+ _hideGhostForTarget();
1435
+ var target = document.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
1436
+ var parent = target;
1437
+ while (target && target.shadowRoot) {
1438
+ target = target.shadowRoot.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
1439
+ if (target === parent) break;
1440
+ parent = target;
1441
+ }
1442
+ dragEl.parentNode[expando]._isOutsideThisEl(target);
1443
+ if (parent) {
1444
+ do {
1445
+ if (parent[expando]) {
1446
+ var inserted = void 0;
1447
+ inserted = parent[expando]._onDragOver({
1448
+ clientX: touchEvt.clientX,
1449
+ clientY: touchEvt.clientY,
1450
+ target: target,
1451
+ rootEl: parent
1452
+ });
1453
+ if (inserted && !this.options.dragoverBubble) {
1454
+ break;
1455
+ }
1456
+ }
1457
+ target = parent; // store last element
1458
+ }
1459
+ /* jshint boss:true */ while (parent = getParentOrHost(parent));
1460
+ }
1461
+ _unhideGhostForTarget();
1462
+ }
1463
+ },
1464
+ _onTouchMove: function _onTouchMove( /**TouchEvent*/evt) {
1465
+ if (tapEvt) {
1466
+ var options = this.options,
1467
+ fallbackTolerance = options.fallbackTolerance,
1468
+ fallbackOffset = options.fallbackOffset,
1469
+ touch = evt.touches ? evt.touches[0] : evt,
1470
+ ghostMatrix = ghostEl && matrix(ghostEl, true),
1471
+ scaleX = ghostEl && ghostMatrix && ghostMatrix.a,
1472
+ scaleY = ghostEl && ghostMatrix && ghostMatrix.d,
1473
+ relativeScrollOffset = PositionGhostAbsolutely && ghostRelativeParent && getRelativeScrollOffset(ghostRelativeParent),
1474
+ dx = (touch.clientX - tapEvt.clientX + fallbackOffset.x) / (scaleX || 1) + (relativeScrollOffset ? relativeScrollOffset[0] - ghostRelativeParentInitialScroll[0] : 0) / (scaleX || 1),
1475
+ dy = (touch.clientY - tapEvt.clientY + fallbackOffset.y) / (scaleY || 1) + (relativeScrollOffset ? relativeScrollOffset[1] - ghostRelativeParentInitialScroll[1] : 0) / (scaleY || 1);
1476
+
1477
+ // only set the status to dragging, when we are actually dragging
1478
+ if (!Sortable.active && !awaitingDragStarted) {
1479
+ if (fallbackTolerance && Math.max(Math.abs(touch.clientX - this._lastX), Math.abs(touch.clientY - this._lastY)) < fallbackTolerance) {
1480
+ return;
1481
+ }
1482
+ this._onDragStart(evt, true);
1483
+ }
1484
+ if (ghostEl) {
1485
+ if (ghostMatrix) {
1486
+ ghostMatrix.e += dx - (lastDx || 0);
1487
+ ghostMatrix.f += dy - (lastDy || 0);
1488
+ } else {
1489
+ ghostMatrix = {
1490
+ a: 1,
1491
+ b: 0,
1492
+ c: 0,
1493
+ d: 1,
1494
+ e: dx,
1495
+ f: dy
1496
+ };
1497
+ }
1498
+ var cssMatrix = "matrix(".concat(ghostMatrix.a, ",").concat(ghostMatrix.b, ",").concat(ghostMatrix.c, ",").concat(ghostMatrix.d, ",").concat(ghostMatrix.e, ",").concat(ghostMatrix.f, ")");
1499
+ css(ghostEl, 'webkitTransform', cssMatrix);
1500
+ css(ghostEl, 'mozTransform', cssMatrix);
1501
+ css(ghostEl, 'msTransform', cssMatrix);
1502
+ css(ghostEl, 'transform', cssMatrix);
1503
+ lastDx = dx;
1504
+ lastDy = dy;
1505
+ touchEvt = touch;
1506
+ }
1507
+ evt.cancelable && evt.preventDefault();
1508
+ }
1509
+ },
1510
+ _appendGhost: function _appendGhost() {
1511
+ // Bug if using scale(): https://stackoverflow.com/questions/2637058
1512
+ // Not being adjusted for
1513
+ if (!ghostEl) {
1514
+ var container = this.options.fallbackOnBody ? document.body : rootEl,
1515
+ rect = getRect(dragEl, true, PositionGhostAbsolutely, true, container),
1516
+ options = this.options;
1517
+
1518
+ // Position absolutely
1519
+ if (PositionGhostAbsolutely) {
1520
+ // Get relatively positioned parent
1521
+ ghostRelativeParent = container;
1522
+ while (css(ghostRelativeParent, 'position') === 'static' && css(ghostRelativeParent, 'transform') === 'none' && ghostRelativeParent !== document) {
1523
+ ghostRelativeParent = ghostRelativeParent.parentNode;
1524
+ }
1525
+ if (ghostRelativeParent !== document.body && ghostRelativeParent !== document.documentElement) {
1526
+ if (ghostRelativeParent === document) ghostRelativeParent = getWindowScrollingElement();
1527
+ rect.top += ghostRelativeParent.scrollTop;
1528
+ rect.left += ghostRelativeParent.scrollLeft;
1529
+ } else {
1530
+ ghostRelativeParent = getWindowScrollingElement();
1531
+ }
1532
+ ghostRelativeParentInitialScroll = getRelativeScrollOffset(ghostRelativeParent);
1533
+ }
1534
+ ghostEl = dragEl.cloneNode(true);
1535
+ toggleClass(ghostEl, options.ghostClass, false);
1536
+ toggleClass(ghostEl, options.fallbackClass, true);
1537
+ toggleClass(ghostEl, options.dragClass, true);
1538
+ css(ghostEl, 'transition', '');
1539
+ css(ghostEl, 'transform', '');
1540
+ css(ghostEl, 'box-sizing', 'border-box');
1541
+ css(ghostEl, 'margin', 0);
1542
+ css(ghostEl, 'top', rect.top);
1543
+ css(ghostEl, 'left', rect.left);
1544
+ css(ghostEl, 'width', rect.width);
1545
+ css(ghostEl, 'height', rect.height);
1546
+ css(ghostEl, 'opacity', '0.8');
1547
+ css(ghostEl, 'position', PositionGhostAbsolutely ? 'absolute' : 'fixed');
1548
+ css(ghostEl, 'zIndex', '100000');
1549
+ css(ghostEl, 'pointerEvents', 'none');
1550
+ Sortable.ghost = ghostEl;
1551
+ container.appendChild(ghostEl);
1552
+
1553
+ // Set transform-origin
1554
+ css(ghostEl, 'transform-origin', tapDistanceLeft / parseInt(ghostEl.style.width) * 100 + '% ' + tapDistanceTop / parseInt(ghostEl.style.height) * 100 + '%');
1555
+ }
1556
+ },
1557
+ _onDragStart: function _onDragStart( /**Event*/evt, /**boolean*/fallback) {
1558
+ var _this = this;
1559
+ var dataTransfer = evt.dataTransfer;
1560
+ var options = _this.options;
1561
+ pluginEvent('dragStart', this, {
1562
+ evt: evt
1563
+ });
1564
+ if (Sortable.eventCanceled) {
1565
+ this._onDrop();
1566
+ return;
1567
+ }
1568
+ pluginEvent('setupClone', this);
1569
+ if (!Sortable.eventCanceled) {
1570
+ cloneEl = clone(dragEl);
1571
+ cloneEl.removeAttribute("id");
1572
+ cloneEl.draggable = false;
1573
+ cloneEl.style['will-change'] = '';
1574
+ this._hideClone();
1575
+ toggleClass(cloneEl, this.options.chosenClass, false);
1576
+ Sortable.clone = cloneEl;
1577
+ }
1578
+
1579
+ // #1143: IFrame support workaround
1580
+ _this.cloneId = _nextTick(function () {
1581
+ pluginEvent('clone', _this);
1582
+ if (Sortable.eventCanceled) return;
1583
+ if (!_this.options.removeCloneOnHide) {
1584
+ rootEl.insertBefore(cloneEl, dragEl);
1585
+ }
1586
+ _this._hideClone();
1587
+ _dispatchEvent({
1588
+ sortable: _this,
1589
+ name: 'clone'
1590
+ });
1591
+ });
1592
+ !fallback && toggleClass(dragEl, options.dragClass, true);
1593
+
1594
+ // Set proper drop events
1595
+ if (fallback) {
1596
+ ignoreNextClick = true;
1597
+ _this._loopId = setInterval(_this._emulateDragOver, 50);
1598
+ } else {
1599
+ // Undo what was set in _prepareDragStart before drag started
1600
+ off(document, 'mouseup', _this._onDrop);
1601
+ off(document, 'touchend', _this._onDrop);
1602
+ off(document, 'touchcancel', _this._onDrop);
1603
+ if (dataTransfer) {
1604
+ dataTransfer.effectAllowed = 'move';
1605
+ options.setData && options.setData.call(_this, dataTransfer, dragEl);
1606
+ }
1607
+ on(document, 'drop', _this);
1608
+
1609
+ // #1276 fix:
1610
+ css(dragEl, 'transform', 'translateZ(0)');
1611
+ }
1612
+ awaitingDragStarted = true;
1613
+ _this._dragStartId = _nextTick(_this._dragStarted.bind(_this, fallback, evt));
1614
+ on(document, 'selectstart', _this);
1615
+ moved = true;
1616
+ window.getSelection().removeAllRanges();
1617
+ if (Safari) {
1618
+ css(document.body, 'user-select', 'none');
1619
+ }
1620
+ },
1621
+ // Returns true - if no further action is needed (either inserted or another condition)
1622
+ _onDragOver: function _onDragOver( /**Event*/evt) {
1623
+ var el = this.el,
1624
+ target = evt.target,
1625
+ dragRect,
1626
+ targetRect,
1627
+ revert,
1628
+ options = this.options,
1629
+ group = options.group,
1630
+ activeSortable = Sortable.active,
1631
+ isOwner = activeGroup === group,
1632
+ canSort = options.sort,
1633
+ fromSortable = putSortable || activeSortable,
1634
+ vertical,
1635
+ _this = this,
1636
+ completedFired = false;
1637
+ if (_silent) return;
1638
+ function dragOverEvent(name, extra) {
1639
+ pluginEvent(name, _this, _objectSpread2({
1640
+ evt: evt,
1641
+ isOwner: isOwner,
1642
+ axis: vertical ? 'vertical' : 'horizontal',
1643
+ revert: revert,
1644
+ dragRect: dragRect,
1645
+ targetRect: targetRect,
1646
+ canSort: canSort,
1647
+ fromSortable: fromSortable,
1648
+ target: target,
1649
+ completed: completed,
1650
+ onMove: function onMove(target, after) {
1651
+ return _onMove(rootEl, el, dragEl, dragRect, target, getRect(target), evt, after);
1652
+ },
1653
+ changed: changed
1654
+ }, extra));
1655
+ }
1656
+
1657
+ // Capture animation state
1658
+ function capture() {
1659
+ dragOverEvent('dragOverAnimationCapture');
1660
+ _this.captureAnimationState();
1661
+ if (_this !== fromSortable) {
1662
+ fromSortable.captureAnimationState();
1663
+ }
1664
+ }
1665
+
1666
+ // Return invocation when dragEl is inserted (or completed)
1667
+ function completed(insertion) {
1668
+ dragOverEvent('dragOverCompleted', {
1669
+ insertion: insertion
1670
+ });
1671
+ if (insertion) {
1672
+ // Clones must be hidden before folding animation to capture dragRectAbsolute properly
1673
+ if (isOwner) {
1674
+ activeSortable._hideClone();
1675
+ } else {
1676
+ activeSortable._showClone(_this);
1677
+ }
1678
+ if (_this !== fromSortable) {
1679
+ // Set ghost class to new sortable's ghost class
1680
+ toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : activeSortable.options.ghostClass, false);
1681
+ toggleClass(dragEl, options.ghostClass, true);
1682
+ }
1683
+ if (putSortable !== _this && _this !== Sortable.active) {
1684
+ putSortable = _this;
1685
+ } else if (_this === Sortable.active && putSortable) {
1686
+ putSortable = null;
1687
+ }
1688
+
1689
+ // Animation
1690
+ if (fromSortable === _this) {
1691
+ _this._ignoreWhileAnimating = target;
1692
+ }
1693
+ _this.animateAll(function () {
1694
+ dragOverEvent('dragOverAnimationComplete');
1695
+ _this._ignoreWhileAnimating = null;
1696
+ });
1697
+ if (_this !== fromSortable) {
1698
+ fromSortable.animateAll();
1699
+ fromSortable._ignoreWhileAnimating = null;
1700
+ }
1701
+ }
1702
+
1703
+ // Null lastTarget if it is not inside a previously swapped element
1704
+ if (target === dragEl && !dragEl.animated || target === el && !target.animated) {
1705
+ lastTarget = null;
1706
+ }
1707
+
1708
+ // no bubbling and not fallback
1709
+ if (!options.dragoverBubble && !evt.rootEl && target !== document) {
1710
+ dragEl.parentNode[expando]._isOutsideThisEl(evt.target);
1711
+
1712
+ // Do not detect for empty insert if already inserted
1713
+ !insertion && nearestEmptyInsertDetectEvent(evt);
1714
+ }
1715
+ !options.dragoverBubble && evt.stopPropagation && evt.stopPropagation();
1716
+ return completedFired = true;
1717
+ }
1718
+
1719
+ // Call when dragEl has been inserted
1720
+ function changed() {
1721
+ newIndex = index(dragEl);
1722
+ newDraggableIndex = index(dragEl, options.draggable);
1723
+ _dispatchEvent({
1724
+ sortable: _this,
1725
+ name: 'change',
1726
+ toEl: el,
1727
+ newIndex: newIndex,
1728
+ newDraggableIndex: newDraggableIndex,
1729
+ originalEvent: evt
1730
+ });
1731
+ }
1732
+ if (evt.preventDefault !== void 0) {
1733
+ evt.cancelable && evt.preventDefault();
1734
+ }
1735
+ target = closest(target, options.draggable, el, true);
1736
+ dragOverEvent('dragOver');
1737
+ if (Sortable.eventCanceled) return completedFired;
1738
+ if (dragEl.contains(evt.target) || target.animated && target.animatingX && target.animatingY || _this._ignoreWhileAnimating === target) {
1739
+ return completed(false);
1740
+ }
1741
+ ignoreNextClick = false;
1742
+ if (activeSortable && !options.disabled && (isOwner ? canSort || (revert = parentEl !== rootEl) // Reverting item into the original list
1743
+ : putSortable === this || (this.lastPutMode = activeGroup.checkPull(this, activeSortable, dragEl, evt)) && group.checkPut(this, activeSortable, dragEl, evt))) {
1744
+ vertical = this._getDirection(evt, target) === 'vertical';
1745
+ dragRect = getRect(dragEl);
1746
+ dragOverEvent('dragOverValid');
1747
+ if (Sortable.eventCanceled) return completedFired;
1748
+ if (revert) {
1749
+ parentEl = rootEl; // actualization
1750
+ capture();
1751
+ this._hideClone();
1752
+ dragOverEvent('revert');
1753
+ if (!Sortable.eventCanceled) {
1754
+ if (nextEl) {
1755
+ rootEl.insertBefore(dragEl, nextEl);
1756
+ } else {
1757
+ rootEl.appendChild(dragEl);
1758
+ }
1759
+ }
1760
+ return completed(true);
1761
+ }
1762
+ var elLastChild = lastChild(el, options.draggable);
1763
+ if (!elLastChild || _ghostIsLast(evt, vertical, this) && !elLastChild.animated) {
1764
+ // Insert to end of list
1765
+
1766
+ // If already at end of list: Do not insert
1767
+ if (elLastChild === dragEl) {
1768
+ return completed(false);
1769
+ }
1770
+
1771
+ // if there is a last element, it is the target
1772
+ if (elLastChild && el === evt.target) {
1773
+ target = elLastChild;
1774
+ }
1775
+ if (target) {
1776
+ targetRect = getRect(target);
1777
+ }
1778
+ if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, !!target) !== false) {
1779
+ capture();
1780
+ if (elLastChild && elLastChild.nextSibling) {
1781
+ // the last draggable element is not the last node
1782
+ el.insertBefore(dragEl, elLastChild.nextSibling);
1783
+ } else {
1784
+ el.appendChild(dragEl);
1785
+ }
1786
+ parentEl = el; // actualization
1787
+
1788
+ changed();
1789
+ return completed(true);
1790
+ }
1791
+ } else if (elLastChild && _ghostIsFirst(evt, vertical, this)) {
1792
+ // Insert to start of list
1793
+ var firstChild = getChild(el, 0, options, true);
1794
+ if (firstChild === dragEl) {
1795
+ return completed(false);
1796
+ }
1797
+ target = firstChild;
1798
+ targetRect = getRect(target);
1799
+ if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, false) !== false) {
1800
+ capture();
1801
+ el.insertBefore(dragEl, firstChild);
1802
+ parentEl = el; // actualization
1803
+
1804
+ changed();
1805
+ return completed(true);
1806
+ }
1807
+ } else if (target.parentNode === el) {
1808
+ targetRect = getRect(target);
1809
+ var direction = 0,
1810
+ targetBeforeFirstSwap,
1811
+ differentLevel = dragEl.parentNode !== el,
1812
+ differentRowCol = !_dragElInRowColumn(dragEl.animated && dragEl.toRect || dragRect, target.animated && target.toRect || targetRect, vertical),
1813
+ side1 = vertical ? 'top' : 'left',
1814
+ scrolledPastTop = isScrolledPast(target, 'top', 'top') || isScrolledPast(dragEl, 'top', 'top'),
1815
+ scrollBefore = scrolledPastTop ? scrolledPastTop.scrollTop : void 0;
1816
+ if (lastTarget !== target) {
1817
+ targetBeforeFirstSwap = targetRect[side1];
1818
+ pastFirstInvertThresh = false;
1819
+ isCircumstantialInvert = !differentRowCol && options.invertSwap || differentLevel;
1820
+ }
1821
+ direction = _getSwapDirection(evt, target, targetRect, vertical, differentRowCol ? 1 : options.swapThreshold, options.invertedSwapThreshold == null ? options.swapThreshold : options.invertedSwapThreshold, isCircumstantialInvert, lastTarget === target);
1822
+ var sibling;
1823
+ if (direction !== 0) {
1824
+ // Check if target is beside dragEl in respective direction (ignoring hidden elements)
1825
+ var dragIndex = index(dragEl);
1826
+ do {
1827
+ dragIndex -= direction;
1828
+ sibling = parentEl.children[dragIndex];
1829
+ } while (sibling && (css(sibling, 'display') === 'none' || sibling === ghostEl));
1830
+ }
1831
+ // If dragEl is already beside target: Do not insert
1832
+ if (direction === 0 || sibling === target) {
1833
+ return completed(false);
1834
+ }
1835
+ lastTarget = target;
1836
+ lastDirection = direction;
1837
+ var nextSibling = target.nextElementSibling,
1838
+ after = false;
1839
+ after = direction === 1;
1840
+ var moveVector = _onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, after);
1841
+ if (moveVector !== false) {
1842
+ if (moveVector === 1 || moveVector === -1) {
1843
+ after = moveVector === 1;
1844
+ }
1845
+ _silent = true;
1846
+ setTimeout(_unsilent, 30);
1847
+ capture();
1848
+ if (after && !nextSibling) {
1849
+ el.appendChild(dragEl);
1850
+ } else {
1851
+ target.parentNode.insertBefore(dragEl, after ? nextSibling : target);
1852
+ }
1853
+
1854
+ // Undo chrome's scroll adjustment (has no effect on other browsers)
1855
+ if (scrolledPastTop) {
1856
+ scrollBy(scrolledPastTop, 0, scrollBefore - scrolledPastTop.scrollTop);
1857
+ }
1858
+ parentEl = dragEl.parentNode; // actualization
1859
+
1860
+ // must be done before animation
1861
+ if (targetBeforeFirstSwap !== undefined && !isCircumstantialInvert) {
1862
+ targetMoveDistance = Math.abs(targetBeforeFirstSwap - getRect(target)[side1]);
1863
+ }
1864
+ changed();
1865
+ return completed(true);
1866
+ }
1867
+ }
1868
+ if (el.contains(dragEl)) {
1869
+ return completed(false);
1870
+ }
1871
+ }
1872
+ return false;
1873
+ },
1874
+ _ignoreWhileAnimating: null,
1875
+ _offMoveEvents: function _offMoveEvents() {
1876
+ off(document, 'mousemove', this._onTouchMove);
1877
+ off(document, 'touchmove', this._onTouchMove);
1878
+ off(document, 'pointermove', this._onTouchMove);
1879
+ off(document, 'dragover', nearestEmptyInsertDetectEvent);
1880
+ off(document, 'mousemove', nearestEmptyInsertDetectEvent);
1881
+ off(document, 'touchmove', nearestEmptyInsertDetectEvent);
1882
+ },
1883
+ _offUpEvents: function _offUpEvents() {
1884
+ var ownerDocument = this.el.ownerDocument;
1885
+ off(ownerDocument, 'mouseup', this._onDrop);
1886
+ off(ownerDocument, 'touchend', this._onDrop);
1887
+ off(ownerDocument, 'pointerup', this._onDrop);
1888
+ off(ownerDocument, 'pointercancel', this._onDrop);
1889
+ off(ownerDocument, 'touchcancel', this._onDrop);
1890
+ off(document, 'selectstart', this);
1891
+ },
1892
+ _onDrop: function _onDrop( /**Event*/evt) {
1893
+ var el = this.el,
1894
+ options = this.options;
1895
+
1896
+ // Get the index of the dragged element within its parent
1897
+ newIndex = index(dragEl);
1898
+ newDraggableIndex = index(dragEl, options.draggable);
1899
+ pluginEvent('drop', this, {
1900
+ evt: evt
1901
+ });
1902
+ parentEl = dragEl && dragEl.parentNode;
1903
+
1904
+ // Get again after plugin event
1905
+ newIndex = index(dragEl);
1906
+ newDraggableIndex = index(dragEl, options.draggable);
1907
+ if (Sortable.eventCanceled) {
1908
+ this._nulling();
1909
+ return;
1910
+ }
1911
+ awaitingDragStarted = false;
1912
+ isCircumstantialInvert = false;
1913
+ pastFirstInvertThresh = false;
1914
+ clearInterval(this._loopId);
1915
+ clearTimeout(this._dragStartTimer);
1916
+ _cancelNextTick(this.cloneId);
1917
+ _cancelNextTick(this._dragStartId);
1918
+
1919
+ // Unbind events
1920
+ if (this.nativeDraggable) {
1921
+ off(document, 'drop', this);
1922
+ off(el, 'dragstart', this._onDragStart);
1923
+ }
1924
+ this._offMoveEvents();
1925
+ this._offUpEvents();
1926
+ if (Safari) {
1927
+ css(document.body, 'user-select', '');
1928
+ }
1929
+ css(dragEl, 'transform', '');
1930
+ if (evt) {
1931
+ if (moved) {
1932
+ evt.cancelable && evt.preventDefault();
1933
+ !options.dropBubble && evt.stopPropagation();
1934
+ }
1935
+ ghostEl && ghostEl.parentNode && ghostEl.parentNode.removeChild(ghostEl);
1936
+ if (rootEl === parentEl || putSortable && putSortable.lastPutMode !== 'clone') {
1937
+ // Remove clone(s)
1938
+ cloneEl && cloneEl.parentNode && cloneEl.parentNode.removeChild(cloneEl);
1939
+ }
1940
+ if (dragEl) {
1941
+ if (this.nativeDraggable) {
1942
+ off(dragEl, 'dragend', this);
1943
+ }
1944
+ _disableDraggable(dragEl);
1945
+ dragEl.style['will-change'] = '';
1946
+
1947
+ // Remove classes
1948
+ // ghostClass is added in dragStarted
1949
+ if (moved && !awaitingDragStarted) {
1950
+ toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : this.options.ghostClass, false);
1951
+ }
1952
+ toggleClass(dragEl, this.options.chosenClass, false);
1953
+
1954
+ // Drag stop event
1955
+ _dispatchEvent({
1956
+ sortable: this,
1957
+ name: 'unchoose',
1958
+ toEl: parentEl,
1959
+ newIndex: null,
1960
+ newDraggableIndex: null,
1961
+ originalEvent: evt
1962
+ });
1963
+ if (rootEl !== parentEl) {
1964
+ if (newIndex >= 0) {
1965
+ // Add event
1966
+ _dispatchEvent({
1967
+ rootEl: parentEl,
1968
+ name: 'add',
1969
+ toEl: parentEl,
1970
+ fromEl: rootEl,
1971
+ originalEvent: evt
1972
+ });
1973
+
1974
+ // Remove event
1975
+ _dispatchEvent({
1976
+ sortable: this,
1977
+ name: 'remove',
1978
+ toEl: parentEl,
1979
+ originalEvent: evt
1980
+ });
1981
+
1982
+ // drag from one list and drop into another
1983
+ _dispatchEvent({
1984
+ rootEl: parentEl,
1985
+ name: 'sort',
1986
+ toEl: parentEl,
1987
+ fromEl: rootEl,
1988
+ originalEvent: evt
1989
+ });
1990
+ _dispatchEvent({
1991
+ sortable: this,
1992
+ name: 'sort',
1993
+ toEl: parentEl,
1994
+ originalEvent: evt
1995
+ });
1996
+ }
1997
+ putSortable && putSortable.save();
1998
+ } else {
1999
+ if (newIndex !== oldIndex) {
2000
+ if (newIndex >= 0) {
2001
+ // drag & drop within the same list
2002
+ _dispatchEvent({
2003
+ sortable: this,
2004
+ name: 'update',
2005
+ toEl: parentEl,
2006
+ originalEvent: evt
2007
+ });
2008
+ _dispatchEvent({
2009
+ sortable: this,
2010
+ name: 'sort',
2011
+ toEl: parentEl,
2012
+ originalEvent: evt
2013
+ });
2014
+ }
2015
+ }
2016
+ }
2017
+ if (Sortable.active) {
2018
+ /* jshint eqnull:true */
2019
+ if (newIndex == null || newIndex === -1) {
2020
+ newIndex = oldIndex;
2021
+ newDraggableIndex = oldDraggableIndex;
2022
+ }
2023
+ _dispatchEvent({
2024
+ sortable: this,
2025
+ name: 'end',
2026
+ toEl: parentEl,
2027
+ originalEvent: evt
2028
+ });
2029
+
2030
+ // Save sorting
2031
+ this.save();
2032
+ }
2033
+ }
2034
+ }
2035
+ this._nulling();
2036
+ },
2037
+ _nulling: function _nulling() {
2038
+ pluginEvent('nulling', this);
2039
+ rootEl = dragEl = parentEl = ghostEl = nextEl = cloneEl = lastDownEl = cloneHidden = tapEvt = touchEvt = moved = newIndex = newDraggableIndex = oldIndex = oldDraggableIndex = lastTarget = lastDirection = putSortable = activeGroup = Sortable.dragged = Sortable.ghost = Sortable.clone = Sortable.active = null;
2040
+ var el = this.el;
2041
+ savedInputChecked.forEach(function (checkEl) {
2042
+ if (el.contains(checkEl)) {
2043
+ checkEl.checked = true;
2044
+ }
2045
+ });
2046
+ savedInputChecked.length = lastDx = lastDy = 0;
2047
+ },
2048
+ handleEvent: function handleEvent( /**Event*/evt) {
2049
+ switch (evt.type) {
2050
+ case 'drop':
2051
+ case 'dragend':
2052
+ this._onDrop(evt);
2053
+ break;
2054
+ case 'dragenter':
2055
+ case 'dragover':
2056
+ if (dragEl) {
2057
+ this._onDragOver(evt);
2058
+ _globalDragOver(evt);
2059
+ }
2060
+ break;
2061
+ case 'selectstart':
2062
+ evt.preventDefault();
2063
+ break;
2064
+ }
2065
+ },
2066
+ /**
2067
+ * Serializes the item into an array of string.
2068
+ * @returns {String[]}
2069
+ */
2070
+ toArray: function toArray() {
2071
+ var order = [],
2072
+ el,
2073
+ children = this.el.children,
2074
+ i = 0,
2075
+ n = children.length,
2076
+ options = this.options;
2077
+ for (; i < n; i++) {
2078
+ el = children[i];
2079
+ if (closest(el, options.draggable, this.el, false)) {
2080
+ order.push(el.getAttribute(options.dataIdAttr) || _generateId(el));
2081
+ }
2082
+ }
2083
+ return order;
2084
+ },
2085
+ /**
2086
+ * Sorts the elements according to the array.
2087
+ * @param {String[]} order order of the items
2088
+ */
2089
+ sort: function sort(order, useAnimation) {
2090
+ var items = {},
2091
+ rootEl = this.el;
2092
+ this.toArray().forEach(function (id, i) {
2093
+ var el = rootEl.children[i];
2094
+ if (closest(el, this.options.draggable, rootEl, false)) {
2095
+ items[id] = el;
2096
+ }
2097
+ }, this);
2098
+ useAnimation && this.captureAnimationState();
2099
+ order.forEach(function (id) {
2100
+ if (items[id]) {
2101
+ rootEl.removeChild(items[id]);
2102
+ rootEl.appendChild(items[id]);
2103
+ }
2104
+ });
2105
+ useAnimation && this.animateAll();
2106
+ },
2107
+ /**
2108
+ * Save the current sorting
2109
+ */
2110
+ save: function save() {
2111
+ var store = this.options.store;
2112
+ store && store.set && store.set(this);
2113
+ },
2114
+ /**
2115
+ * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.
2116
+ * @param {HTMLElement} el
2117
+ * @param {String} [selector] default: `options.draggable`
2118
+ * @returns {HTMLElement|null}
2119
+ */
2120
+ closest: function closest$1(el, selector) {
2121
+ return closest(el, selector || this.options.draggable, this.el, false);
2122
+ },
2123
+ /**
2124
+ * Set/get option
2125
+ * @param {string} name
2126
+ * @param {*} [value]
2127
+ * @returns {*}
2128
+ */
2129
+ option: function option(name, value) {
2130
+ var options = this.options;
2131
+ if (value === void 0) {
2132
+ return options[name];
2133
+ } else {
2134
+ var modifiedValue = PluginManager.modifyOption(this, name, value);
2135
+ if (typeof modifiedValue !== 'undefined') {
2136
+ options[name] = modifiedValue;
2137
+ } else {
2138
+ options[name] = value;
2139
+ }
2140
+ if (name === 'group') {
2141
+ _prepareGroup(options);
2142
+ }
2143
+ }
2144
+ },
2145
+ /**
2146
+ * Destroy
2147
+ */
2148
+ destroy: function destroy() {
2149
+ pluginEvent('destroy', this);
2150
+ var el = this.el;
2151
+ el[expando] = null;
2152
+ off(el, 'mousedown', this._onTapStart);
2153
+ off(el, 'touchstart', this._onTapStart);
2154
+ off(el, 'pointerdown', this._onTapStart);
2155
+ if (this.nativeDraggable) {
2156
+ off(el, 'dragover', this);
2157
+ off(el, 'dragenter', this);
2158
+ }
2159
+ // Remove draggable attributes
2160
+ Array.prototype.forEach.call(el.querySelectorAll('[draggable]'), function (el) {
2161
+ el.removeAttribute('draggable');
2162
+ });
2163
+ this._onDrop();
2164
+ this._disableDelayedDragEvents();
2165
+ sortables.splice(sortables.indexOf(this.el), 1);
2166
+ this.el = el = null;
2167
+ },
2168
+ _hideClone: function _hideClone() {
2169
+ if (!cloneHidden) {
2170
+ pluginEvent('hideClone', this);
2171
+ if (Sortable.eventCanceled) return;
2172
+ css(cloneEl, 'display', 'none');
2173
+ if (this.options.removeCloneOnHide && cloneEl.parentNode) {
2174
+ cloneEl.parentNode.removeChild(cloneEl);
2175
+ }
2176
+ cloneHidden = true;
2177
+ }
2178
+ },
2179
+ _showClone: function _showClone(putSortable) {
2180
+ if (putSortable.lastPutMode !== 'clone') {
2181
+ this._hideClone();
2182
+ return;
2183
+ }
2184
+ if (cloneHidden) {
2185
+ pluginEvent('showClone', this);
2186
+ if (Sortable.eventCanceled) return;
2187
+
2188
+ // show clone at dragEl or original position
2189
+ if (dragEl.parentNode == rootEl && !this.options.group.revertClone) {
2190
+ rootEl.insertBefore(cloneEl, dragEl);
2191
+ } else if (nextEl) {
2192
+ rootEl.insertBefore(cloneEl, nextEl);
2193
+ } else {
2194
+ rootEl.appendChild(cloneEl);
2195
+ }
2196
+ if (this.options.group.revertClone) {
2197
+ this.animate(dragEl, cloneEl);
2198
+ }
2199
+ css(cloneEl, 'display', '');
2200
+ cloneHidden = false;
2201
+ }
2202
+ }
2203
+ };
2204
+ function _globalDragOver( /**Event*/evt) {
2205
+ if (evt.dataTransfer) {
2206
+ evt.dataTransfer.dropEffect = 'move';
2207
+ }
2208
+ evt.cancelable && evt.preventDefault();
2209
+ }
2210
+ function _onMove(fromEl, toEl, dragEl, dragRect, targetEl, targetRect, originalEvent, willInsertAfter) {
2211
+ var evt,
2212
+ sortable = fromEl[expando],
2213
+ onMoveFn = sortable.options.onMove,
2214
+ retVal;
2215
+ // Support for new CustomEvent feature
2216
+ if (window.CustomEvent && !IE11OrLess && !Edge) {
2217
+ evt = new CustomEvent('move', {
2218
+ bubbles: true,
2219
+ cancelable: true
2220
+ });
2221
+ } else {
2222
+ evt = document.createEvent('Event');
2223
+ evt.initEvent('move', true, true);
2224
+ }
2225
+ evt.to = toEl;
2226
+ evt.from = fromEl;
2227
+ evt.dragged = dragEl;
2228
+ evt.draggedRect = dragRect;
2229
+ evt.related = targetEl || toEl;
2230
+ evt.relatedRect = targetRect || getRect(toEl);
2231
+ evt.willInsertAfter = willInsertAfter;
2232
+ evt.originalEvent = originalEvent;
2233
+ fromEl.dispatchEvent(evt);
2234
+ if (onMoveFn) {
2235
+ retVal = onMoveFn.call(sortable, evt, originalEvent);
2236
+ }
2237
+ return retVal;
2238
+ }
2239
+ function _disableDraggable(el) {
2240
+ el.draggable = false;
2241
+ }
2242
+ function _unsilent() {
2243
+ _silent = false;
2244
+ }
2245
+ function _ghostIsFirst(evt, vertical, sortable) {
2246
+ var firstElRect = getRect(getChild(sortable.el, 0, sortable.options, true));
2247
+ var childContainingRect = getChildContainingRectFromElement(sortable.el, sortable.options, ghostEl);
2248
+ var spacer = 10;
2249
+ return vertical ? evt.clientX < childContainingRect.left - spacer || evt.clientY < firstElRect.top && evt.clientX < firstElRect.right : evt.clientY < childContainingRect.top - spacer || evt.clientY < firstElRect.bottom && evt.clientX < firstElRect.left;
2250
+ }
2251
+ function _ghostIsLast(evt, vertical, sortable) {
2252
+ var lastElRect = getRect(lastChild(sortable.el, sortable.options.draggable));
2253
+ var childContainingRect = getChildContainingRectFromElement(sortable.el, sortable.options, ghostEl);
2254
+ var spacer = 10;
2255
+ return vertical ? evt.clientX > childContainingRect.right + spacer || evt.clientY > lastElRect.bottom && evt.clientX > lastElRect.left : evt.clientY > childContainingRect.bottom + spacer || evt.clientX > lastElRect.right && evt.clientY > lastElRect.top;
2256
+ }
2257
+ function _getSwapDirection(evt, target, targetRect, vertical, swapThreshold, invertedSwapThreshold, invertSwap, isLastTarget) {
2258
+ var mouseOnAxis = vertical ? evt.clientY : evt.clientX,
2259
+ targetLength = vertical ? targetRect.height : targetRect.width,
2260
+ targetS1 = vertical ? targetRect.top : targetRect.left,
2261
+ targetS2 = vertical ? targetRect.bottom : targetRect.right,
2262
+ invert = false;
2263
+ if (!invertSwap) {
2264
+ // Never invert or create dragEl shadow when target movemenet causes mouse to move past the end of regular swapThreshold
2265
+ if (isLastTarget && targetMoveDistance < targetLength * swapThreshold) {
2266
+ // multiplied only by swapThreshold because mouse will already be inside target by (1 - threshold) * targetLength / 2
2267
+ // check if past first invert threshold on side opposite of lastDirection
2268
+ if (!pastFirstInvertThresh && (lastDirection === 1 ? mouseOnAxis > targetS1 + targetLength * invertedSwapThreshold / 2 : mouseOnAxis < targetS2 - targetLength * invertedSwapThreshold / 2)) {
2269
+ // past first invert threshold, do not restrict inverted threshold to dragEl shadow
2270
+ pastFirstInvertThresh = true;
2271
+ }
2272
+ if (!pastFirstInvertThresh) {
2273
+ // dragEl shadow (target move distance shadow)
2274
+ if (lastDirection === 1 ? mouseOnAxis < targetS1 + targetMoveDistance // over dragEl shadow
2275
+ : mouseOnAxis > targetS2 - targetMoveDistance) {
2276
+ return -lastDirection;
2277
+ }
2278
+ } else {
2279
+ invert = true;
2280
+ }
2281
+ } else {
2282
+ // Regular
2283
+ if (mouseOnAxis > targetS1 + targetLength * (1 - swapThreshold) / 2 && mouseOnAxis < targetS2 - targetLength * (1 - swapThreshold) / 2) {
2284
+ return _getInsertDirection(target);
2285
+ }
2286
+ }
2287
+ }
2288
+ invert = invert || invertSwap;
2289
+ if (invert) {
2290
+ // Invert of regular
2291
+ if (mouseOnAxis < targetS1 + targetLength * invertedSwapThreshold / 2 || mouseOnAxis > targetS2 - targetLength * invertedSwapThreshold / 2) {
2292
+ return mouseOnAxis > targetS1 + targetLength / 2 ? 1 : -1;
2293
+ }
2294
+ }
2295
+ return 0;
2296
+ }
2297
+
2298
+ /**
2299
+ * Gets the direction dragEl must be swapped relative to target in order to make it
2300
+ * seem that dragEl has been "inserted" into that element's position
2301
+ * @param {HTMLElement} target The target whose position dragEl is being inserted at
2302
+ * @return {Number} Direction dragEl must be swapped
2303
+ */
2304
+ function _getInsertDirection(target) {
2305
+ if (index(dragEl) < index(target)) {
2306
+ return 1;
2307
+ } else {
2308
+ return -1;
2309
+ }
2310
+ }
2311
+
2312
+ /**
2313
+ * Generate id
2314
+ * @param {HTMLElement} el
2315
+ * @returns {String}
2316
+ * @private
2317
+ */
2318
+ function _generateId(el) {
2319
+ var str = el.tagName + el.className + el.src + el.href + el.textContent,
2320
+ i = str.length,
2321
+ sum = 0;
2322
+ while (i--) {
2323
+ sum += str.charCodeAt(i);
2324
+ }
2325
+ return sum.toString(36);
2326
+ }
2327
+ function _saveInputCheckedState(root) {
2328
+ savedInputChecked.length = 0;
2329
+ var inputs = root.getElementsByTagName('input');
2330
+ var idx = inputs.length;
2331
+ while (idx--) {
2332
+ var el = inputs[idx];
2333
+ el.checked && savedInputChecked.push(el);
2334
+ }
2335
+ }
2336
+ function _nextTick(fn) {
2337
+ return setTimeout(fn, 0);
2338
+ }
2339
+ function _cancelNextTick(id) {
2340
+ return clearTimeout(id);
2341
+ }
2342
+
2343
+ // Fixed #973:
2344
+ if (documentExists) {
2345
+ on(document, 'touchmove', function (evt) {
2346
+ if ((Sortable.active || awaitingDragStarted) && evt.cancelable) {
2347
+ evt.preventDefault();
2348
+ }
2349
+ });
2350
+ }
2351
+
2352
+ // Export utils
2353
+ Sortable.utils = {
2354
+ on: on,
2355
+ off: off,
2356
+ css: css,
2357
+ find: find,
2358
+ is: function is(el, selector) {
2359
+ return !!closest(el, selector, el, false);
2360
+ },
2361
+ extend: extend,
2362
+ throttle: throttle,
2363
+ closest: closest,
2364
+ toggleClass: toggleClass,
2365
+ clone: clone,
2366
+ index: index,
2367
+ nextTick: _nextTick,
2368
+ cancelNextTick: _cancelNextTick,
2369
+ detectDirection: _detectDirection,
2370
+ getChild: getChild,
2371
+ expando: expando
2372
+ };
2373
+
2374
+ /**
2375
+ * Get the Sortable instance of an element
2376
+ * @param {HTMLElement} element The element
2377
+ * @return {Sortable|undefined} The instance of Sortable
2378
+ */
2379
+ Sortable.get = function (element) {
2380
+ return element[expando];
2381
+ };
2382
+
2383
+ /**
2384
+ * Mount a plugin to Sortable
2385
+ * @param {...SortablePlugin|SortablePlugin[]} plugins Plugins being mounted
2386
+ */
2387
+ Sortable.mount = function () {
2388
+ for (var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++) {
2389
+ plugins[_key] = arguments[_key];
2390
+ }
2391
+ if (plugins[0].constructor === Array) plugins = plugins[0];
2392
+ plugins.forEach(function (plugin) {
2393
+ if (!plugin.prototype || !plugin.prototype.constructor) {
2394
+ throw "Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(plugin));
2395
+ }
2396
+ if (plugin.utils) Sortable.utils = _objectSpread2(_objectSpread2({}, Sortable.utils), plugin.utils);
2397
+ PluginManager.mount(plugin);
2398
+ });
2399
+ };
2400
+
2401
+ /**
2402
+ * Create sortable instance
2403
+ * @param {HTMLElement} el
2404
+ * @param {Object} [options]
2405
+ */
2406
+ Sortable.create = function (el, options) {
2407
+ return new Sortable(el, options);
2408
+ };
2409
+
2410
+ // Export
2411
+ Sortable.version = version;
2412
+
2413
+ var autoScrolls = [],
2414
+ scrollEl,
2415
+ scrollRootEl,
2416
+ scrolling = false,
2417
+ lastAutoScrollX,
2418
+ lastAutoScrollY,
2419
+ touchEvt$1,
2420
+ pointerElemChangedInterval;
2421
+ function AutoScrollPlugin() {
2422
+ function AutoScroll() {
2423
+ this.defaults = {
2424
+ scroll: true,
2425
+ forceAutoScrollFallback: false,
2426
+ scrollSensitivity: 30,
2427
+ scrollSpeed: 10,
2428
+ bubbleScroll: true
2429
+ };
2430
+
2431
+ // Bind all private methods
2432
+ for (var fn in this) {
2433
+ if (fn.charAt(0) === '_' && typeof this[fn] === 'function') {
2434
+ this[fn] = this[fn].bind(this);
2435
+ }
2436
+ }
2437
+ }
2438
+ AutoScroll.prototype = {
2439
+ dragStarted: function dragStarted(_ref) {
2440
+ var originalEvent = _ref.originalEvent;
2441
+ if (this.sortable.nativeDraggable) {
2442
+ on(document, 'dragover', this._handleAutoScroll);
2443
+ } else {
2444
+ if (this.options.supportPointer) {
2445
+ on(document, 'pointermove', this._handleFallbackAutoScroll);
2446
+ } else if (originalEvent.touches) {
2447
+ on(document, 'touchmove', this._handleFallbackAutoScroll);
2448
+ } else {
2449
+ on(document, 'mousemove', this._handleFallbackAutoScroll);
2450
+ }
2451
+ }
2452
+ },
2453
+ dragOverCompleted: function dragOverCompleted(_ref2) {
2454
+ var originalEvent = _ref2.originalEvent;
2455
+ // For when bubbling is canceled and using fallback (fallback 'touchmove' always reached)
2456
+ if (!this.options.dragOverBubble && !originalEvent.rootEl) {
2457
+ this._handleAutoScroll(originalEvent);
2458
+ }
2459
+ },
2460
+ drop: function drop() {
2461
+ if (this.sortable.nativeDraggable) {
2462
+ off(document, 'dragover', this._handleAutoScroll);
2463
+ } else {
2464
+ off(document, 'pointermove', this._handleFallbackAutoScroll);
2465
+ off(document, 'touchmove', this._handleFallbackAutoScroll);
2466
+ off(document, 'mousemove', this._handleFallbackAutoScroll);
2467
+ }
2468
+ clearPointerElemChangedInterval();
2469
+ clearAutoScrolls();
2470
+ cancelThrottle();
2471
+ },
2472
+ nulling: function nulling() {
2473
+ touchEvt$1 = scrollRootEl = scrollEl = scrolling = pointerElemChangedInterval = lastAutoScrollX = lastAutoScrollY = null;
2474
+ autoScrolls.length = 0;
2475
+ },
2476
+ _handleFallbackAutoScroll: function _handleFallbackAutoScroll(evt) {
2477
+ this._handleAutoScroll(evt, true);
2478
+ },
2479
+ _handleAutoScroll: function _handleAutoScroll(evt, fallback) {
2480
+ var _this = this;
2481
+ var x = (evt.touches ? evt.touches[0] : evt).clientX,
2482
+ y = (evt.touches ? evt.touches[0] : evt).clientY,
2483
+ elem = document.elementFromPoint(x, y);
2484
+ touchEvt$1 = evt;
2485
+
2486
+ // IE does not seem to have native autoscroll,
2487
+ // Edge's autoscroll seems too conditional,
2488
+ // MACOS Safari does not have autoscroll,
2489
+ // Firefox and Chrome are good
2490
+ if (fallback || this.options.forceAutoScrollFallback || Edge || IE11OrLess || Safari) {
2491
+ autoScroll(evt, this.options, elem, fallback);
2492
+
2493
+ // Listener for pointer element change
2494
+ var ogElemScroller = getParentAutoScrollElement(elem, true);
2495
+ if (scrolling && (!pointerElemChangedInterval || x !== lastAutoScrollX || y !== lastAutoScrollY)) {
2496
+ pointerElemChangedInterval && clearPointerElemChangedInterval();
2497
+ // Detect for pointer elem change, emulating native DnD behaviour
2498
+ pointerElemChangedInterval = setInterval(function () {
2499
+ var newElem = getParentAutoScrollElement(document.elementFromPoint(x, y), true);
2500
+ if (newElem !== ogElemScroller) {
2501
+ ogElemScroller = newElem;
2502
+ clearAutoScrolls();
2503
+ }
2504
+ autoScroll(evt, _this.options, newElem, fallback);
2505
+ }, 10);
2506
+ lastAutoScrollX = x;
2507
+ lastAutoScrollY = y;
2508
+ }
2509
+ } else {
2510
+ // if DnD is enabled (and browser has good autoscrolling), first autoscroll will already scroll, so get parent autoscroll of first autoscroll
2511
+ if (!this.options.bubbleScroll || getParentAutoScrollElement(elem, true) === getWindowScrollingElement()) {
2512
+ clearAutoScrolls();
2513
+ return;
2514
+ }
2515
+ autoScroll(evt, this.options, getParentAutoScrollElement(elem, false), false);
2516
+ }
2517
+ }
2518
+ };
2519
+ return _extends(AutoScroll, {
2520
+ pluginName: 'scroll',
2521
+ initializeByDefault: true
2522
+ });
2523
+ }
2524
+ function clearAutoScrolls() {
2525
+ autoScrolls.forEach(function (autoScroll) {
2526
+ clearInterval(autoScroll.pid);
2527
+ });
2528
+ autoScrolls = [];
2529
+ }
2530
+ function clearPointerElemChangedInterval() {
2531
+ clearInterval(pointerElemChangedInterval);
2532
+ }
2533
+ var autoScroll = throttle(function (evt, options, rootEl, isFallback) {
2534
+ // Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=505521
2535
+ if (!options.scroll) return;
2536
+ var x = (evt.touches ? evt.touches[0] : evt).clientX,
2537
+ y = (evt.touches ? evt.touches[0] : evt).clientY,
2538
+ sens = options.scrollSensitivity,
2539
+ speed = options.scrollSpeed,
2540
+ winScroller = getWindowScrollingElement();
2541
+ var scrollThisInstance = false,
2542
+ scrollCustomFn;
2543
+
2544
+ // New scroll root, set scrollEl
2545
+ if (scrollRootEl !== rootEl) {
2546
+ scrollRootEl = rootEl;
2547
+ clearAutoScrolls();
2548
+ scrollEl = options.scroll;
2549
+ scrollCustomFn = options.scrollFn;
2550
+ if (scrollEl === true) {
2551
+ scrollEl = getParentAutoScrollElement(rootEl, true);
2552
+ }
2553
+ }
2554
+ var layersOut = 0;
2555
+ var currentParent = scrollEl;
2556
+ do {
2557
+ var el = currentParent,
2558
+ rect = getRect(el),
2559
+ top = rect.top,
2560
+ bottom = rect.bottom,
2561
+ left = rect.left,
2562
+ right = rect.right,
2563
+ width = rect.width,
2564
+ height = rect.height,
2565
+ canScrollX = void 0,
2566
+ canScrollY = void 0,
2567
+ scrollWidth = el.scrollWidth,
2568
+ scrollHeight = el.scrollHeight,
2569
+ elCSS = css(el),
2570
+ scrollPosX = el.scrollLeft,
2571
+ scrollPosY = el.scrollTop;
2572
+ if (el === winScroller) {
2573
+ canScrollX = width < scrollWidth && (elCSS.overflowX === 'auto' || elCSS.overflowX === 'scroll' || elCSS.overflowX === 'visible');
2574
+ canScrollY = height < scrollHeight && (elCSS.overflowY === 'auto' || elCSS.overflowY === 'scroll' || elCSS.overflowY === 'visible');
2575
+ } else {
2576
+ canScrollX = width < scrollWidth && (elCSS.overflowX === 'auto' || elCSS.overflowX === 'scroll');
2577
+ canScrollY = height < scrollHeight && (elCSS.overflowY === 'auto' || elCSS.overflowY === 'scroll');
2578
+ }
2579
+ var vx = canScrollX && (Math.abs(right - x) <= sens && scrollPosX + width < scrollWidth) - (Math.abs(left - x) <= sens && !!scrollPosX);
2580
+ var vy = canScrollY && (Math.abs(bottom - y) <= sens && scrollPosY + height < scrollHeight) - (Math.abs(top - y) <= sens && !!scrollPosY);
2581
+ if (!autoScrolls[layersOut]) {
2582
+ for (var i = 0; i <= layersOut; i++) {
2583
+ if (!autoScrolls[i]) {
2584
+ autoScrolls[i] = {};
2585
+ }
2586
+ }
2587
+ }
2588
+ if (autoScrolls[layersOut].vx != vx || autoScrolls[layersOut].vy != vy || autoScrolls[layersOut].el !== el) {
2589
+ autoScrolls[layersOut].el = el;
2590
+ autoScrolls[layersOut].vx = vx;
2591
+ autoScrolls[layersOut].vy = vy;
2592
+ clearInterval(autoScrolls[layersOut].pid);
2593
+ if (vx != 0 || vy != 0) {
2594
+ scrollThisInstance = true;
2595
+ /* jshint loopfunc:true */
2596
+ autoScrolls[layersOut].pid = setInterval(function () {
2597
+ // emulate drag over during autoscroll (fallback), emulating native DnD behaviour
2598
+ if (isFallback && this.layer === 0) {
2599
+ Sortable.active._onTouchMove(touchEvt$1); // To move ghost if it is positioned absolutely
2600
+ }
2601
+ var scrollOffsetY = autoScrolls[this.layer].vy ? autoScrolls[this.layer].vy * speed : 0;
2602
+ var scrollOffsetX = autoScrolls[this.layer].vx ? autoScrolls[this.layer].vx * speed : 0;
2603
+ if (typeof scrollCustomFn === 'function') {
2604
+ if (scrollCustomFn.call(Sortable.dragged.parentNode[expando], scrollOffsetX, scrollOffsetY, evt, touchEvt$1, autoScrolls[this.layer].el) !== 'continue') {
2605
+ return;
2606
+ }
2607
+ }
2608
+ scrollBy(autoScrolls[this.layer].el, scrollOffsetX, scrollOffsetY);
2609
+ }.bind({
2610
+ layer: layersOut
2611
+ }), 24);
2612
+ }
2613
+ }
2614
+ layersOut++;
2615
+ } while (options.bubbleScroll && currentParent !== winScroller && (currentParent = getParentAutoScrollElement(currentParent, false)));
2616
+ scrolling = scrollThisInstance; // in case another function catches scrolling as false in between when it is not
2617
+ }, 30);
2618
+
2619
+ var drop = function drop(_ref) {
2620
+ var originalEvent = _ref.originalEvent,
2621
+ putSortable = _ref.putSortable,
2622
+ dragEl = _ref.dragEl,
2623
+ activeSortable = _ref.activeSortable,
2624
+ dispatchSortableEvent = _ref.dispatchSortableEvent,
2625
+ hideGhostForTarget = _ref.hideGhostForTarget,
2626
+ unhideGhostForTarget = _ref.unhideGhostForTarget;
2627
+ if (!originalEvent) return;
2628
+ var toSortable = putSortable || activeSortable;
2629
+ hideGhostForTarget();
2630
+ var touch = originalEvent.changedTouches && originalEvent.changedTouches.length ? originalEvent.changedTouches[0] : originalEvent;
2631
+ var target = document.elementFromPoint(touch.clientX, touch.clientY);
2632
+ unhideGhostForTarget();
2633
+ if (toSortable && !toSortable.el.contains(target)) {
2634
+ dispatchSortableEvent('spill');
2635
+ this.onSpill({
2636
+ dragEl: dragEl,
2637
+ putSortable: putSortable
2638
+ });
2639
+ }
2640
+ };
2641
+ function Revert() {}
2642
+ Revert.prototype = {
2643
+ startIndex: null,
2644
+ dragStart: function dragStart(_ref2) {
2645
+ var oldDraggableIndex = _ref2.oldDraggableIndex;
2646
+ this.startIndex = oldDraggableIndex;
2647
+ },
2648
+ onSpill: function onSpill(_ref3) {
2649
+ var dragEl = _ref3.dragEl,
2650
+ putSortable = _ref3.putSortable;
2651
+ this.sortable.captureAnimationState();
2652
+ if (putSortable) {
2653
+ putSortable.captureAnimationState();
2654
+ }
2655
+ var nextSibling = getChild(this.sortable.el, this.startIndex, this.options);
2656
+ if (nextSibling) {
2657
+ this.sortable.el.insertBefore(dragEl, nextSibling);
2658
+ } else {
2659
+ this.sortable.el.appendChild(dragEl);
2660
+ }
2661
+ this.sortable.animateAll();
2662
+ if (putSortable) {
2663
+ putSortable.animateAll();
2664
+ }
2665
+ },
2666
+ drop: drop
2667
+ };
2668
+ _extends(Revert, {
2669
+ pluginName: 'revertOnSpill'
2670
+ });
2671
+ function Remove() {}
2672
+ Remove.prototype = {
2673
+ onSpill: function onSpill(_ref4) {
2674
+ var dragEl = _ref4.dragEl,
2675
+ putSortable = _ref4.putSortable;
2676
+ var parentSortable = putSortable || this.sortable;
2677
+ parentSortable.captureAnimationState();
2678
+ dragEl.parentNode && dragEl.parentNode.removeChild(dragEl);
2679
+ parentSortable.animateAll();
2680
+ },
2681
+ drop: drop
2682
+ };
2683
+ _extends(Remove, {
2684
+ pluginName: 'removeOnSpill'
2685
+ });
2686
+
2687
+ var lastSwapEl;
2688
+ function SwapPlugin() {
2689
+ function Swap() {
2690
+ this.defaults = {
2691
+ swapClass: 'sortable-swap-highlight'
2692
+ };
2693
+ }
2694
+ Swap.prototype = {
2695
+ dragStart: function dragStart(_ref) {
2696
+ var dragEl = _ref.dragEl;
2697
+ lastSwapEl = dragEl;
2698
+ },
2699
+ dragOverValid: function dragOverValid(_ref2) {
2700
+ var completed = _ref2.completed,
2701
+ target = _ref2.target,
2702
+ onMove = _ref2.onMove,
2703
+ activeSortable = _ref2.activeSortable,
2704
+ changed = _ref2.changed,
2705
+ cancel = _ref2.cancel;
2706
+ if (!activeSortable.options.swap) return;
2707
+ var el = this.sortable.el,
2708
+ options = this.options;
2709
+ if (target && target !== el) {
2710
+ var prevSwapEl = lastSwapEl;
2711
+ if (onMove(target) !== false) {
2712
+ toggleClass(target, options.swapClass, true);
2713
+ lastSwapEl = target;
2714
+ } else {
2715
+ lastSwapEl = null;
2716
+ }
2717
+ if (prevSwapEl && prevSwapEl !== lastSwapEl) {
2718
+ toggleClass(prevSwapEl, options.swapClass, false);
2719
+ }
2720
+ }
2721
+ changed();
2722
+ completed(true);
2723
+ cancel();
2724
+ },
2725
+ drop: function drop(_ref3) {
2726
+ var activeSortable = _ref3.activeSortable,
2727
+ putSortable = _ref3.putSortable,
2728
+ dragEl = _ref3.dragEl;
2729
+ var toSortable = putSortable || this.sortable;
2730
+ var options = this.options;
2731
+ lastSwapEl && toggleClass(lastSwapEl, options.swapClass, false);
2732
+ if (lastSwapEl && (options.swap || putSortable && putSortable.options.swap)) {
2733
+ if (dragEl !== lastSwapEl) {
2734
+ toSortable.captureAnimationState();
2735
+ if (toSortable !== activeSortable) activeSortable.captureAnimationState();
2736
+ swapNodes(dragEl, lastSwapEl);
2737
+ toSortable.animateAll();
2738
+ if (toSortable !== activeSortable) activeSortable.animateAll();
2739
+ }
2740
+ }
2741
+ },
2742
+ nulling: function nulling() {
2743
+ lastSwapEl = null;
2744
+ }
2745
+ };
2746
+ return _extends(Swap, {
2747
+ pluginName: 'swap',
2748
+ eventProperties: function eventProperties() {
2749
+ return {
2750
+ swapItem: lastSwapEl
2751
+ };
2752
+ }
2753
+ });
2754
+ }
2755
+ function swapNodes(n1, n2) {
2756
+ var p1 = n1.parentNode,
2757
+ p2 = n2.parentNode,
2758
+ i1,
2759
+ i2;
2760
+ if (!p1 || !p2 || p1.isEqualNode(n2) || p2.isEqualNode(n1)) return;
2761
+ i1 = index(n1);
2762
+ i2 = index(n2);
2763
+ if (p1.isEqualNode(p2) && i1 < i2) {
2764
+ i2++;
2765
+ }
2766
+ p1.insertBefore(n2, p1.children[i1]);
2767
+ p2.insertBefore(n1, p2.children[i2]);
2768
+ }
2769
+
2770
+ var multiDragElements = [],
2771
+ multiDragClones = [],
2772
+ lastMultiDragSelect,
2773
+ // for selection with modifier key down (SHIFT)
2774
+ multiDragSortable,
2775
+ initialFolding = false,
2776
+ // Initial multi-drag fold when drag started
2777
+ folding = false,
2778
+ // Folding any other time
2779
+ dragStarted = false,
2780
+ dragEl$1,
2781
+ clonesFromRect,
2782
+ clonesHidden;
2783
+ function MultiDragPlugin() {
2784
+ function MultiDrag(sortable) {
2785
+ // Bind all private methods
2786
+ for (var fn in this) {
2787
+ if (fn.charAt(0) === '_' && typeof this[fn] === 'function') {
2788
+ this[fn] = this[fn].bind(this);
2789
+ }
2790
+ }
2791
+ if (!sortable.options.avoidImplicitDeselect) {
2792
+ if (sortable.options.supportPointer) {
2793
+ on(document, 'pointerup', this._deselectMultiDrag);
2794
+ } else {
2795
+ on(document, 'mouseup', this._deselectMultiDrag);
2796
+ on(document, 'touchend', this._deselectMultiDrag);
2797
+ }
2798
+ }
2799
+ on(document, 'keydown', this._checkKeyDown);
2800
+ on(document, 'keyup', this._checkKeyUp);
2801
+ this.defaults = {
2802
+ selectedClass: 'sortable-selected',
2803
+ multiDragKey: null,
2804
+ avoidImplicitDeselect: false,
2805
+ setData: function setData(dataTransfer, dragEl) {
2806
+ var data = '';
2807
+ if (multiDragElements.length && multiDragSortable === sortable) {
2808
+ multiDragElements.forEach(function (multiDragElement, i) {
2809
+ data += (!i ? '' : ', ') + multiDragElement.textContent;
2810
+ });
2811
+ } else {
2812
+ data = dragEl.textContent;
2813
+ }
2814
+ dataTransfer.setData('Text', data);
2815
+ }
2816
+ };
2817
+ }
2818
+ MultiDrag.prototype = {
2819
+ multiDragKeyDown: false,
2820
+ isMultiDrag: false,
2821
+ delayStartGlobal: function delayStartGlobal(_ref) {
2822
+ var dragged = _ref.dragEl;
2823
+ dragEl$1 = dragged;
2824
+ },
2825
+ delayEnded: function delayEnded() {
2826
+ this.isMultiDrag = ~multiDragElements.indexOf(dragEl$1);
2827
+ },
2828
+ setupClone: function setupClone(_ref2) {
2829
+ var sortable = _ref2.sortable,
2830
+ cancel = _ref2.cancel;
2831
+ if (!this.isMultiDrag) return;
2832
+ for (var i = 0; i < multiDragElements.length; i++) {
2833
+ multiDragClones.push(clone(multiDragElements[i]));
2834
+ multiDragClones[i].sortableIndex = multiDragElements[i].sortableIndex;
2835
+ multiDragClones[i].draggable = false;
2836
+ multiDragClones[i].style['will-change'] = '';
2837
+ toggleClass(multiDragClones[i], this.options.selectedClass, false);
2838
+ multiDragElements[i] === dragEl$1 && toggleClass(multiDragClones[i], this.options.chosenClass, false);
2839
+ }
2840
+ sortable._hideClone();
2841
+ cancel();
2842
+ },
2843
+ clone: function clone(_ref3) {
2844
+ var sortable = _ref3.sortable,
2845
+ rootEl = _ref3.rootEl,
2846
+ dispatchSortableEvent = _ref3.dispatchSortableEvent,
2847
+ cancel = _ref3.cancel;
2848
+ if (!this.isMultiDrag) return;
2849
+ if (!this.options.removeCloneOnHide) {
2850
+ if (multiDragElements.length && multiDragSortable === sortable) {
2851
+ insertMultiDragClones(true, rootEl);
2852
+ dispatchSortableEvent('clone');
2853
+ cancel();
2854
+ }
2855
+ }
2856
+ },
2857
+ showClone: function showClone(_ref4) {
2858
+ var cloneNowShown = _ref4.cloneNowShown,
2859
+ rootEl = _ref4.rootEl,
2860
+ cancel = _ref4.cancel;
2861
+ if (!this.isMultiDrag) return;
2862
+ insertMultiDragClones(false, rootEl);
2863
+ multiDragClones.forEach(function (clone) {
2864
+ css(clone, 'display', '');
2865
+ });
2866
+ cloneNowShown();
2867
+ clonesHidden = false;
2868
+ cancel();
2869
+ },
2870
+ hideClone: function hideClone(_ref5) {
2871
+ var _this = this;
2872
+ var sortable = _ref5.sortable,
2873
+ cloneNowHidden = _ref5.cloneNowHidden,
2874
+ cancel = _ref5.cancel;
2875
+ if (!this.isMultiDrag) return;
2876
+ multiDragClones.forEach(function (clone) {
2877
+ css(clone, 'display', 'none');
2878
+ if (_this.options.removeCloneOnHide && clone.parentNode) {
2879
+ clone.parentNode.removeChild(clone);
2880
+ }
2881
+ });
2882
+ cloneNowHidden();
2883
+ clonesHidden = true;
2884
+ cancel();
2885
+ },
2886
+ dragStartGlobal: function dragStartGlobal(_ref6) {
2887
+ var sortable = _ref6.sortable;
2888
+ if (!this.isMultiDrag && multiDragSortable) {
2889
+ multiDragSortable.multiDrag._deselectMultiDrag();
2890
+ }
2891
+ multiDragElements.forEach(function (multiDragElement) {
2892
+ multiDragElement.sortableIndex = index(multiDragElement);
2893
+ });
2894
+
2895
+ // Sort multi-drag elements
2896
+ multiDragElements = multiDragElements.sort(function (a, b) {
2897
+ return a.sortableIndex - b.sortableIndex;
2898
+ });
2899
+ dragStarted = true;
2900
+ },
2901
+ dragStarted: function dragStarted(_ref7) {
2902
+ var _this2 = this;
2903
+ var sortable = _ref7.sortable;
2904
+ if (!this.isMultiDrag) return;
2905
+ if (this.options.sort) {
2906
+ // Capture rects,
2907
+ // hide multi drag elements (by positioning them absolute),
2908
+ // set multi drag elements rects to dragRect,
2909
+ // show multi drag elements,
2910
+ // animate to rects,
2911
+ // unset rects & remove from DOM
2912
+
2913
+ sortable.captureAnimationState();
2914
+ if (this.options.animation) {
2915
+ multiDragElements.forEach(function (multiDragElement) {
2916
+ if (multiDragElement === dragEl$1) return;
2917
+ css(multiDragElement, 'position', 'absolute');
2918
+ });
2919
+ var dragRect = getRect(dragEl$1, false, true, true);
2920
+ multiDragElements.forEach(function (multiDragElement) {
2921
+ if (multiDragElement === dragEl$1) return;
2922
+ setRect(multiDragElement, dragRect);
2923
+ });
2924
+ folding = true;
2925
+ initialFolding = true;
2926
+ }
2927
+ }
2928
+ sortable.animateAll(function () {
2929
+ folding = false;
2930
+ initialFolding = false;
2931
+ if (_this2.options.animation) {
2932
+ multiDragElements.forEach(function (multiDragElement) {
2933
+ unsetRect(multiDragElement);
2934
+ });
2935
+ }
2936
+
2937
+ // Remove all auxiliary multidrag items from el, if sorting enabled
2938
+ if (_this2.options.sort) {
2939
+ removeMultiDragElements();
2940
+ }
2941
+ });
2942
+ },
2943
+ dragOver: function dragOver(_ref8) {
2944
+ var target = _ref8.target,
2945
+ completed = _ref8.completed,
2946
+ cancel = _ref8.cancel;
2947
+ if (folding && ~multiDragElements.indexOf(target)) {
2948
+ completed(false);
2949
+ cancel();
2950
+ }
2951
+ },
2952
+ revert: function revert(_ref9) {
2953
+ var fromSortable = _ref9.fromSortable,
2954
+ rootEl = _ref9.rootEl,
2955
+ sortable = _ref9.sortable,
2956
+ dragRect = _ref9.dragRect;
2957
+ if (multiDragElements.length > 1) {
2958
+ // Setup unfold animation
2959
+ multiDragElements.forEach(function (multiDragElement) {
2960
+ sortable.addAnimationState({
2961
+ target: multiDragElement,
2962
+ rect: folding ? getRect(multiDragElement) : dragRect
2963
+ });
2964
+ unsetRect(multiDragElement);
2965
+ multiDragElement.fromRect = dragRect;
2966
+ fromSortable.removeAnimationState(multiDragElement);
2967
+ });
2968
+ folding = false;
2969
+ insertMultiDragElements(!this.options.removeCloneOnHide, rootEl);
2970
+ }
2971
+ },
2972
+ dragOverCompleted: function dragOverCompleted(_ref10) {
2973
+ var sortable = _ref10.sortable,
2974
+ isOwner = _ref10.isOwner,
2975
+ insertion = _ref10.insertion,
2976
+ activeSortable = _ref10.activeSortable,
2977
+ parentEl = _ref10.parentEl,
2978
+ putSortable = _ref10.putSortable;
2979
+ var options = this.options;
2980
+ if (insertion) {
2981
+ // Clones must be hidden before folding animation to capture dragRectAbsolute properly
2982
+ if (isOwner) {
2983
+ activeSortable._hideClone();
2984
+ }
2985
+ initialFolding = false;
2986
+ // If leaving sort:false root, or already folding - Fold to new location
2987
+ if (options.animation && multiDragElements.length > 1 && (folding || !isOwner && !activeSortable.options.sort && !putSortable)) {
2988
+ // Fold: Set all multi drag elements's rects to dragEl's rect when multi-drag elements are invisible
2989
+ var dragRectAbsolute = getRect(dragEl$1, false, true, true);
2990
+ multiDragElements.forEach(function (multiDragElement) {
2991
+ if (multiDragElement === dragEl$1) return;
2992
+ setRect(multiDragElement, dragRectAbsolute);
2993
+
2994
+ // Move element(s) to end of parentEl so that it does not interfere with multi-drag clones insertion if they are inserted
2995
+ // while folding, and so that we can capture them again because old sortable will no longer be fromSortable
2996
+ parentEl.appendChild(multiDragElement);
2997
+ });
2998
+ folding = true;
2999
+ }
3000
+
3001
+ // Clones must be shown (and check to remove multi drags) after folding when interfering multiDragElements are moved out
3002
+ if (!isOwner) {
3003
+ // Only remove if not folding (folding will remove them anyways)
3004
+ if (!folding) {
3005
+ removeMultiDragElements();
3006
+ }
3007
+ if (multiDragElements.length > 1) {
3008
+ var clonesHiddenBefore = clonesHidden;
3009
+ activeSortable._showClone(sortable);
3010
+
3011
+ // Unfold animation for clones if showing from hidden
3012
+ if (activeSortable.options.animation && !clonesHidden && clonesHiddenBefore) {
3013
+ multiDragClones.forEach(function (clone) {
3014
+ activeSortable.addAnimationState({
3015
+ target: clone,
3016
+ rect: clonesFromRect
3017
+ });
3018
+ clone.fromRect = clonesFromRect;
3019
+ clone.thisAnimationDuration = null;
3020
+ });
3021
+ }
3022
+ } else {
3023
+ activeSortable._showClone(sortable);
3024
+ }
3025
+ }
3026
+ }
3027
+ },
3028
+ dragOverAnimationCapture: function dragOverAnimationCapture(_ref11) {
3029
+ var dragRect = _ref11.dragRect,
3030
+ isOwner = _ref11.isOwner,
3031
+ activeSortable = _ref11.activeSortable;
3032
+ multiDragElements.forEach(function (multiDragElement) {
3033
+ multiDragElement.thisAnimationDuration = null;
3034
+ });
3035
+ if (activeSortable.options.animation && !isOwner && activeSortable.multiDrag.isMultiDrag) {
3036
+ clonesFromRect = _extends({}, dragRect);
3037
+ var dragMatrix = matrix(dragEl$1, true);
3038
+ clonesFromRect.top -= dragMatrix.f;
3039
+ clonesFromRect.left -= dragMatrix.e;
3040
+ }
3041
+ },
3042
+ dragOverAnimationComplete: function dragOverAnimationComplete() {
3043
+ if (folding) {
3044
+ folding = false;
3045
+ removeMultiDragElements();
3046
+ }
3047
+ },
3048
+ drop: function drop(_ref12) {
3049
+ var evt = _ref12.originalEvent,
3050
+ rootEl = _ref12.rootEl,
3051
+ parentEl = _ref12.parentEl,
3052
+ sortable = _ref12.sortable,
3053
+ dispatchSortableEvent = _ref12.dispatchSortableEvent,
3054
+ oldIndex = _ref12.oldIndex,
3055
+ putSortable = _ref12.putSortable;
3056
+ var toSortable = putSortable || this.sortable;
3057
+ if (!evt) return;
3058
+ var options = this.options,
3059
+ children = parentEl.children;
3060
+
3061
+ // Multi-drag selection
3062
+ if (!dragStarted) {
3063
+ if (options.multiDragKey && !this.multiDragKeyDown) {
3064
+ this._deselectMultiDrag();
3065
+ }
3066
+ toggleClass(dragEl$1, options.selectedClass, !~multiDragElements.indexOf(dragEl$1));
3067
+ if (!~multiDragElements.indexOf(dragEl$1)) {
3068
+ multiDragElements.push(dragEl$1);
3069
+ dispatchEvent({
3070
+ sortable: sortable,
3071
+ rootEl: rootEl,
3072
+ name: 'select',
3073
+ targetEl: dragEl$1,
3074
+ originalEvent: evt
3075
+ });
3076
+
3077
+ // Modifier activated, select from last to dragEl
3078
+ if (evt.shiftKey && lastMultiDragSelect && sortable.el.contains(lastMultiDragSelect)) {
3079
+ var lastIndex = index(lastMultiDragSelect),
3080
+ currentIndex = index(dragEl$1);
3081
+ if (~lastIndex && ~currentIndex && lastIndex !== currentIndex) {
3082
+ (function () {
3083
+ // Must include lastMultiDragSelect (select it), in case modified selection from no selection
3084
+ // (but previous selection existed)
3085
+ var n, i;
3086
+ if (currentIndex > lastIndex) {
3087
+ i = lastIndex;
3088
+ n = currentIndex;
3089
+ } else {
3090
+ i = currentIndex;
3091
+ n = lastIndex + 1;
3092
+ }
3093
+ var filter = options.filter;
3094
+ for (; i < n; i++) {
3095
+ if (~multiDragElements.indexOf(children[i])) continue;
3096
+ // Check if element is draggable
3097
+ if (!closest(children[i], options.draggable, parentEl, false)) continue;
3098
+ // Check if element is filtered
3099
+ var filtered = filter && (typeof filter === 'function' ? filter.call(sortable, evt, children[i], sortable) : filter.split(',').some(function (criteria) {
3100
+ return closest(children[i], criteria.trim(), parentEl, false);
3101
+ }));
3102
+ if (filtered) continue;
3103
+ toggleClass(children[i], options.selectedClass, true);
3104
+ multiDragElements.push(children[i]);
3105
+ dispatchEvent({
3106
+ sortable: sortable,
3107
+ rootEl: rootEl,
3108
+ name: 'select',
3109
+ targetEl: children[i],
3110
+ originalEvent: evt
3111
+ });
3112
+ }
3113
+ })();
3114
+ }
3115
+ } else {
3116
+ lastMultiDragSelect = dragEl$1;
3117
+ }
3118
+ multiDragSortable = toSortable;
3119
+ } else {
3120
+ multiDragElements.splice(multiDragElements.indexOf(dragEl$1), 1);
3121
+ lastMultiDragSelect = null;
3122
+ dispatchEvent({
3123
+ sortable: sortable,
3124
+ rootEl: rootEl,
3125
+ name: 'deselect',
3126
+ targetEl: dragEl$1,
3127
+ originalEvent: evt
3128
+ });
3129
+ }
3130
+ }
3131
+
3132
+ // Multi-drag drop
3133
+ if (dragStarted && this.isMultiDrag) {
3134
+ folding = false;
3135
+ // Do not "unfold" after around dragEl if reverted
3136
+ if ((parentEl[expando].options.sort || parentEl !== rootEl) && multiDragElements.length > 1) {
3137
+ var dragRect = getRect(dragEl$1),
3138
+ multiDragIndex = index(dragEl$1, ':not(.' + this.options.selectedClass + ')');
3139
+ if (!initialFolding && options.animation) dragEl$1.thisAnimationDuration = null;
3140
+ toSortable.captureAnimationState();
3141
+ if (!initialFolding) {
3142
+ if (options.animation) {
3143
+ dragEl$1.fromRect = dragRect;
3144
+ multiDragElements.forEach(function (multiDragElement) {
3145
+ multiDragElement.thisAnimationDuration = null;
3146
+ if (multiDragElement !== dragEl$1) {
3147
+ var rect = folding ? getRect(multiDragElement) : dragRect;
3148
+ multiDragElement.fromRect = rect;
3149
+
3150
+ // Prepare unfold animation
3151
+ toSortable.addAnimationState({
3152
+ target: multiDragElement,
3153
+ rect: rect
3154
+ });
3155
+ }
3156
+ });
3157
+ }
3158
+
3159
+ // Multi drag elements are not necessarily removed from the DOM on drop, so to reinsert
3160
+ // properly they must all be removed
3161
+ removeMultiDragElements();
3162
+ multiDragElements.forEach(function (multiDragElement) {
3163
+ if (children[multiDragIndex]) {
3164
+ parentEl.insertBefore(multiDragElement, children[multiDragIndex]);
3165
+ } else {
3166
+ parentEl.appendChild(multiDragElement);
3167
+ }
3168
+ multiDragIndex++;
3169
+ });
3170
+
3171
+ // If initial folding is done, the elements may have changed position because they are now
3172
+ // unfolding around dragEl, even though dragEl may not have his index changed, so update event
3173
+ // must be fired here as Sortable will not.
3174
+ if (oldIndex === index(dragEl$1)) {
3175
+ var update = false;
3176
+ multiDragElements.forEach(function (multiDragElement) {
3177
+ if (multiDragElement.sortableIndex !== index(multiDragElement)) {
3178
+ update = true;
3179
+ return;
3180
+ }
3181
+ });
3182
+ if (update) {
3183
+ dispatchSortableEvent('update');
3184
+ dispatchSortableEvent('sort');
3185
+ }
3186
+ }
3187
+ }
3188
+
3189
+ // Must be done after capturing individual rects (scroll bar)
3190
+ multiDragElements.forEach(function (multiDragElement) {
3191
+ unsetRect(multiDragElement);
3192
+ });
3193
+ toSortable.animateAll();
3194
+ }
3195
+ multiDragSortable = toSortable;
3196
+ }
3197
+
3198
+ // Remove clones if necessary
3199
+ if (rootEl === parentEl || putSortable && putSortable.lastPutMode !== 'clone') {
3200
+ multiDragClones.forEach(function (clone) {
3201
+ clone.parentNode && clone.parentNode.removeChild(clone);
3202
+ });
3203
+ }
3204
+ },
3205
+ nullingGlobal: function nullingGlobal() {
3206
+ this.isMultiDrag = dragStarted = false;
3207
+ multiDragClones.length = 0;
3208
+ },
3209
+ destroyGlobal: function destroyGlobal() {
3210
+ this._deselectMultiDrag();
3211
+ off(document, 'pointerup', this._deselectMultiDrag);
3212
+ off(document, 'mouseup', this._deselectMultiDrag);
3213
+ off(document, 'touchend', this._deselectMultiDrag);
3214
+ off(document, 'keydown', this._checkKeyDown);
3215
+ off(document, 'keyup', this._checkKeyUp);
3216
+ },
3217
+ _deselectMultiDrag: function _deselectMultiDrag(evt) {
3218
+ if (typeof dragStarted !== "undefined" && dragStarted) return;
3219
+
3220
+ // Only deselect if selection is in this sortable
3221
+ if (multiDragSortable !== this.sortable) return;
3222
+
3223
+ // Only deselect if target is not item in this sortable
3224
+ if (evt && closest(evt.target, this.options.draggable, this.sortable.el, false)) return;
3225
+
3226
+ // Only deselect if left click
3227
+ if (evt && evt.button !== 0) return;
3228
+ while (multiDragElements.length) {
3229
+ var el = multiDragElements[0];
3230
+ toggleClass(el, this.options.selectedClass, false);
3231
+ multiDragElements.shift();
3232
+ dispatchEvent({
3233
+ sortable: this.sortable,
3234
+ rootEl: this.sortable.el,
3235
+ name: 'deselect',
3236
+ targetEl: el,
3237
+ originalEvent: evt
3238
+ });
3239
+ }
3240
+ },
3241
+ _checkKeyDown: function _checkKeyDown(evt) {
3242
+ if (evt.key === this.options.multiDragKey) {
3243
+ this.multiDragKeyDown = true;
3244
+ }
3245
+ },
3246
+ _checkKeyUp: function _checkKeyUp(evt) {
3247
+ if (evt.key === this.options.multiDragKey) {
3248
+ this.multiDragKeyDown = false;
3249
+ }
3250
+ }
3251
+ };
3252
+ return _extends(MultiDrag, {
3253
+ // Static methods & properties
3254
+ pluginName: 'multiDrag',
3255
+ utils: {
3256
+ /**
3257
+ * Selects the provided multi-drag item
3258
+ * @param {HTMLElement} el The element to be selected
3259
+ */
3260
+ select: function select(el) {
3261
+ var sortable = el.parentNode[expando];
3262
+ if (!sortable || !sortable.options.multiDrag || ~multiDragElements.indexOf(el)) return;
3263
+ if (multiDragSortable && multiDragSortable !== sortable) {
3264
+ multiDragSortable.multiDrag._deselectMultiDrag();
3265
+ multiDragSortable = sortable;
3266
+ }
3267
+ toggleClass(el, sortable.options.selectedClass, true);
3268
+ multiDragElements.push(el);
3269
+ },
3270
+ /**
3271
+ * Deselects the provided multi-drag item
3272
+ * @param {HTMLElement} el The element to be deselected
3273
+ */
3274
+ deselect: function deselect(el) {
3275
+ var sortable = el.parentNode[expando],
3276
+ index = multiDragElements.indexOf(el);
3277
+ if (!sortable || !sortable.options.multiDrag || !~index) return;
3278
+ toggleClass(el, sortable.options.selectedClass, false);
3279
+ multiDragElements.splice(index, 1);
3280
+ }
3281
+ },
3282
+ eventProperties: function eventProperties() {
3283
+ var _this3 = this;
3284
+ var oldIndicies = [],
3285
+ newIndicies = [];
3286
+ multiDragElements.forEach(function (multiDragElement) {
3287
+ oldIndicies.push({
3288
+ multiDragElement: multiDragElement,
3289
+ index: multiDragElement.sortableIndex
3290
+ });
3291
+
3292
+ // multiDragElements will already be sorted if folding
3293
+ var newIndex;
3294
+ if (folding && multiDragElement !== dragEl$1) {
3295
+ newIndex = -1;
3296
+ } else if (folding) {
3297
+ newIndex = index(multiDragElement, ':not(.' + _this3.options.selectedClass + ')');
3298
+ } else {
3299
+ newIndex = index(multiDragElement);
3300
+ }
3301
+ newIndicies.push({
3302
+ multiDragElement: multiDragElement,
3303
+ index: newIndex
3304
+ });
3305
+ });
3306
+ return {
3307
+ items: _toConsumableArray(multiDragElements),
3308
+ clones: [].concat(multiDragClones),
3309
+ oldIndicies: oldIndicies,
3310
+ newIndicies: newIndicies
3311
+ };
3312
+ },
3313
+ optionListeners: {
3314
+ multiDragKey: function multiDragKey(key) {
3315
+ key = key.toLowerCase();
3316
+ if (key === 'ctrl') {
3317
+ key = 'Control';
3318
+ } else if (key.length > 1) {
3319
+ key = key.charAt(0).toUpperCase() + key.substr(1);
3320
+ }
3321
+ return key;
3322
+ }
3323
+ }
3324
+ });
3325
+ }
3326
+ function insertMultiDragElements(clonesInserted, rootEl) {
3327
+ multiDragElements.forEach(function (multiDragElement, i) {
3328
+ var target = rootEl.children[multiDragElement.sortableIndex + (clonesInserted ? Number(i) : 0)];
3329
+ if (target) {
3330
+ rootEl.insertBefore(multiDragElement, target);
3331
+ } else {
3332
+ rootEl.appendChild(multiDragElement);
3333
+ }
3334
+ });
3335
+ }
3336
+
3337
+ /**
3338
+ * Insert multi-drag clones
3339
+ * @param {[Boolean]} elementsInserted Whether the multi-drag elements are inserted
3340
+ * @param {HTMLElement} rootEl
3341
+ */
3342
+ function insertMultiDragClones(elementsInserted, rootEl) {
3343
+ multiDragClones.forEach(function (clone, i) {
3344
+ var target = rootEl.children[clone.sortableIndex + (elementsInserted ? Number(i) : 0)];
3345
+ if (target) {
3346
+ rootEl.insertBefore(clone, target);
3347
+ } else {
3348
+ rootEl.appendChild(clone);
3349
+ }
3350
+ });
3351
+ }
3352
+ function removeMultiDragElements() {
3353
+ multiDragElements.forEach(function (multiDragElement) {
3354
+ if (multiDragElement === dragEl$1) return;
3355
+ multiDragElement.parentNode && multiDragElement.parentNode.removeChild(multiDragElement);
3356
+ });
3357
+ }
3358
+
3359
+ Sortable.mount(new AutoScrollPlugin());
3360
+ Sortable.mount(Remove, Revert);
3361
+
3362
+ export default Sortable;
3363
+ export { MultiDragPlugin as MultiDrag, Sortable, SwapPlugin as Swap };