diff --git a/public/js/buildings/wohnhaus.js b/public/js/buildings/wohnhaus.js index 84f0d55..dc81895 100644 --- a/public/js/buildings/wohnhaus.js +++ b/public/js/buildings/wohnhaus.js @@ -72,7 +72,9 @@ async function loadEquipment() { const label = slot.querySelector(".slot-label"); - slot.innerHTML = ``; + slot.innerHTML = ``; + + initSlotDrag(); if (label) { slot.appendChild(label); @@ -199,11 +201,9 @@ function initDrop() { } function initSlotDrag() { - document.querySelectorAll(".slot").forEach((slot) => { - slot.addEventListener("dragstart", (e) => { - const img = slot.querySelector("img"); - - if (!img) return; + document.querySelectorAll(".slot img").forEach((img) => { + img.addEventListener("dragstart", (e) => { + const slot = img.closest(".slot"); e.dataTransfer.setData("icon", img.src); e.dataTransfer.setData("fromSlot", slot.dataset.slot);