Skip to content

Commit 965e310

Browse files
committed
Swap cancel fix (SortableJS#1866)
1 parent 2addddd commit 965e310

File tree

7 files changed

+1737
-1822
lines changed

7 files changed

+1737
-1822
lines changed

Sortable.js

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3003,40 +3003,47 @@
30033003
var dragEl = _ref.dragEl;
30043004
lastSwapEl = dragEl;
30053005
},
3006-
dragOverValid: function dragOverValid(_ref2) {
3006+
dragOver: function dragOver(_ref2) {
30073007
var completed = _ref2.completed,
30083008
target = _ref2.target,
30093009
onMove = _ref2.onMove,
30103010
activeSortable = _ref2.activeSortable,
30113011
changed = _ref2.changed,
30123012
cancel = _ref2.cancel;
30133013
if (!activeSortable.options.swap) return;
3014+
3015+
if (target && lastSwapEl && target !== lastSwapEl) {
3016+
toggleClass(lastSwapEl, this.options.swapClass, false); // If dragOverValid doesn't set this, target isn't valid
3017+
3018+
lastSwapEl = null;
3019+
}
3020+
},
3021+
dragOverValid: function dragOverValid(_ref3) {
3022+
var completed = _ref3.completed,
3023+
target = _ref3.target,
3024+
onMove = _ref3.onMove,
3025+
activeSortable = _ref3.activeSortable,
3026+
changed = _ref3.changed,
3027+
cancel = _ref3.cancel;
3028+
if (!activeSortable.options.swap) return;
30143029
var el = this.sortable.el,
30153030
options = this.options;
30163031

30173032
if (target && target !== el) {
3018-
var prevSwapEl = lastSwapEl;
3019-
30203033
if (onMove(target) !== false) {
30213034
toggleClass(target, options.swapClass, true);
30223035
lastSwapEl = target;
3023-
} else {
3024-
lastSwapEl = null;
3025-
}
3026-
3027-
if (prevSwapEl && prevSwapEl !== lastSwapEl) {
3028-
toggleClass(prevSwapEl, options.swapClass, false);
30293036
}
30303037
}
30313038

30323039
changed();
30333040
completed(true);
30343041
cancel();
30353042
},
3036-
drop: function drop(_ref3) {
3037-
var activeSortable = _ref3.activeSortable,
3038-
putSortable = _ref3.putSortable,
3039-
dragEl = _ref3.dragEl;
3043+
drop: function drop(_ref4) {
3044+
var activeSortable = _ref4.activeSortable,
3045+
putSortable = _ref4.putSortable,
3046+
dragEl = _ref4.dragEl;
30403047
var toSortable = putSortable || this.sortable;
30413048
var options = this.options;
30423049
lastSwapEl && toggleClass(lastSwapEl, options.swapClass, false);

Sortable.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)