mirror of
https://github.com/sigmasternchen/php-chess
synced 2025-03-15 07:58:54 +00:00
feat: Clear move selection when clicking on the source piece
This commit is contained in:
parent
9a0a705607
commit
985bff13b7
1 changed files with 11 additions and 7 deletions
|
@ -31,6 +31,9 @@ const loadBoard = (board) => {
|
||||||
|
|
||||||
board.querySelectorAll(".piece.hasMoves").forEach(element => {
|
board.querySelectorAll(".piece.hasMoves").forEach(element => {
|
||||||
element.addEventListener("click", event => {
|
element.addEventListener("click", event => {
|
||||||
|
if (board.classList.contains("moveSelection")) {
|
||||||
|
clearSelection();
|
||||||
|
} else {
|
||||||
clearSelection();
|
clearSelection();
|
||||||
const moves = element.getAttribute("data-moves").split(";").map(move => ({
|
const moves = element.getAttribute("data-moves").split(";").map(move => ({
|
||||||
encoded: move,
|
encoded: move,
|
||||||
|
@ -38,6 +41,7 @@ const loadBoard = (board) => {
|
||||||
target: move.split(",")[1]
|
target: move.split(",")[1]
|
||||||
}));
|
}));
|
||||||
enterSelection(moves);
|
enterSelection(moves);
|
||||||
|
}
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue