Skip to content

Commit

Permalink
fix flipped drag and drop
Browse files Browse the repository at this point in the history
  • Loading branch information
fohristiwhirl committed Jun 27, 2019
1 parent a23b829 commit 029d02a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions 99_start.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,18 @@ for (let y = 0; y < 8; y++) {
tr1.appendChild(td1);
tr2.appendChild(td2);

// Closure shizzle, we need unchanging copies of the x and y variables.
// Note that the fact that we used let x and let y above in our loop
// doesn't seem to be good enough.

let x_copy = x;
let y_copy = y;

td2.addEventListener("dragstart", (event) => {
hub.set_active_square(Point(x, y));
event.dataTransfer.setData("text", "overlay_" + S(x, y));
let actualx = config.flip ? 7 - x_copy : x_copy;
let actualy = config.flip ? 7 - y_copy : y_copy;
hub.set_active_square(Point(actualx, actualy));
event.dataTransfer.setData("text", "overlay_" + S(actualx, actualy));
});
}
}
Expand Down

0 comments on commit 029d02a

Please sign in to comment.