Skip to content

Commit

Permalink
Set correct data
Browse files Browse the repository at this point in the history
  • Loading branch information
kopiro committed Jan 18, 2024
1 parent 3dd9ac4 commit 918ec35
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
16 changes: 2 additions & 14 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -540,18 +540,7 @@ $cfs.addEventListener("dragstart", (e) => {
e.target.classList.add("dragging");

const incomingCf = e.target.dataset.cf;
const incomingIdx = Number(e.target.dataset.position);
const incomingJp = getJP(incomingCf);

// Set data JSON
e.dataTransfer.setData(
"text/plain",
JSON.stringify({
incomingCf,
incomingIdx,
incomingJp,
})
);
e.dataTransfer.setData("text/plain", incomingCf);

$cfs.querySelectorAll(`[draggable]`).forEach(($scf) => {
if ($scf === e.target) return;
Expand Down Expand Up @@ -585,8 +574,7 @@ $cfs.addEventListener("drop", (e) => {
e.stopPropagation();
if (!e.target.classList.contains("droppable")) return;

const data = JSON.parse(e.dataTransfer.getData("text/plain"));
const { incomingCf, incomingIdx } = data;
const incomingCf = e.dataTransfer.getData("text/plain");

const newType = calculateNewTypeAfterSwap(
incomingCf,
Expand Down
10 changes: 5 additions & 5 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,16 @@ body {
translate: 0 0;
}
25% {
translate: -5px 0;
translate: -10px 0;
}
50% {
transform: 0 0;
translate: 0 0;
}
75% {
transform: 5px 0;
translate: 10px 0;
}
100% {
transform: 0 0;
translate: 0 0;
}
}

Expand All @@ -185,7 +185,7 @@ body {

.cf.droppable {
opacity: 0.6;
animation: shake 0.2s ease-in-out infinite;
animation: shake 1s ease-in-out infinite;
}

.cf.droppable > * {
Expand Down

0 comments on commit 918ec35

Please sign in to comment.