Closed AhsanSarwar45 closed 9 months ago
An even better example would be the crazyhouse variant in lichess. Is that done using in built features, or custom-made?
Dropping off the board is done via: https://github.com/lichess-org/chessground/blob/f90358e77403673027ef3215cfe6266dc98bbc44/src/config.ts#L66
To drag a new piece onto the board, a little bit of glue is needed, because the pocket is not part of chessground. Call https://github.com/lichess-org/chessground/blob/f90358e77403673027ef3215cfe6266dc98bbc44/src/api.ts#L72 from the mousedown
event handler of the pocket.
@niklasf Thank you, that worked. By any chance, is there a way to specify legal squares that the pieces can be dragged on to?
For a new piece that's dragged in? Not directly, but you provide a callback https://github.com/lichess-org/chessground/blob/f90358e77403673027ef3215cfe6266dc98bbc44/src/config.ts#L77 and reset the board state if needed. That's how lichess.org implements Crazyhouse drops.
For pieces that are already on the board, yes:
Hi, I was wondering if its possible to drag and drop pieces pieces off the board like in this chessboard.js example?