Skip to content

Commit

Permalink
fix: syncronized animation bug (#2420)
Browse files Browse the repository at this point in the history
Fixes issue when multiple skeletons or spinners are removed at different
times, causing crash

![image](https://github.com/user-attachments/assets/97f2fc9c-5b41-42d7-9b1b-ec1b7468098f)
The issue is because `firstOfType` might exist, but it might not have a
`currentTime` and setting `myAnimation.currentTime = null` is not
allowed.
Reported by Team Export Mattilsynet
  • Loading branch information
eirikbacker authored Sep 16, 2024
1 parent 54d3037 commit dc8ecf9
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,16 @@ export function useSynchronizedAnimation<T>(animationName: string) {
myAnimation.currentTime = 0;
}

if (myAnimation && firstOfType && myAnimation !== firstOfType) {
if (
myAnimation &&
firstOfType?.currentTime &&
myAnimation !== firstOfType
) {
myAnimation.currentTime = firstOfType.currentTime;
}

return () => {
if (myAnimation && firstOfType) {
if (myAnimation && firstOfType?.currentTime) {
myAnimation.currentTime = firstOfType.currentTime;
}
};
Expand Down

0 comments on commit dc8ecf9

Please sign in to comment.