sortablejs 1.15.0 → 1.15.2

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