You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: versioned_docs/version-6.x/shared-element-transitions.md
+60-8Lines changed: 60 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,17 @@
1
1
# Animating elements between screens
2
2
3
-
This guide covers how to animate elements between screens. This feature is known as a [Shared Element Transition](https://docs.swmansion.com/react-native-reanimated/docs/api/sharedElementTransitions) and it's implemented in the [`@react-navigation/native-stack`](/docs/native-stack-navigator) with [React Native Reanimated](https://docs.swmansion.com/react-native-reanimated/).
3
+
This guide covers how to animate elements between screens. This feature is known as a [Shared Element Transition](https://docs.swmansion.com/react-native-reanimated/docs/shared-element-transitions/overview/) and it's implemented in the [`@react-navigation/native-stack`](native-stack-navigator.md) with [React Native Reanimated](https://docs.swmansion.com/react-native-reanimated/).
4
4
5
5
:::warning
6
6
7
-
As of writing this guide, Shared Element Transitions are considered an experimental feature not recommended for production use.
7
+
Shared Element Transitions are an experimental feature not recommended for production use yet.
8
+
9
+
**Architecture support:**
10
+
11
+
-**Reanimated 3** supports Shared Element Transitions on the **Old Architecture** (Paper).
12
+
-**Reanimated 4** supports them on the **New Architecture** (Fabric) since 4.2.0, but the feature is behind a feature flag. You need to [enable the `ENABLE_SHARED_ELEMENT_TRANSITIONS` feature flag](https://docs.swmansion.com/react-native-reanimated/docs/guides/feature-flags#enable_shared_element_transitions) to use it.
13
+
14
+
Check [the Reanimated documentation](https://docs.swmansion.com/react-native-reanimated/docs/shared-element-transitions/overview/) for details and [send feedback to the Reanimated team](https://github.com/software-mansion/react-native-reanimated)
8
15
9
16
:::
10
17
@@ -18,6 +25,7 @@ Before continuing this guide make sure your app meets these criteria:
18
25
19
26
- You are using [`@react-navigation/native-stack`](native-stack-navigator.md). The Shared Element Transitions feature isn't supported in JS-based [`@react-navigation/stack`](stack-navigator.md).
20
27
- You have [`react-native-reanimated`](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started)**v3.0.0 or higher** installed and configured.
28
+
- If you are using **Reanimated 4** (New Architecture), you must [enable the `ENABLE_SHARED_ELEMENT_TRANSITIONS` feature flag](https://docs.swmansion.com/react-native-reanimated/docs/guides/feature-flags#enable_shared_element_transitions).
By default, the transition animates the `width`, `height`, `originX`, `originY` and `transform` properties using `withTiming` with a 500 ms duration. You can easily customize `width`, `height`, `originX`, and `originY` props. Customizing `transform` is also possible but it's far beyond the scope of this guide.
96
-
97
-
:::warning
103
+
You can customize the transition by passing a custom `SharedTransition` configuration via the `sharedTransitionStyle` prop. Apply the same `sharedTransitionStyle` to the matching element on the target screen.
98
104
99
-
Custom SharedTransition API is not finalized and might change in a future release.
105
+
Custom transition configuration is not fully finalized and might change in a future release.
100
106
101
107
:::
102
108
103
-
To customize the transition you need to pass all the properties besides `transform`.
109
+
### Old Architecture (Reanimated 3)
110
+
111
+
By default, the transition animates `width`, `height`, `originX`, `originY`, and `transform` using `withTiming` with a 500 ms duration. You can customize the transition using `SharedTransition.custom()`:
On the New Architecture, the default transition animates `width`, `height`, `originX`, `originY`, `transform`, `backgroundColor`, and `opacity` using `withTiming` with a 500 ms duration.
141
+
142
+
Currently customization is more limited due to ongoing development. You can't define fully custom animation functions. Instead, use the `SharedTransition` builder class to configure duration and spring-based animations:
You can find a full Shared Element Transitions reference in the [React Native Reanimated documentation](https://docs.swmansion.com/react-native-reanimated/docs/shared-element-transitions/overview/).
133
165
166
+
## Limitations
167
+
168
+
Shared Element Transitions have several current limitations to be aware of:
169
+
170
+
- Only the native stack navigator is supported
171
+
- The Tab navigator is not supported
172
+
- Transitions with native modals don't work properly on iOS
173
+
174
+
### New Architecture specific limitations (Reanimated 4)
175
+
176
+
The following limitations apply specifically when using Reanimated 4 on the New Architecture:
177
+
178
+
- The feature must be enabled via the `ENABLE_SHARED_ELEMENT_TRANSITIONS` feature flag
179
+
- Custom animation functions are not supported; you can only customize duration and use spring-based animations
180
+
- Some properties (e.g., `backgroundColor`) are not supported in progress-based transitions (iOS back gesture)
181
+
- There are performance bottlenecks with transforms being recalculated too eagerly
182
+
- On iOS, you may encounter issues with vertical positioning due to header height information propagation
183
+
184
+
The limitations will be addressed in future Reanimated releases.
185
+
134
186
## Alternatives
135
187
136
188
Alternatively, you can use [`react-native-shared-element`](https://github.com/IjzerenHein/react-native-shared-element) library with a [React Navigation binding](https://github.com/IjzerenHein/react-navigation-shared-element) which implements Shared Element Transitions in a JS-based `@react-navigation/stack` navigator. This solution, however, isn't actively maintained.
0 commit comments