pop29
This commit is contained in:
parent
0745a27a15
commit
a9896062f9
@ -72,7 +72,9 @@ async function loadEquipment() {
|
|||||||
|
|
||||||
const label = slot.querySelector(".slot-label");
|
const label = slot.querySelector(".slot-label");
|
||||||
|
|
||||||
slot.innerHTML = `<img src="${item.icon}">`;
|
slot.innerHTML = `<img src="${item.icon}" draggable="true">`;
|
||||||
|
|
||||||
|
initSlotDrag();
|
||||||
|
|
||||||
if (label) {
|
if (label) {
|
||||||
slot.appendChild(label);
|
slot.appendChild(label);
|
||||||
@ -199,11 +201,9 @@ function initDrop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function initSlotDrag() {
|
function initSlotDrag() {
|
||||||
document.querySelectorAll(".slot").forEach((slot) => {
|
document.querySelectorAll(".slot img").forEach((img) => {
|
||||||
slot.addEventListener("dragstart", (e) => {
|
img.addEventListener("dragstart", (e) => {
|
||||||
const img = slot.querySelector("img");
|
const slot = img.closest(".slot");
|
||||||
|
|
||||||
if (!img) return;
|
|
||||||
|
|
||||||
e.dataTransfer.setData("icon", img.src);
|
e.dataTransfer.setData("icon", img.src);
|
||||||
e.dataTransfer.setData("fromSlot", slot.dataset.slot);
|
e.dataTransfer.setData("fromSlot", slot.dataset.slot);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user