Skip to content
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

Entering layout animation jump on initial render #5952

Open
matinzd opened this issue Apr 29, 2024 · 3 comments · May be fixed by #6052
Open

Entering layout animation jump on initial render #5952

matinzd opened this issue Apr 29, 2024 · 3 comments · May be fixed by #6052
Labels
Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS Repro provided A reproduction with a snippet of code, snack or repo is provided

Comments

@matinzd
Copy link

matinzd commented Apr 29, 2024

Description

There is an initial jump when calculating the boundaries of the view when using layout animations on initial render. It is more obvious on iOS but it also happens a bit on Android.

RPReplay_Final1714400189.MP4

Steps to reproduce

  1. Add some views with space between them
  2. Add some views after other views and apply entering animation
  3. Add some delay to it to see the jump and increase the duration

Snack or a link to a repository

https://snack.expo.dev/@matinzd/reanimated-layout-animation-bug

Reanimated version

3.9.0

React Native version

0.74.0

Platforms

Android, iOS

JavaScript runtime

Hermes

Workflow

React Native

Architecture

Paper (Old Architecture)

Build type

Debug app & production bundle

Device

Real device

Device model

iPhone 12 Pro

Acknowledgements

Yes

@github-actions github-actions bot added Repro provided A reproduction with a snippet of code, snack or repo is provided Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS labels Apr 29, 2024
@matinzd
Copy link
Author

matinzd commented Apr 29, 2024

Update:

I realized that even without adding space or margin between items, the bug is still present. I have updated the reproducible example.

Wrapping it in another view will fix the issue on iOS but it is still broken on Android.

@exploIF
Copy link
Contributor

exploIF commented May 23, 2024

Hi @matinzd, regarding Android issue I cannot reproduce it with your example.

Regarding iOS issue I've take a look on your repro and I've managed to fix it by providing additional container for all your components rendered directly inside SafeAreaView (not only for the Animated.View itself). It is because SafeAreaView is adding padding which is somehow making animated component to jump afer animation is completed. We will take a look on this behavior closer.

Please check my code

import { Text, SafeAreaView, StyleSheet, View } from 'react-native';
import Animated, { FadeIn } from 'react-native-reanimated';
import { Card } from 'react-native-paper';
import AssetExample from './components/AssetExample';

const animation = FadeIn.delay(1000).duration(2000);

export default function App() {
  return (
    <SafeAreaView style={{flex: 1}}>
      <View style={styles.container}>
        <Text style={styles.paragraph}>
            Test text to expand the size between
          </Text>
          <Text style={styles.paragraph}>
            Test text to expand the size between
          </Text>
          <Animated.View entering={animation}>
            <Card>
              <AssetExample />
            </Card>
          </Animated.View>
      </View>
    </SafeAreaView>
  );
}
const styles = StyleSheet.create({
  container: {
    justifyContent: 'center',
    backgroundColor: '#ecf0f1',
  },
  paragraph: {
    fontSize: 18,
    fontWeight: 'bold',
    textAlign: 'center',
  },
});

@exploIF
Copy link
Contributor

exploIF commented May 28, 2024

We've decided to add a warning message when animated component is rendered directly inside SafeAreaView. Also, this will be added to Troubleshooting section in our docs too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS Repro provided A reproduction with a snippet of code, snack or repo is provided
Projects
None yet
2 participants