Skip to content

Commit 890c8b2

Browse files
committed
1.15.6
1 parent 73780bb commit 890c8b2

File tree

2 files changed

+64
-38
lines changed

2 files changed

+64
-38
lines changed

Sortable.js

Lines changed: 62 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**!
2-
* Sortable 1.15.2
2+
* Sortable 1.15.6
33
* @author RubaXa <[email protected]>
44
* @author owenm <[email protected]>
55
* @license MIT
@@ -134,7 +134,7 @@
134134
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
135135
}
136136

137-
var version = "1.15.2";
137+
var version = "1.15.6";
138138

139139
function userAgent(pattern) {
140140
if (typeof window !== 'undefined' && window.navigator) {
@@ -1127,7 +1127,8 @@
11271127
x: 0,
11281128
y: 0
11291129
},
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),
11311132
emptyInsertThreshold: 5
11321133
};
11331134
PluginManager.initializePlugins(this, el, defaults);
@@ -1238,7 +1239,7 @@
12381239
pluginEvent('filter', _this, {
12391240
evt: evt
12401241
});
1241-
preventOnFilter && evt.cancelable && evt.preventDefault();
1242+
preventOnFilter && evt.preventDefault();
12421243
return; // cancel dnd
12431244
}
12441245
} else if (filter) {
@@ -1260,7 +1261,7 @@
12601261
}
12611262
});
12621263
if (filter) {
1263-
preventOnFilter && evt.cancelable && evt.preventDefault();
1264+
preventOnFilter && evt.preventDefault();
12641265
return; // cancel dnd
12651266
}
12661267
}
@@ -1332,9 +1333,15 @@
13321333
on(ownerDocument, 'dragover', nearestEmptyInsertDetectEvent);
13331334
on(ownerDocument, 'mousemove', nearestEmptyInsertDetectEvent);
13341335
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+
}
13381345

13391346
// Make dragEl draggable (must be before delay for FireFox)
13401347
if (FireFox && this.nativeDraggable) {
@@ -1354,9 +1361,14 @@
13541361
// If the user moves the pointer or let go the click or touch
13551362
// before the delay has been reached:
13561363
// 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+
}
13601372
on(ownerDocument, 'mousemove', _this._delayedDragTouchMoveHandler);
13611373
on(ownerDocument, 'touchmove', _this._delayedDragTouchMoveHandler);
13621374
options.supportPointer && on(ownerDocument, 'pointermove', _this._delayedDragTouchMoveHandler);
@@ -1382,6 +1394,8 @@
13821394
off(ownerDocument, 'mouseup', this._disableDelayedDrag);
13831395
off(ownerDocument, 'touchend', this._disableDelayedDrag);
13841396
off(ownerDocument, 'touchcancel', this._disableDelayedDrag);
1397+
off(ownerDocument, 'pointerup', this._disableDelayedDrag);
1398+
off(ownerDocument, 'pointercancel', this._disableDelayedDrag);
13851399
off(ownerDocument, 'mousemove', this._delayedDragTouchMoveHandler);
13861400
off(ownerDocument, 'touchmove', this._delayedDragTouchMoveHandler);
13871401
off(ownerDocument, 'pointermove', this._delayedDragTouchMoveHandler);
@@ -1402,7 +1416,6 @@
14021416
}
14031417
try {
14041418
if (document.selection) {
1405-
// Timeout neccessary for IE9
14061419
_nextTick(function () {
14071420
document.selection.empty();
14081421
});
@@ -1467,7 +1480,7 @@
14671480
}
14681481
target = parent; // store last element
14691482
}
1470-
/* jshint boss:true */ while (parent = parent.parentNode);
1483+
/* jshint boss:true */ while (parent = getParentOrHost(parent));
14711484
}
14721485
_unhideGhostForTarget();
14731486
}
@@ -1624,6 +1637,7 @@
16241637
_this._dragStartId = _nextTick(_this._dragStarted.bind(_this, fallback, evt));
16251638
on(document, 'selectstart', _this);
16261639
moved = true;
1640+
window.getSelection().removeAllRanges();
16271641
if (Safari) {
16281642
css(document.body, 'user-select', 'none');
16291643
}
@@ -1895,6 +1909,7 @@
18951909
off(ownerDocument, 'mouseup', this._onDrop);
18961910
off(ownerDocument, 'touchend', this._onDrop);
18971911
off(ownerDocument, 'pointerup', this._onDrop);
1912+
off(ownerDocument, 'pointercancel', this._onDrop);
18981913
off(ownerDocument, 'touchcancel', this._onDrop);
18991914
off(document, 'selectstart', this);
19001915
},
@@ -2373,7 +2388,8 @@
23732388
nextTick: _nextTick,
23742389
cancelNextTick: _cancelNextTick,
23752390
detectDirection: _detectDirection,
2376-
getChild: getChild
2391+
getChild: getChild,
2392+
expando: expando
23772393
};
23782394

23792395
/**
@@ -3084,28 +3100,38 @@
30843100
var lastIndex = index(lastMultiDragSelect),
30853101
currentIndex = index(dragEl$1);
30863102
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+
})();
31093135
}
31103136
} else {
31113137
lastMultiDragSelect = dragEl$1;

0 commit comments

Comments
 (0)