Refactor code structure and remove redundant sections for improved readability and maintainability
This commit is contained in:
@@ -2533,7 +2533,8 @@ if (!Element.prototype.closest) {
|
||||
this._dragging = false;
|
||||
this._dragHandleClass = this._options.dragHandleClass || '';
|
||||
this._parentident = this._options.parentident || '';
|
||||
this._swapdone = typeof this._options.swapdone === "function" ? this._options._swapdone : null;
|
||||
this._swapdone = typeof this._options.swapdone === "function" ? this._options.swapdone : null;
|
||||
this._onend = typeof this._options.onend === "function" ? this._options.onend : null;
|
||||
|
||||
this._container.setAttribute("data-is-sortable", 1);
|
||||
this._container.classList.add("sortable");
|
||||
@@ -2683,10 +2684,17 @@ if (!Element.prototype.closest) {
|
||||
}
|
||||
},
|
||||
|
||||
// on item release/drop
|
||||
// on item release/drop
|
||||
_onRelease: function (e) {
|
||||
// Was THIS list mid-drag? (mouseup fires on every instance's window listener.)
|
||||
var wasDragging = this._dragging === true && this._clickItem !== null;
|
||||
this._dragging = false;
|
||||
this._trashDragItem();
|
||||
// Fire a single "drag finished" callback so callers can commit the new order once,
|
||||
// reliably, on drop — rather than relying on the per-hover _swapdone during the drag.
|
||||
if (wasDragging && typeof this._onend === 'function') {
|
||||
this._onend();
|
||||
}
|
||||
},
|
||||
|
||||
// on item drag/move
|
||||
|
||||
Reference in New Issue
Block a user