react-chess / chessground

Chessground React Wrapper
https://www.npmjs.com/package/@react-chess/chessground
GNU General Public License v3.0
29 stars 5 forks source link

onMove function #12

Closed gabrilator closed 1 year ago

gabrilator commented 2 years ago

Hey! Great job with the library, enjoying it so far!

I wonder if there's an implementation of onMove to receive the from and to after a user moves.

Thanks a lot! Gabriel

yarrichar commented 1 year ago

Yes, you need to pass it in through the config property.

        <Chessground config={{
            events: {
                move: onMove
            }
        }} />

Where onMove has signature: move?: (orig: cg.Key, dest: cg.Key, capturedPiece?: cg.Piece) => void;

H-Richard commented 1 year ago

Yes, you need to pass it in through the config property.

        <Chessground config={{
            events: {
                move: onMove
            }
        }} />

Where onMove has signature: move?: (orig: cg.Key, dest: cg.Key, capturedPiece?: cg.Piece) => void;

awesome response, thanks for resolving!