Skip to content

Commit 62f0498

Browse files
committed
1.15.4
1 parent 7fd5baf commit 62f0498

7 files changed

+253
-161
lines changed

Sortable.js

+62-39
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**!
2-
* Sortable 1.15.3
2+
* Sortable 1.15.4
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.3";
137+
var version = "1.15.4";
138138

139139
function userAgent(pattern) {
140140
if (typeof window !== 'undefined' && window.navigator) {
@@ -1238,7 +1238,7 @@
12381238
pluginEvent('filter', _this, {
12391239
evt: evt
12401240
});
1241-
preventOnFilter && evt.cancelable && evt.preventDefault();
1241+
preventOnFilter && evt.preventDefault();
12421242
return; // cancel dnd
12431243
}
12441244
} else if (filter) {
@@ -1260,7 +1260,7 @@
12601260
}
12611261
});
12621262
if (filter) {
1263-
preventOnFilter && evt.cancelable && evt.preventDefault();
1263+
preventOnFilter && evt.preventDefault();
12641264
return; // cancel dnd
12651265
}
12661266
}
@@ -1332,9 +1332,15 @@
13321332
on(ownerDocument, 'dragover', nearestEmptyInsertDetectEvent);
13331333
on(ownerDocument, 'mousemove', nearestEmptyInsertDetectEvent);
13341334
on(ownerDocument, 'touchmove', nearestEmptyInsertDetectEvent);
1335-
on(ownerDocument, 'mouseup', _this._onDrop);
1336-
on(ownerDocument, 'touchend', _this._onDrop);
1337-
on(ownerDocument, 'touchcancel', _this._onDrop);
1335+
if (options.supportPointer) {
1336+
on(ownerDocument, 'pointerup', _this._onDrop);
1337+
// Native D&D triggers pointercancel
1338+
!this.nativeDraggable && on(ownerDocument, 'pointercancel', _this._onDrop);
1339+
} else {
1340+
on(ownerDocument, 'mouseup', _this._onDrop);
1341+
on(ownerDocument, 'touchend', _this._onDrop);
1342+
on(ownerDocument, 'touchcancel', _this._onDrop);
1343+
}
13381344

13391345
// Make dragEl draggable (must be before delay for FireFox)
13401346
if (FireFox && this.nativeDraggable) {
@@ -1354,9 +1360,14 @@
13541360
// If the user moves the pointer or let go the click or touch
13551361
// before the delay has been reached:
13561362
// disable the delayed drag
1357-
on(ownerDocument, 'mouseup', _this._disableDelayedDrag);
1358-
on(ownerDocument, 'touchend', _this._disableDelayedDrag);
1359-
on(ownerDocument, 'touchcancel', _this._disableDelayedDrag);
1363+
if (options.supportPointer) {
1364+
on(ownerDocument, 'pointerup', _this._disableDelayedDrag);
1365+
on(ownerDocument, 'pointercancel', _this._disableDelayedDrag);
1366+
} else {
1367+
on(ownerDocument, 'mouseup', _this._disableDelayedDrag);
1368+
on(ownerDocument, 'touchend', _this._disableDelayedDrag);
1369+
on(ownerDocument, 'touchcancel', _this._disableDelayedDrag);
1370+
}
13601371
on(ownerDocument, 'mousemove', _this._delayedDragTouchMoveHandler);
13611372
on(ownerDocument, 'touchmove', _this._delayedDragTouchMoveHandler);
13621373
options.supportPointer && on(ownerDocument, 'pointermove', _this._delayedDragTouchMoveHandler);
@@ -1382,6 +1393,8 @@
13821393
off(ownerDocument, 'mouseup', this._disableDelayedDrag);
13831394
off(ownerDocument, 'touchend', this._disableDelayedDrag);
13841395
off(ownerDocument, 'touchcancel', this._disableDelayedDrag);
1396+
off(ownerDocument, 'pointerup', this._disableDelayedDrag);
1397+
off(ownerDocument, 'pointercancel', this._disableDelayedDrag);
13851398
off(ownerDocument, 'mousemove', this._delayedDragTouchMoveHandler);
13861399
off(ownerDocument, 'touchmove', this._delayedDragTouchMoveHandler);
13871400
off(ownerDocument, 'pointermove', this._delayedDragTouchMoveHandler);
@@ -1401,14 +1414,13 @@
14011414
on(rootEl, 'dragstart', this._onDragStart);
14021415
}
14031416
try {
1404-
if (document.selection) {
1405-
// Timeout neccessary for IE9
1406-
_nextTick(function () {
1417+
_nextTick(function () {
1418+
if (document.selection) {
14071419
document.selection.empty();
1408-
});
1409-
} else {
1410-
window.getSelection().removeAllRanges();
1411-
}
1420+
} else {
1421+
window.getSelection().removeAllRanges();
1422+
}
1423+
});
14121424
} catch (err) {}
14131425
},
14141426
_dragStarted: function _dragStarted(fallback, evt) {
@@ -1895,6 +1907,7 @@
18951907
off(ownerDocument, 'mouseup', this._onDrop);
18961908
off(ownerDocument, 'touchend', this._onDrop);
18971909
off(ownerDocument, 'pointerup', this._onDrop);
1910+
off(ownerDocument, 'pointercancel', this._onDrop);
18981911
off(ownerDocument, 'touchcancel', this._onDrop);
18991912
off(document, 'selectstart', this);
19001913
},
@@ -3085,28 +3098,38 @@
30853098
var lastIndex = index(lastMultiDragSelect),
30863099
currentIndex = index(dragEl$1);
30873100
if (~lastIndex && ~currentIndex && lastIndex !== currentIndex) {
3088-
// Must include lastMultiDragSelect (select it), in case modified selection from no selection
3089-
// (but previous selection existed)
3090-
var n, i;
3091-
if (currentIndex > lastIndex) {
3092-
i = lastIndex;
3093-
n = currentIndex;
3094-
} else {
3095-
i = currentIndex;
3096-
n = lastIndex + 1;
3097-
}
3098-
for (; i < n; i++) {
3099-
if (~multiDragElements.indexOf(children[i])) continue;
3100-
toggleClass(children[i], options.selectedClass, true);
3101-
multiDragElements.push(children[i]);
3102-
dispatchEvent({
3103-
sortable: sortable,
3104-
rootEl: rootEl,
3105-
name: 'select',
3106-
targetEl: children[i],
3107-
originalEvent: evt
3108-
});
3109-
}
3101+
(function () {
3102+
// Must include lastMultiDragSelect (select it), in case modified selection from no selection
3103+
// (but previous selection existed)
3104+
var n, i;
3105+
if (currentIndex > lastIndex) {
3106+
i = lastIndex;
3107+
n = currentIndex;
3108+
} else {
3109+
i = currentIndex;
3110+
n = lastIndex + 1;
3111+
}
3112+
var filter = options.filter;
3113+
for (; i < n; i++) {
3114+
if (~multiDragElements.indexOf(children[i])) continue;
3115+
// Check if element is draggable
3116+
if (!closest(children[i], options.draggable, parentEl, false)) continue;
3117+
// Check if element is filtered
3118+
var filtered = filter && (typeof filter === 'function' ? filter.call(sortable, evt, children[i], sortable) : filter.split(',').some(function (criteria) {
3119+
return closest(children[i], criteria.trim(), parentEl, false);
3120+
}));
3121+
if (filtered) continue;
3122+
toggleClass(children[i], options.selectedClass, true);
3123+
multiDragElements.push(children[i]);
3124+
dispatchEvent({
3125+
sortable: sortable,
3126+
rootEl: rootEl,
3127+
name: 'select',
3128+
targetEl: children[i],
3129+
originalEvent: evt
3130+
});
3131+
}
3132+
})();
31103133
}
31113134
} else {
31123135
lastMultiDragSelect = dragEl$1;

Sortable.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modular/sortable.complete.esm.js

+62-39
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**!
2-
* Sortable 1.15.3
2+
* Sortable 1.15.4
33
* @author RubaXa <[email protected]>
44
* @author owenm <[email protected]>
55
* @license MIT
@@ -128,7 +128,7 @@ function _nonIterableSpread() {
128128
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
129129
}
130130

131-
var version = "1.15.3";
131+
var version = "1.15.4";
132132

133133
function userAgent(pattern) {
134134
if (typeof window !== 'undefined' && window.navigator) {
@@ -1232,7 +1232,7 @@ Sortable.prototype = /** @lends Sortable.prototype */{
12321232
pluginEvent('filter', _this, {
12331233
evt: evt
12341234
});
1235-
preventOnFilter && evt.cancelable && evt.preventDefault();
1235+
preventOnFilter && evt.preventDefault();
12361236
return; // cancel dnd
12371237
}
12381238
} else if (filter) {
@@ -1254,7 +1254,7 @@ Sortable.prototype = /** @lends Sortable.prototype */{
12541254
}
12551255
});
12561256
if (filter) {
1257-
preventOnFilter && evt.cancelable && evt.preventDefault();
1257+
preventOnFilter && evt.preventDefault();
12581258
return; // cancel dnd
12591259
}
12601260
}
@@ -1326,9 +1326,15 @@ Sortable.prototype = /** @lends Sortable.prototype */{
13261326
on(ownerDocument, 'dragover', nearestEmptyInsertDetectEvent);
13271327
on(ownerDocument, 'mousemove', nearestEmptyInsertDetectEvent);
13281328
on(ownerDocument, 'touchmove', nearestEmptyInsertDetectEvent);
1329-
on(ownerDocument, 'mouseup', _this._onDrop);
1330-
on(ownerDocument, 'touchend', _this._onDrop);
1331-
on(ownerDocument, 'touchcancel', _this._onDrop);
1329+
if (options.supportPointer) {
1330+
on(ownerDocument, 'pointerup', _this._onDrop);
1331+
// Native D&D triggers pointercancel
1332+
!this.nativeDraggable && on(ownerDocument, 'pointercancel', _this._onDrop);
1333+
} else {
1334+
on(ownerDocument, 'mouseup', _this._onDrop);
1335+
on(ownerDocument, 'touchend', _this._onDrop);
1336+
on(ownerDocument, 'touchcancel', _this._onDrop);
1337+
}
13321338

13331339
// Make dragEl draggable (must be before delay for FireFox)
13341340
if (FireFox && this.nativeDraggable) {
@@ -1348,9 +1354,14 @@ Sortable.prototype = /** @lends Sortable.prototype */{
13481354
// If the user moves the pointer or let go the click or touch
13491355
// before the delay has been reached:
13501356
// disable the delayed drag
1351-
on(ownerDocument, 'mouseup', _this._disableDelayedDrag);
1352-
on(ownerDocument, 'touchend', _this._disableDelayedDrag);
1353-
on(ownerDocument, 'touchcancel', _this._disableDelayedDrag);
1357+
if (options.supportPointer) {
1358+
on(ownerDocument, 'pointerup', _this._disableDelayedDrag);
1359+
on(ownerDocument, 'pointercancel', _this._disableDelayedDrag);
1360+
} else {
1361+
on(ownerDocument, 'mouseup', _this._disableDelayedDrag);
1362+
on(ownerDocument, 'touchend', _this._disableDelayedDrag);
1363+
on(ownerDocument, 'touchcancel', _this._disableDelayedDrag);
1364+
}
13541365
on(ownerDocument, 'mousemove', _this._delayedDragTouchMoveHandler);
13551366
on(ownerDocument, 'touchmove', _this._delayedDragTouchMoveHandler);
13561367
options.supportPointer && on(ownerDocument, 'pointermove', _this._delayedDragTouchMoveHandler);
@@ -1376,6 +1387,8 @@ Sortable.prototype = /** @lends Sortable.prototype */{
13761387
off(ownerDocument, 'mouseup', this._disableDelayedDrag);
13771388
off(ownerDocument, 'touchend', this._disableDelayedDrag);
13781389
off(ownerDocument, 'touchcancel', this._disableDelayedDrag);
1390+
off(ownerDocument, 'pointerup', this._disableDelayedDrag);
1391+
off(ownerDocument, 'pointercancel', this._disableDelayedDrag);
13791392
off(ownerDocument, 'mousemove', this._delayedDragTouchMoveHandler);
13801393
off(ownerDocument, 'touchmove', this._delayedDragTouchMoveHandler);
13811394
off(ownerDocument, 'pointermove', this._delayedDragTouchMoveHandler);
@@ -1395,14 +1408,13 @@ Sortable.prototype = /** @lends Sortable.prototype */{
13951408
on(rootEl, 'dragstart', this._onDragStart);
13961409
}
13971410
try {
1398-
if (document.selection) {
1399-
// Timeout neccessary for IE9
1400-
_nextTick(function () {
1411+
_nextTick(function () {
1412+
if (document.selection) {
14011413
document.selection.empty();
1402-
});
1403-
} else {
1404-
window.getSelection().removeAllRanges();
1405-
}
1414+
} else {
1415+
window.getSelection().removeAllRanges();
1416+
}
1417+
});
14061418
} catch (err) {}
14071419
},
14081420
_dragStarted: function _dragStarted(fallback, evt) {
@@ -1889,6 +1901,7 @@ Sortable.prototype = /** @lends Sortable.prototype */{
18891901
off(ownerDocument, 'mouseup', this._onDrop);
18901902
off(ownerDocument, 'touchend', this._onDrop);
18911903
off(ownerDocument, 'pointerup', this._onDrop);
1904+
off(ownerDocument, 'pointercancel', this._onDrop);
18921905
off(ownerDocument, 'touchcancel', this._onDrop);
18931906
off(document, 'selectstart', this);
18941907
},
@@ -3079,28 +3092,38 @@ function MultiDragPlugin() {
30793092
var lastIndex = index(lastMultiDragSelect),
30803093
currentIndex = index(dragEl$1);
30813094
if (~lastIndex && ~currentIndex && lastIndex !== currentIndex) {
3082-
// Must include lastMultiDragSelect (select it), in case modified selection from no selection
3083-
// (but previous selection existed)
3084-
var n, i;
3085-
if (currentIndex > lastIndex) {
3086-
i = lastIndex;
3087-
n = currentIndex;
3088-
} else {
3089-
i = currentIndex;
3090-
n = lastIndex + 1;
3091-
}
3092-
for (; i < n; i++) {
3093-
if (~multiDragElements.indexOf(children[i])) continue;
3094-
toggleClass(children[i], options.selectedClass, true);
3095-
multiDragElements.push(children[i]);
3096-
dispatchEvent({
3097-
sortable: sortable,
3098-
rootEl: rootEl,
3099-
name: 'select',
3100-
targetEl: children[i],
3101-
originalEvent: evt
3102-
});
3103-
}
3095+
(function () {
3096+
// Must include lastMultiDragSelect (select it), in case modified selection from no selection
3097+
// (but previous selection existed)
3098+
var n, i;
3099+
if (currentIndex > lastIndex) {
3100+
i = lastIndex;
3101+
n = currentIndex;
3102+
} else {
3103+
i = currentIndex;
3104+
n = lastIndex + 1;
3105+
}
3106+
var filter = options.filter;
3107+
for (; i < n; i++) {
3108+
if (~multiDragElements.indexOf(children[i])) continue;
3109+
// Check if element is draggable
3110+
if (!closest(children[i], options.draggable, parentEl, false)) continue;
3111+
// Check if element is filtered
3112+
var filtered = filter && (typeof filter === 'function' ? filter.call(sortable, evt, children[i], sortable) : filter.split(',').some(function (criteria) {
3113+
return closest(children[i], criteria.trim(), parentEl, false);
3114+
}));
3115+
if (filtered) continue;
3116+
toggleClass(children[i], options.selectedClass, true);
3117+
multiDragElements.push(children[i]);
3118+
dispatchEvent({
3119+
sortable: sortable,
3120+
rootEl: rootEl,
3121+
name: 'select',
3122+
targetEl: children[i],
3123+
originalEvent: evt
3124+
});
3125+
}
3126+
})();
31043127
}
31053128
} else {
31063129
lastMultiDragSelect = dragEl$1;

0 commit comments

Comments
 (0)