From a895bd85603e48b9ebaf0a588efe58f94ad67c08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Sat, 4 Mar 2023 08:18:52 +0800 Subject: [PATCH] Replaced the traditional function expressions with ES6 arrow function expressions in the JavaScript for the drop-and-drop reorder. --- src/accounting/static/js/drag-and-drop-reorder.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/accounting/static/js/drag-and-drop-reorder.js b/src/accounting/static/js/drag-and-drop-reorder.js index 0ff2733..e7191d6 100644 --- a/src/accounting/static/js/drag-and-drop-reorder.js +++ b/src/accounting/static/js/drag-and-drop-reorder.js @@ -44,15 +44,15 @@ function initializeMouseDragAndDropReordering(list, onReorder) { let dragged = null; for (const item of items) { item.draggable = true; - item.addEventListener("dragstart", function () { + item.addEventListener("dragstart", () => { dragged = item; dragged.classList.add("accounting-dragged"); }); - item.addEventListener("dragover", function () { + item.addEventListener("dragover", () => { onDragOver(dragged, item); onReorder(); }); - item.addEventListener("dragend", function () { + item.addEventListener("dragend", () => { dragged.classList.remove("accounting-dragged"); dragged = null; }); @@ -69,16 +69,16 @@ function initializeMouseDragAndDropReordering(list, onReorder) { function initializeTouchDragAndDropReordering(list, onReorder) { const items = Array.from(list.children); for (const item of items) { - item.addEventListener("touchstart", function () { + item.addEventListener("touchstart", () => { item.classList.add("accounting-dragged"); }); - item.addEventListener("touchmove", function (event) { + item.addEventListener("touchmove", (event) => { const touch = event.targetTouches[0]; const target = document.elementFromPoint(touch.pageX, touch.pageY); onDragOver(item, target); onReorder(); }); - item.addEventListener("touchend", function () { + item.addEventListener("touchend", () => { item.classList.remove("accounting-dragged"); }); }