Skip to content

fix(app,components): Fix unreliable MoveLabwareOnDeck animation #19179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 41 additions & 19 deletions components/src/hardware-sim/Deck/MoveLabwareOnDeck.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,30 +111,52 @@ export function MoveLabwareOnDeck(
? finalCoordinates
: offDeckCoordinates

// The user can't see the splash animation if it happens off-deck.
// Skip it so there's no pause where it looks like nothing is happening.
const shouldAnimateSplashBeforeMove =
animationInitialCoordinates !== offDeckCoordinates
const shouldAnimateSplashAfterMove =
animationFinalCoordinates !== offDeckCoordinates

const shouldReset = usePositionChangeReset(
animationInitialCoordinates,
animationFinalCoordinates
)

const springProps = useSpring({
reset: shouldReset,
config: { duration: 1000, easing: easings.easeInOutSine },
from: {
...animationInitialCoordinates,
splashOpacity: 0,
deckOpacity: 0,
},
to: [
{ deckOpacity: 1 },
{ splashOpacity: 1 },
{ splashOpacity: 0 },
{ ...animationFinalCoordinates },
{ splashOpacity: 1 },
{ splashOpacity: 0 },
{ deckOpacity: 0 },
],
loop: true,
})
const [springProps] = useSpring(
() => ({
reset: shouldReset,
config: { duration: 1000, easing: easings.easeInOutSine },
from: {
...animationInitialCoordinates,
splashOpacity: 0,
deckOpacity: 0,
},
to: [
{ deckOpacity: 1 },
...(shouldAnimateSplashBeforeMove
? [{ splashOpacity: 1 }, { splashOpacity: 0 }]
: []),
{ ...animationFinalCoordinates },
...(shouldAnimateSplashAfterMove
? [{ splashOpacity: 1 }, { splashOpacity: 0 }]
: []),
{ deckOpacity: 0 },
],
loop: true,
}),
// Dependency array:
[
shouldReset,
// react-spring behaves weirdly if its props are updated too frequently.
// So make sure to filter out coordinate "updates" that are just object identity
// updates and not updates to the actual x/y/z components.
...Object.values(animationInitialCoordinates),
...Object.values(animationFinalCoordinates),
shouldAnimateSplashBeforeMove,
shouldAnimateSplashAfterMove,
]
)

return (
<BaseDeck
Expand Down
Loading