@@ -61,7 +61,8 @@ export function Board({ flipped = false }: Props) {
6161 } ;
6262
6363 const lastMove = state . history [ state . history . length - 1 ] ;
64- const moveIndex = state . history . length ;
64+ // Include replay nonce so "Replay" re-mounts animated pieces and restarts keyframes.
65+ const moveAnimIndex = state . history . length + lastMoveReplayNonce ;
6566 const checkedKing = result . kind === "ongoing" && inCheck ( state , state . turn )
6667 ? findKing ( state , state . turn )
6768 : null ;
@@ -125,7 +126,7 @@ export function Board({ flipped = false }: Props) {
125126 [ "--slide-dx" as string ] : `${ sign * df * 100 } %` ,
126127 [ "--slide-dy" as string ] : `${ sign * dr * 100 } %`
127128 } ;
128- slideKey = `slide-${ moveIndex } - ${ lastMoveReplayNonce } ` ;
129+ slideKey = `slide-${ moveAnimIndex } ` ;
129130 }
130131 const isRematerializeHere =
131132 isTeleportMove &&
@@ -154,7 +155,7 @@ export function Board({ flipped = false }: Props) {
154155 ) }
155156 { piece && (
156157 < span
157- key = { isRematerializeHere ? `remat-${ moveIndex } - ${ lastMoveReplayNonce } ` : slideKey }
158+ key = { isRematerializeHere ? `remat-${ moveAnimIndex } ` : slideKey }
158159 className = {
159160 isRematerializeHere
160161 ? "piece-wrap piece-rematerialize"
@@ -174,7 +175,7 @@ export function Board({ flipped = false }: Props) {
174175 ) }
175176 { isDematerializeHere && lastMove && (
176177 < span
177- key = { `demat-${ moveIndex } - ${ lastMoveReplayNonce } ` }
178+ key = { `demat-${ moveAnimIndex } ` }
178179 className = "piece-wrap piece-dematerialize"
179180 aria-hidden = "true"
180181 >
@@ -187,7 +188,7 @@ export function Board({ flipped = false }: Props) {
187188 </ span >
188189 ) }
189190 { isLastTo && lastMove ?. captured && store . settings . explodeOnCapture && (
190- < span key = { `boom-${ moveIndex } - ${ lastMoveReplayNonce } ` } className = "boom" aria-hidden = "true" >
191+ < span key = { `boom-${ moveAnimIndex } ` } className = "boom" aria-hidden = "true" >
191192 < span className = "boom-core" > 💥</ span >
192193 < span className = "boom-bit b1" > ✨</ span >
193194 < span className = "boom-bit b2" > ⭐</ span >
0 commit comments