Skip to content

Conversation

@bartlomiejbloniarz
Copy link
Contributor

@bartlomiejbloniarz bartlomiejbloniarz commented May 27, 2024

Summary

This PR brings layout animations to the New Architecture.

In the Old Architecture layout animations were implemented separately for iOS and Android. The new implementation leverages the MountingOverrideDelegate to intercept and animate layout changes right before they are sent to the platform. This way we can have a unified implementation across platforms (it should also work beyond Android and iOS).

MountingOverrideDelegate

The override delegate is called every time a new transaction is about to be mounted. It gives us full access to the mutations list and allows us to change them. This mechanism is used by RN, also in Layout Animations. It is important to note that this way we never commit a new ShadowTree - we only change the mutations that are sent to the platform. This means that those changes don't influence the layout of other views, which is consistent with the Old Arch implementation.

Limitations

  • configuration of entering animations is done using nativeID since I was unable to obtain the tag of a view before the animation should start
  • skipExiting does not work properly on android (I'm not sure why the componentWillUnmount method is called there earlier than on iOS)
  • globalOriginX and globalOriginY currently return the values of originX and originY - this part will probably require a native convertPoint function to be used
  • due to view flattening some exiting animations behave differently. The issue is explained in this PR.

Test plan

Go through the Layout Animations examples in the FabricExample app.

Copy link
Member

@piaskowyk piaskowyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work 👏👏👏

For me, this is ready to merge. Let users test it in real-life scenarios, and we can gather feedback accordingly.

@bartlomiejbloniarz bartlomiejbloniarz added this pull request to the merge queue Jun 18, 2024
Merged via the queue into main with commit 993491e Jun 18, 2024
@bartlomiejbloniarz bartlomiejbloniarz deleted the @bartlomiejbloniarz/fabric-layout-animations branch June 18, 2024 08:38
@mrousavy
Copy link
Contributor

Nice work guys 👏

r0h0gg6 pushed a commit to r0h0gg6/react-native-reanimated that referenced this pull request Jul 28, 2025
## Summary

This PR brings layout animations to the New Architecture. 

In the Old Architecture layout animations were implemented separately
for iOS and Android. The new implementation leverages the
`MountingOverrideDelegate` to intercept and animate layout changes right
before they are sent to the platform. This way we can have a unified
implementation across platforms (it should also work beyond Android and
iOS).

## `MountingOverrideDelegate`
The override delegate is called every time a new transaction is about to
be mounted. It gives us full access to the mutations list and allows us
to change them. This mechanism is used by RN, also in Layout Animations.
It is important to note that this way we never commit a new `ShadowTree`
- we only change the mutations that are sent to the platform. This means
that those changes don't influence the layout of other views, which is
consistent with the Old Arch implementation.

## Limitations
- configuration of entering animations is done using `nativeID` since I
was unable to obtain the `tag` of a view before the animation should
start
- `skipExiting` does not work properly on android (I'm not sure why the
`componentWillUnmount` method is called there earlier than on iOS)
- `globalOriginX` and `globalOriginY` currently return the values of
`originX` and `originY` - this part will probably require a native
`convertPoint` function to be used
- due to view flattening some exiting animations behave differently. The
issue is explained in [this
PR](facebook/react-native#44043).

## Test plan

Go through the Layout Animations examples in the FabricExample app.
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.

5 participants