Skip to content

(cherry-pick) Fix dynamic updates of layout animations - #7813

Merged
MatiPl01 merged 1 commit into
3.18-stablefrom
@matipl01/cherry-pick/fix-layout-animation-update
Jul 17, 2025
Merged

MatiPl01 merged 1 commit into
3.18-stablefrom
@matipl01/cherry-pick/fix-layout-animation-update

Conversation

@MatiPl01

@MatiPl01 MatiPl01 commented Jul 16, 2025 •

Copy link
Copy Markdown
Contributor

Summary

This PR is a cherry-pick of changes applied in the #7788 and #7812 PRs with some adjustments for proper Paper support.

Example recordings

Paper

Worked fine before as well.

Before After
Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-07-17.at.01.17.11.mp4
Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-07-17.at.01.18.51.mp4

Fabric

Exiting animations could not be changed after the view was mounted. It had to be remounted to apply the new exiting prop value.

Before After
Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-07-17.at.01.13.08.mp4
Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-07-17.at.01.12.07.mp4

Test example

Code snippet
import React, { useState } from 'react';
import { Button, StyleSheet, View } from 'react-native';
import Animated, {
  FadeIn,
  FadeOutDown,
  LinearTransition,
} from 'react-native-reanimated';

export default function EmptyExample() {
  const [exitingEnabled, setExitingEnabled] = useState(true);
  const [layoutEnabled, setLayoutEnabled] = useState(true);
  const [show, setShow] = useState(true);
  const [pos, setPos] = useState(0);

  return (
    <View style={styles.container}>
      <Button title="Toggle show" onPress={() => setShow(!show)} />
      <Button title="Toggle pos" onPress={() => setPos(Math.random() * 100)} />
      <Button
        title={`Toggle exiting: ${exitingEnabled}`}
        onPress={() => setExitingEnabled(!exitingEnabled)}
      />
      <Button
        title={`Toggle layout: ${layoutEnabled}`}
        onPress={() => setLayoutEnabled(!layoutEnabled)}
      />
      {show && (
        <Animated.View
          entering={FadeIn}
          exiting={exitingEnabled ? FadeOutDown : undefined}
          layout={layoutEnabled ? LinearTransition : undefined}
          style={{
            top: pos,
            width: 100,
            height: 100,
            backgroundColor: 'red',
          }}
        />
      )}
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
});

@MatiPl01 MatiPl01 self-assigned this Jul 16, 2025
@MatiPl01 MatiPl01 mentioned this pull request Jul 16, 2025
21 tasks done
@MatiPl01
MatiPl01 marked this pull request as ready for review July 16, 2025 23:26
@MatiPl01
MatiPl01 merged commit 0aa7ffb into 3.18-stable Jul 17, 2025
@MatiPl01
MatiPl01 deleted the @matipl01/cherry-pick/fix-layout-animation-update branch July 17, 2025 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants