Refactor code structure and remove redundant sections for improved readability and maintainability

This commit is contained in:
Stefan
2026-07-10 21:03:55 +02:00
parent 42997c4f49
commit 83d1c28b29
18 changed files with 696 additions and 86 deletions
+10 -2
View File
@@ -63,7 +63,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");
@@ -213,10 +214,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