sortablejs 1.14.0 → 1.15.1

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