mirror of
https://github.com/sigmasternchen/php-chess
synced 2025-03-14 23:58:53 +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,13 +31,17 @@ const loadBoard = (board) => {
|
|||
|
||||
board.querySelectorAll(".piece.hasMoves").forEach(element => {
|
||||
element.addEventListener("click", event => {
|
||||
clearSelection();
|
||||
const moves = element.getAttribute("data-moves").split(";").map(move => ({
|
||||
encoded: move,
|
||||
source: move.split(",")[0].split("-")[2],
|
||||
target: move.split(",")[1]
|
||||
}));
|
||||
enterSelection(moves);
|
||||
if (board.classList.contains("moveSelection")) {
|
||||
clearSelection();
|
||||
} else {
|
||||
clearSelection();
|
||||
const moves = element.getAttribute("data-moves").split(";").map(move => ({
|
||||
encoded: move,
|
||||
source: move.split(",")[0].split("-")[2],
|
||||
target: move.split(",")[1]
|
||||
}));
|
||||
enterSelection(moves);
|
||||
}
|
||||
event.stopPropagation();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue