chessboardjsx icon indicating copy to clipboard operation
chessboardjsx copied to clipboard

Adding onStartDrag callback

Open dfish13 opened this issue 4 years ago • 2 comments

I thought it would be useful to add an onStartDrag(square) prop that is called whenever the user initiates a drag for a piece. For example it would help with highlighting the available moves when a user grabs a piece. And maybe an onStopDrag too!

I tried to use allowDrag to achieve this effect but for some reason allowDrag is called many times after a piece is dropped. When I added logic to compute available moves and change squareStyles for those squares in the allowDrag function it ended up calling allowDrag even more times and crashing the component. So I guess allowDrag was not designed to be used this way and I don't really understand why it gets called so many times.

I would be happy to work on this issue since I use this library on a personal project : )

dfish13 avatar Feb 25 '22 15:02 dfish13

react-chessboard (that was made because this library is no longer maintained) has onPieceDragBegin and onPieceDragEnd

Clariity avatar Apr 06 '22 10:04 Clariity

@Clariity Excellent! I will probably migrate my project over to use react-chessboard then.

dfish13 avatar Apr 11 '22 18:04 dfish13