pychess-variants icon indicating copy to clipboard operation
pychess-variants copied to clipboard

Janggi: animate pass move

Open gbtami opened this issue 5 years ago • 2 comments

https://discord.com/channels/634298688663191582/693434760852406322/742133741421330514

gbtami avatar Aug 09 '20 21:08 gbtami

pieceflip {
  translate: scaleX(-1);
  transition: 500ms ease-in-out;
}

Add the class to the piece element on pass click and then remove the class after the animation finishes.

randompearl-stack avatar May 07 '24 20:05 randompearl-stack

Good idea! Thx for the css snippet. Unfortunately adding class to the piece can't work because it already has another transform directive, and multiple transform can work in one line only.

But it may work at https://github.com/gbtami/pychess-variants/blob/master/client/roundCtrl.ts#L835 after const lastMove = uci2LastMove(msg.lastMove);

something like:

        // Add flip css to pass move piece
        if (lastMove[0] == lastMove[1]) {
            const flipColor = (this.turnColor == 'white') ? 'black' : 'white';
            const piece = document.querySelector(`piece.${flipColor}.k-piece`) as HTMLElement;
            piece.style.transform = piece.style.transform + ' scaleX(-1)'
            piece.style.transition = '200ms ease-in-out'
        }

Somewhere later this should be removed of course as well.

gbtami avatar May 08 '24 12:05 gbtami