Skip to content

Fix multi-hop move animation showing only the last segment#188

Merged
ProLoser merged 2 commits intomainfrom
copilot/fix-multiple-move-animation
Mar 21, 2026
Merged

Fix multi-hop move animation showing only the last segment#188
ProLoser merged 2 commits intomainfrom
copilot/fix-multiple-move-animation

Conversation

Copy link
Contributor

Copilot AI commented Mar 20, 2026

When a piece is moved multiple times in one turn (e.g. "6/3 3/1"), the animation overlay only played the final segment instead of all hops.

Root cause

parseMove's cancellation logic removes moved[point] for intermediate stops — points where a piece both arrives and departs. This is correct for ghost/moved highlighting, but MoveAnimation.tsx relied solely on .piece.moved elements to locate the animation target, so intermediate destinations had no toEl and the segment was silently skipped.

Fix

Fall back to .piece.ghost elements when no .piece.moved is found at the destination. Ghost pieces survive the cancellation and are rendered at every intermediate point, so their DOM position correctly anchors the animation end for that segment.

// Before
const toEl = movedEls?.[toIdx] ?? null;

// After — ghost fallback for intermediate points
const ghostFallbackEls = points[pair.to as number]?.querySelectorAll<HTMLElement>('.piece.ghost');
const toEl = movedEls?.[toIdx] ?? ghostFallbackEls?.[toIdx] ?? null;

The toIdx counter already tracks how many times each point has been visited as a destination, so it correctly indexes into the ghost list for cases like doubles where the same intermediate point is visited multiple times.

Original prompt

when a piece is moved twice or more in one turn, only the last move is shown in the animation instead of all of the moves


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…e positions

Co-authored-by: ProLoser <67395+ProLoser@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix multiple moves animation display issue Fix multi-hop move animation showing only the last segment Mar 20, 2026
Copilot AI requested a review from ProLoser March 20, 2026 01:19
@github-actions
Copy link

github-actions bot commented Mar 20, 2026

PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-03-21 22:10 UTC

@ProLoser ProLoser marked this pull request as ready for review March 21, 2026 22:08
@ProLoser ProLoser merged commit 63ab63e into main Mar 21, 2026
2 checks passed
@ProLoser ProLoser deleted the copilot/fix-multiple-move-animation branch March 21, 2026 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants