-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Flush UI operation queue when animation is not running #4329
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Co-authored-by: Tomek Zawadzki <tomasz.zawadzki@swmansion.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can confirm this PR successfully resolves the issue with useAnimatedSensor
✅
@piaskowyk @tomekzaw does this solve #4231 as well? |
@ranaavneet unfortunately, probably not, but we're working on it |
…ion#4329) ## Summary When animation is not running it is possible to enqueue UI update operation but never execute them. | Before | After | | ----------- | ----------- | | <video src="https://user-images.githubusercontent.com/36106620/230021472-c41aa77b-d955-4503-8273-a26e29dc7dea.mov" /> | <video src="https://user-images.githubusercontent.com/36106620/230021555-cbb62d7a-5f2e-4eb1-8d21-d3169aa1bfaf.mov" /> | I tested it on the Fabric also. <details> <summary>code</summary> ```js import Animated, { useSharedValue, useAnimatedStyle, useAnimatedProps, withTiming } from 'react-native-reanimated'; import { View, Button } from 'react-native'; import React from 'react'; export default function AnimatedStyleUpdateExample(): React.ReactElement { const sv1 = useSharedValue(20); const sv2 = useSharedValue(20); const style1 = useAnimatedStyle(() => ({ width: sv1.value })); const style2 = useAnimatedStyle(() => ({ width: sv2.value })); return ( <View style={{ flex: 1, flexDirection: 'column', marginTop: 50 }}> <Animated.View style={[ { width: 100, height: 80, backgroundColor: 'orange'}, style1, ]} /> <Animated.View style={[ { width: 100, height: 80, backgroundColor: 'black'}, style2, ]} /> <Button title={'set width for 1'} onPress={() => { sv1.value = withTiming(sv1.value === 20 ? 100 : 20); }} /> <Button title={'set width for 2'} onPress={() => { sv2.value = sv2.value === 20 ? 100 : 20; }} /> <Button title={'set width for 1 & 2'} onPress={() => { sv1.value = withTiming(sv1.value === 20 ? 100 : 20); sv2.value = sv2.value === 20 ? 100 : 20; }} /> </View> ); } ``` </details> --------- Co-authored-by: Tomek Zawadzki <tomasz.zawadzki@swmansion.com>
Summary
When animation is not running it is possible to enqueue UI update operation but never execute them.
Screen.Recording.2023-04-05.at.09.48.36.mov
Screen.Recording.2023-04-05.at.09.49.10.mov
I tested it on the Fabric also.
code