drop Snapback
If 'snapback'
is passed to the drop
event's setAction()
function, the dragged piece will return to it's source square.
HTML
<chess-board
style="width: 400px"
position="start"
draggable-pieces>
</chess-board>
JavaScript
const board = document.querySelector('chess-board');
// snapback black pieces when they are dropped
board.addEventListener('drop', (e) => {
const {piece, setAction} = e.detail;
if (piece.search(/b/) !== -1) {
setAction('snapback');
}
});