Repository navigation
(cherry-pick) [Web LA] Adjust animation cleanup to slower devices - #8008
Merged
Merged
Conversation
## Summary
Turns out that on slower devices when animation lags, it can be removed
from DOM before it finishes. This results in callbacks not being called
and `dummy` being left instead of removed.
This PR:
1. Adjusts timeout value for slower devices,
2. Removes dummy elements when their animation is removed from DOM
## Test plan
<details>
<summary>Tested on the following code, with 20x throttling enabled in
chrome dev tools:</summary>
```jsx
import { useState } from 'react';
import { Button, View } from 'react-native';
import Animated, { Keyframe, Easing } from 'react-native-reanimated';
function Square() {
const [visible, setVisible] = useState(false);
const easing = Easing.bezier(0.76, 0.0, 0.24, 1.0).factory();
const animation = new Keyframe({
from: { transform: [{ translateX: '0%' }] },
to: {
transform: [{ translateX: '100%' }],
easing,
},
});
return (
<View
style={{
padding: 20,
flex: 1,
flexDirection: 'row',
alignItems: 'center',
}}>
<Button
title="Toggle"
onPress={() => setVisible((visible) => !visible)}
/>
{visible && (
<Animated.View
style={{
backgroundColor: 'red',
width: 200,
height: 200,
flexDirection: 'row',
flexWrap: 'wrap',
}}
exiting={animation
.duration(300)
.withCallback(() => console.log('callback!'))}>
{Array(10000)
.fill(0)
.map((_, i) => (
<View
key={i}
style={{ backgroundColor: 'yellow', width: 2, height: 2 }}
/>
))}
</Animated.View>
)}
</View>
);
}
export default function App() {
return (
<View style={{ flex: 1 }}>
<Square />
</View>
);
}
```
</details>
10 tasks done
m-bert
approved these changes
Aug 5, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-pick of the #7933