sortablejs-rails 1.15.0 → 1.15.6

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