Skip to content

Commit

Permalink
1.15.4
Browse files Browse the repository at this point in the history
  • Loading branch information
owen-m1 committed Nov 23, 2024
1 parent 7fd5baf commit 62f0498
Show file tree
Hide file tree
Showing 7 changed files with 253 additions and 161 deletions.
101 changes: 62 additions & 39 deletions Sortable.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**!
* Sortable 1.15.3
* Sortable 1.15.4
* @author RubaXa <[email protected]>
* @author owenm <[email protected]>
* @license MIT
Expand Down Expand Up @@ -134,7 +134,7 @@
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}

var version = "1.15.3";
var version = "1.15.4";

function userAgent(pattern) {
if (typeof window !== 'undefined' && window.navigator) {
Expand Down Expand Up @@ -1238,7 +1238,7 @@
pluginEvent('filter', _this, {
evt: evt
});
preventOnFilter && evt.cancelable && evt.preventDefault();
preventOnFilter && evt.preventDefault();
return; // cancel dnd
}
} else if (filter) {
Expand All @@ -1260,7 +1260,7 @@
}
});
if (filter) {
preventOnFilter && evt.cancelable && evt.preventDefault();
preventOnFilter && evt.preventDefault();
return; // cancel dnd
}
}
Expand Down Expand Up @@ -1332,9 +1332,15 @@
on(ownerDocument, 'dragover', nearestEmptyInsertDetectEvent);
on(ownerDocument, 'mousemove', nearestEmptyInsertDetectEvent);
on(ownerDocument, 'touchmove', nearestEmptyInsertDetectEvent);
on(ownerDocument, 'mouseup', _this._onDrop);
on(ownerDocument, 'touchend', _this._onDrop);
on(ownerDocument, 'touchcancel', _this._onDrop);
if (options.supportPointer) {
on(ownerDocument, 'pointerup', _this._onDrop);
// Native D&D triggers pointercancel
!this.nativeDraggable && on(ownerDocument, 'pointercancel', _this._onDrop);
} else {
on(ownerDocument, 'mouseup', _this._onDrop);
on(ownerDocument, 'touchend', _this._onDrop);
on(ownerDocument, 'touchcancel', _this._onDrop);
}

// Make dragEl draggable (must be before delay for FireFox)
if (FireFox && this.nativeDraggable) {
Expand All @@ -1354,9 +1360,14 @@
// If the user moves the pointer or let go the click or touch
// before the delay has been reached:
// disable the delayed drag
on(ownerDocument, 'mouseup', _this._disableDelayedDrag);
on(ownerDocument, 'touchend', _this._disableDelayedDrag);
on(ownerDocument, 'touchcancel', _this._disableDelayedDrag);
if (options.supportPointer) {
on(ownerDocument, 'pointerup', _this._disableDelayedDrag);
on(ownerDocument, 'pointercancel', _this._disableDelayedDrag);
} else {
on(ownerDocument, 'mouseup', _this._disableDelayedDrag);
on(ownerDocument, 'touchend', _this._disableDelayedDrag);
on(ownerDocument, 'touchcancel', _this._disableDelayedDrag);
}
on(ownerDocument, 'mousemove', _this._delayedDragTouchMoveHandler);
on(ownerDocument, 'touchmove', _this._delayedDragTouchMoveHandler);
options.supportPointer && on(ownerDocument, 'pointermove', _this._delayedDragTouchMoveHandler);
Expand All @@ -1382,6 +1393,8 @@
off(ownerDocument, 'mouseup', this._disableDelayedDrag);
off(ownerDocument, 'touchend', this._disableDelayedDrag);
off(ownerDocument, 'touchcancel', this._disableDelayedDrag);
off(ownerDocument, 'pointerup', this._disableDelayedDrag);
off(ownerDocument, 'pointercancel', this._disableDelayedDrag);
off(ownerDocument, 'mousemove', this._delayedDragTouchMoveHandler);
off(ownerDocument, 'touchmove', this._delayedDragTouchMoveHandler);
off(ownerDocument, 'pointermove', this._delayedDragTouchMoveHandler);
Expand All @@ -1401,14 +1414,13 @@
on(rootEl, 'dragstart', this._onDragStart);
}
try {
if (document.selection) {
// Timeout neccessary for IE9
_nextTick(function () {
_nextTick(function () {
if (document.selection) {
document.selection.empty();
});
} else {
window.getSelection().removeAllRanges();
}
} else {
window.getSelection().removeAllRanges();
}
});
} catch (err) {}
},
_dragStarted: function _dragStarted(fallback, evt) {
Expand Down Expand Up @@ -1895,6 +1907,7 @@
off(ownerDocument, 'mouseup', this._onDrop);
off(ownerDocument, 'touchend', this._onDrop);
off(ownerDocument, 'pointerup', this._onDrop);
off(ownerDocument, 'pointercancel', this._onDrop);
off(ownerDocument, 'touchcancel', this._onDrop);
off(document, 'selectstart', this);
},
Expand Down Expand Up @@ -3085,28 +3098,38 @@
var lastIndex = index(lastMultiDragSelect),
currentIndex = index(dragEl$1);
if (~lastIndex && ~currentIndex && lastIndex !== currentIndex) {
// Must include lastMultiDragSelect (select it), in case modified selection from no selection
// (but previous selection existed)
var n, i;
if (currentIndex > lastIndex) {
i = lastIndex;
n = currentIndex;
} else {
i = currentIndex;
n = lastIndex + 1;
}
for (; i < n; i++) {
if (~multiDragElements.indexOf(children[i])) continue;
toggleClass(children[i], options.selectedClass, true);
multiDragElements.push(children[i]);
dispatchEvent({
sortable: sortable,
rootEl: rootEl,
name: 'select',
targetEl: children[i],
originalEvent: evt
});
}
(function () {
// Must include lastMultiDragSelect (select it), in case modified selection from no selection
// (but previous selection existed)
var n, i;
if (currentIndex > lastIndex) {
i = lastIndex;
n = currentIndex;
} else {
i = currentIndex;
n = lastIndex + 1;
}
var filter = options.filter;
for (; i < n; i++) {
if (~multiDragElements.indexOf(children[i])) continue;
// Check if element is draggable
if (!closest(children[i], options.draggable, parentEl, false)) continue;
// Check if element is filtered
var filtered = filter && (typeof filter === 'function' ? filter.call(sortable, evt, children[i], sortable) : filter.split(',').some(function (criteria) {
return closest(children[i], criteria.trim(), parentEl, false);
}));
if (filtered) continue;
toggleClass(children[i], options.selectedClass, true);
multiDragElements.push(children[i]);
dispatchEvent({
sortable: sortable,
rootEl: rootEl,
name: 'select',
targetEl: children[i],
originalEvent: evt
});
}
})();
}
} else {
lastMultiDragSelect = dragEl$1;
Expand Down
4 changes: 2 additions & 2 deletions Sortable.min.js

Large diffs are not rendered by default.

101 changes: 62 additions & 39 deletions modular/sortable.complete.esm.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**!
* Sortable 1.15.3
* Sortable 1.15.4
* @author RubaXa <[email protected]>
* @author owenm <[email protected]>
* @license MIT
Expand Down Expand Up @@ -128,7 +128,7 @@ function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}

var version = "1.15.3";
var version = "1.15.4";

function userAgent(pattern) {
if (typeof window !== 'undefined' && window.navigator) {
Expand Down Expand Up @@ -1232,7 +1232,7 @@ Sortable.prototype = /** @lends Sortable.prototype */{
pluginEvent('filter', _this, {
evt: evt
});
preventOnFilter && evt.cancelable && evt.preventDefault();
preventOnFilter && evt.preventDefault();
return; // cancel dnd
}
} else if (filter) {
Expand All @@ -1254,7 +1254,7 @@ Sortable.prototype = /** @lends Sortable.prototype */{
}
});
if (filter) {
preventOnFilter && evt.cancelable && evt.preventDefault();
preventOnFilter && evt.preventDefault();
return; // cancel dnd
}
}
Expand Down Expand Up @@ -1326,9 +1326,15 @@ Sortable.prototype = /** @lends Sortable.prototype */{
on(ownerDocument, 'dragover', nearestEmptyInsertDetectEvent);
on(ownerDocument, 'mousemove', nearestEmptyInsertDetectEvent);
on(ownerDocument, 'touchmove', nearestEmptyInsertDetectEvent);
on(ownerDocument, 'mouseup', _this._onDrop);
on(ownerDocument, 'touchend', _this._onDrop);
on(ownerDocument, 'touchcancel', _this._onDrop);
if (options.supportPointer) {
on(ownerDocument, 'pointerup', _this._onDrop);
// Native D&D triggers pointercancel
!this.nativeDraggable && on(ownerDocument, 'pointercancel', _this._onDrop);
} else {
on(ownerDocument, 'mouseup', _this._onDrop);
on(ownerDocument, 'touchend', _this._onDrop);
on(ownerDocument, 'touchcancel', _this._onDrop);
}

// Make dragEl draggable (must be before delay for FireFox)
if (FireFox && this.nativeDraggable) {
Expand All @@ -1348,9 +1354,14 @@ Sortable.prototype = /** @lends Sortable.prototype */{
// If the user moves the pointer or let go the click or touch
// before the delay has been reached:
// disable the delayed drag
on(ownerDocument, 'mouseup', _this._disableDelayedDrag);
on(ownerDocument, 'touchend', _this._disableDelayedDrag);
on(ownerDocument, 'touchcancel', _this._disableDelayedDrag);
if (options.supportPointer) {
on(ownerDocument, 'pointerup', _this._disableDelayedDrag);
on(ownerDocument, 'pointercancel', _this._disableDelayedDrag);
} else {
on(ownerDocument, 'mouseup', _this._disableDelayedDrag);
on(ownerDocument, 'touchend', _this._disableDelayedDrag);
on(ownerDocument, 'touchcancel', _this._disableDelayedDrag);
}
on(ownerDocument, 'mousemove', _this._delayedDragTouchMoveHandler);
on(ownerDocument, 'touchmove', _this._delayedDragTouchMoveHandler);
options.supportPointer && on(ownerDocument, 'pointermove', _this._delayedDragTouchMoveHandler);
Expand All @@ -1376,6 +1387,8 @@ Sortable.prototype = /** @lends Sortable.prototype */{
off(ownerDocument, 'mouseup', this._disableDelayedDrag);
off(ownerDocument, 'touchend', this._disableDelayedDrag);
off(ownerDocument, 'touchcancel', this._disableDelayedDrag);
off(ownerDocument, 'pointerup', this._disableDelayedDrag);
off(ownerDocument, 'pointercancel', this._disableDelayedDrag);
off(ownerDocument, 'mousemove', this._delayedDragTouchMoveHandler);
off(ownerDocument, 'touchmove', this._delayedDragTouchMoveHandler);
off(ownerDocument, 'pointermove', this._delayedDragTouchMoveHandler);
Expand All @@ -1395,14 +1408,13 @@ Sortable.prototype = /** @lends Sortable.prototype */{
on(rootEl, 'dragstart', this._onDragStart);
}
try {
if (document.selection) {
// Timeout neccessary for IE9
_nextTick(function () {
_nextTick(function () {
if (document.selection) {
document.selection.empty();
});
} else {
window.getSelection().removeAllRanges();
}
} else {
window.getSelection().removeAllRanges();
}
});
} catch (err) {}
},
_dragStarted: function _dragStarted(fallback, evt) {
Expand Down Expand Up @@ -1889,6 +1901,7 @@ Sortable.prototype = /** @lends Sortable.prototype */{
off(ownerDocument, 'mouseup', this._onDrop);
off(ownerDocument, 'touchend', this._onDrop);
off(ownerDocument, 'pointerup', this._onDrop);
off(ownerDocument, 'pointercancel', this._onDrop);
off(ownerDocument, 'touchcancel', this._onDrop);
off(document, 'selectstart', this);
},
Expand Down Expand Up @@ -3079,28 +3092,38 @@ function MultiDragPlugin() {
var lastIndex = index(lastMultiDragSelect),
currentIndex = index(dragEl$1);
if (~lastIndex && ~currentIndex && lastIndex !== currentIndex) {
// Must include lastMultiDragSelect (select it), in case modified selection from no selection
// (but previous selection existed)
var n, i;
if (currentIndex > lastIndex) {
i = lastIndex;
n = currentIndex;
} else {
i = currentIndex;
n = lastIndex + 1;
}
for (; i < n; i++) {
if (~multiDragElements.indexOf(children[i])) continue;
toggleClass(children[i], options.selectedClass, true);
multiDragElements.push(children[i]);
dispatchEvent({
sortable: sortable,
rootEl: rootEl,
name: 'select',
targetEl: children[i],
originalEvent: evt
});
}
(function () {
// Must include lastMultiDragSelect (select it), in case modified selection from no selection
// (but previous selection existed)
var n, i;
if (currentIndex > lastIndex) {
i = lastIndex;
n = currentIndex;
} else {
i = currentIndex;
n = lastIndex + 1;
}
var filter = options.filter;
for (; i < n; i++) {
if (~multiDragElements.indexOf(children[i])) continue;
// Check if element is draggable
if (!closest(children[i], options.draggable, parentEl, false)) continue;
// Check if element is filtered
var filtered = filter && (typeof filter === 'function' ? filter.call(sortable, evt, children[i], sortable) : filter.split(',').some(function (criteria) {
return closest(children[i], criteria.trim(), parentEl, false);
}));
if (filtered) continue;
toggleClass(children[i], options.selectedClass, true);
multiDragElements.push(children[i]);
dispatchEvent({
sortable: sortable,
rootEl: rootEl,
name: 'select',
targetEl: children[i],
originalEvent: evt
});
}
})();
}
} else {
lastMultiDragSelect = dragEl$1;
Expand Down
Loading

0 comments on commit 62f0498

Please sign in to comment.