|
1 | 1 | /**! |
2 | | - * Sortable 1.15.2 |
| 2 | + * Sortable 1.15.6 |
3 | 3 | * @author RubaXa <[email protected]> |
4 | 4 | * @author owenm <[email protected]> |
5 | 5 | * @license MIT |
|
134 | 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."); |
135 | 135 | } |
136 | 136 |
|
137 | | - var version = "1.15.2"; |
| 137 | + var version = "1.15.6"; |
138 | 138 |
|
139 | 139 | function userAgent(pattern) { |
140 | 140 | if (typeof window !== 'undefined' && window.navigator) { |
|
1127 | 1127 | x: 0, |
1128 | 1128 | y: 0 |
1129 | 1129 | }, |
1130 | | - 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), |
1131 | 1132 | emptyInsertThreshold: 5 |
1132 | 1133 | }; |
1133 | 1134 | PluginManager.initializePlugins(this, el, defaults); |
|
1238 | 1239 | pluginEvent('filter', _this, { |
1239 | 1240 | evt: evt |
1240 | 1241 | }); |
1241 | | - preventOnFilter && evt.cancelable && evt.preventDefault(); |
| 1242 | + preventOnFilter && evt.preventDefault(); |
1242 | 1243 | return; // cancel dnd |
1243 | 1244 | } |
1244 | 1245 | } else if (filter) { |
|
1260 | 1261 | } |
1261 | 1262 | }); |
1262 | 1263 | if (filter) { |
1263 | | - preventOnFilter && evt.cancelable && evt.preventDefault(); |
| 1264 | + preventOnFilter && evt.preventDefault(); |
1264 | 1265 | return; // cancel dnd |
1265 | 1266 | } |
1266 | 1267 | } |
|
1332 | 1333 | on(ownerDocument, 'dragover', nearestEmptyInsertDetectEvent); |
1333 | 1334 | on(ownerDocument, 'mousemove', nearestEmptyInsertDetectEvent); |
1334 | 1335 | on(ownerDocument, 'touchmove', nearestEmptyInsertDetectEvent); |
1335 | | - on(ownerDocument, 'mouseup', _this._onDrop); |
1336 | | - on(ownerDocument, 'touchend', _this._onDrop); |
1337 | | - on(ownerDocument, 'touchcancel', _this._onDrop); |
| 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 | + } |
1338 | 1345 |
|
1339 | 1346 | // Make dragEl draggable (must be before delay for FireFox) |
1340 | 1347 | if (FireFox && this.nativeDraggable) { |
|
1354 | 1361 | // If the user moves the pointer or let go the click or touch |
1355 | 1362 | // before the delay has been reached: |
1356 | 1363 | // disable the delayed drag |
1357 | | - on(ownerDocument, 'mouseup', _this._disableDelayedDrag); |
1358 | | - on(ownerDocument, 'touchend', _this._disableDelayedDrag); |
1359 | | - 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 | + } |
1360 | 1372 | on(ownerDocument, 'mousemove', _this._delayedDragTouchMoveHandler); |
1361 | 1373 | on(ownerDocument, 'touchmove', _this._delayedDragTouchMoveHandler); |
1362 | 1374 | options.supportPointer && on(ownerDocument, 'pointermove', _this._delayedDragTouchMoveHandler); |
|
1382 | 1394 | off(ownerDocument, 'mouseup', this._disableDelayedDrag); |
1383 | 1395 | off(ownerDocument, 'touchend', this._disableDelayedDrag); |
1384 | 1396 | off(ownerDocument, 'touchcancel', this._disableDelayedDrag); |
| 1397 | + off(ownerDocument, 'pointerup', this._disableDelayedDrag); |
| 1398 | + off(ownerDocument, 'pointercancel', this._disableDelayedDrag); |
1385 | 1399 | off(ownerDocument, 'mousemove', this._delayedDragTouchMoveHandler); |
1386 | 1400 | off(ownerDocument, 'touchmove', this._delayedDragTouchMoveHandler); |
1387 | 1401 | off(ownerDocument, 'pointermove', this._delayedDragTouchMoveHandler); |
|
1402 | 1416 | } |
1403 | 1417 | try { |
1404 | 1418 | if (document.selection) { |
1405 | | - // Timeout neccessary for IE9 |
1406 | 1419 | _nextTick(function () { |
1407 | 1420 | document.selection.empty(); |
1408 | 1421 | }); |
|
1467 | 1480 | } |
1468 | 1481 | target = parent; // store last element |
1469 | 1482 | } |
1470 | | - /* jshint boss:true */ while (parent = parent.parentNode); |
| 1483 | + /* jshint boss:true */ while (parent = getParentOrHost(parent)); |
1471 | 1484 | } |
1472 | 1485 | _unhideGhostForTarget(); |
1473 | 1486 | } |
|
1624 | 1637 | _this._dragStartId = _nextTick(_this._dragStarted.bind(_this, fallback, evt)); |
1625 | 1638 | on(document, 'selectstart', _this); |
1626 | 1639 | moved = true; |
| 1640 | + window.getSelection().removeAllRanges(); |
1627 | 1641 | if (Safari) { |
1628 | 1642 | css(document.body, 'user-select', 'none'); |
1629 | 1643 | } |
|
1895 | 1909 | off(ownerDocument, 'mouseup', this._onDrop); |
1896 | 1910 | off(ownerDocument, 'touchend', this._onDrop); |
1897 | 1911 | off(ownerDocument, 'pointerup', this._onDrop); |
| 1912 | + off(ownerDocument, 'pointercancel', this._onDrop); |
1898 | 1913 | off(ownerDocument, 'touchcancel', this._onDrop); |
1899 | 1914 | off(document, 'selectstart', this); |
1900 | 1915 | }, |
|
2373 | 2388 | nextTick: _nextTick, |
2374 | 2389 | cancelNextTick: _cancelNextTick, |
2375 | 2390 | detectDirection: _detectDirection, |
2376 | | - getChild: getChild |
| 2391 | + getChild: getChild, |
| 2392 | + expando: expando |
2377 | 2393 | }; |
2378 | 2394 |
|
2379 | 2395 | /** |
|
3084 | 3100 | var lastIndex = index(lastMultiDragSelect), |
3085 | 3101 | currentIndex = index(dragEl$1); |
3086 | 3102 | if (~lastIndex && ~currentIndex && lastIndex !== currentIndex) { |
3087 | | - // Must include lastMultiDragSelect (select it), in case modified selection from no selection |
3088 | | - // (but previous selection existed) |
3089 | | - var n, i; |
3090 | | - if (currentIndex > lastIndex) { |
3091 | | - i = lastIndex; |
3092 | | - n = currentIndex; |
3093 | | - } else { |
3094 | | - i = currentIndex; |
3095 | | - n = lastIndex + 1; |
3096 | | - } |
3097 | | - for (; i < n; i++) { |
3098 | | - if (~multiDragElements.indexOf(children[i])) continue; |
3099 | | - toggleClass(children[i], options.selectedClass, true); |
3100 | | - multiDragElements.push(children[i]); |
3101 | | - dispatchEvent({ |
3102 | | - sortable: sortable, |
3103 | | - rootEl: rootEl, |
3104 | | - name: 'select', |
3105 | | - targetEl: children[i], |
3106 | | - originalEvent: evt |
3107 | | - }); |
3108 | | - } |
| 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 | + })(); |
3109 | 3135 | } |
3110 | 3136 | } else { |
3111 | 3137 | lastMultiDragSelect = dragEl$1; |
|
0 commit comments