Layout Animation not working as expected with other view
See original GitHub issueDescription
I’m try to use layout animtion with other view of react native. But i think, Layout Animation just create a copy element to animate not like animte layout as docs mentioned
Expected behavior
Animate my view same the docs
Actual behavior & steps to reproduce
Let’s see my code and my video
Snack or minimal code example
import React, {memo, useState} from 'react';
import isEqual from 'react-fast-compare';
import {Button, Text, View} from 'react-native';
import Animated, {FadeIn, FadeOut, Layout} from 'react-native-reanimated';
const LoginComponent = () => {
const [visible, setVisible] = useState<boolean>(false);
// render
return (
<View style={{flex: 1, paddingVertical: 50}}>
<Button
title={'Toggle'}
onPress={() => {
setVisible(v => !v);
}}
/>
<Animated.View layout={Layout} style={{backgroundColor: 'green'}}>
<Text>Layout</Text>
{visible && (
<Animated.View
layout={Layout}
entering={FadeIn}
exiting={FadeOut}
style={{width: 50, height: 50, backgroundColor: 'red'}}
/>
)}
</Animated.View>
<View style={{backgroundColor: 'yellow', paddingVertical: 10}}>
<Text>My Text</Text>
</View>
</View>
);
};
export const Login = memo(LoginComponent, isEqual);
Package versions
name | version |
---|---|
react-native | 0.66.4 |
react-native-reanimated | 2.3.1 |
Affected platforms
- Android
- [x ] iOS
- Web
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Layout animation not working on first run - Stack Overflow
My problem is, the first time I run the app, when I click on an item, the onClick callback is executed, but the...
Read more >RecyclerView android:layoutAnimation not working
If you attempt to animate on a view that has not been rendered yet, the animation will occur on the view without a...
Read more >Animation | Jetpack Compose - Android Developers
Many Jetpack Compose Animation APIs are available as composable functions just like layouts and other UI elements, and they are backed by lower-level...
Read more >The little secret of android:animateLayoutChanges
A flag indicating the animation that runs on those items that are changing due to a layout change not caused by items being...
Read more >How to fix ZStack's views disappear transition not animated in ...
The transition animation work as expected. Set the views below the problem view to a non-zero value. Depend on your view layout, set ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I faced an issue like this. You just need to cover your parent element in <Animated.View/> Tag.
` <Animated.View style={{flex: 1, paddingVertical: 50}}> <Button title={‘Toggle’} onPress={() => { setVisible(v => !v); }} />
`
Hello! Can you please clarify what is the expected behaviour?
If you want the yellow box to animate smoothly to its target position instead of jumping immediately, please convert the component to
Animated.View
and uselayout
prop, similarly as for the green box:Alternatively, if the issue is related to the red box layout animation when toggling it on and off faster than the duration of the animation, please clarify what is the expected behaviour so we can help you! 😄