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
+64-10Lines changed: 64 additions & 10 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
@@ -16,8 +23,9 @@ As of writing this guide, Shared Element Transitions are considered an experimen
16
23
17
24
Before continuing this guide make sure your app meets these criteria:
18
25
19
-
- 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).
26
+
- You are using [`@react-navigation/native-stack`](native-stack-navigator.md). JS-based [`@react-navigation/stack`](stack-navigator.md) or other navigators are not supported.
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.
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.
96
104
97
-
:::warning
105
+
Custom transition configuration is not fully finalized and might change in a future release.
98
106
99
-
Custom SharedTransition API is not finalized and might change in a future release.
107
+
### Old Architecture (Reanimated 3)
100
108
101
-
:::
102
-
103
-
To customize the transition you need to pass all the properties besides `transform`.
109
+
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.
142
+
143
+
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
167
168
+
## Limitations
169
+
170
+
Shared Element Transitions currently have several limitations to be aware of:
171
+
172
+
- Only the [native stack navigator](native-stack-navigator.md) is supported
173
+
- Other navigators such as JS stack, drawer, and bottom tabs are not supported
174
+
- Transitions with native modals don't work properly on iOS
175
+
176
+
### New Architecture specific limitations (Reanimated 4)
177
+
178
+
The following limitations apply specifically when using Reanimated 4 on the New Architecture:
179
+
180
+
- The feature must be enabled via the `ENABLE_SHARED_ELEMENT_TRANSITIONS` feature flag
181
+
- Custom animation functions are not supported; you can only customize duration and use spring-based animations
182
+
- Some properties (e.g., `backgroundColor`) are not supported in progress-based transitions (iOS back gesture)
183
+
- There are performance bottlenecks with transforms being recalculated too eagerly
184
+
- On iOS, you may encounter issues with vertical positioning due to header height information propagation
185
+
186
+
The limitations will be addressed in future Reanimated releases.
187
+
134
188
## Alternatives
135
189
136
190
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.
Copy file name to clipboardExpand all lines: versioned_docs/version-7.x/shared-element-transitions.md
+61-91Lines changed: 61 additions & 91 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,9 +11,14 @@ This guide covers how to animate elements between screens. This feature is known
11
11
12
12
:::warning
13
13
14
-
As of writing this guide, Shared Element Transitions are considered an experimental feature not recommended for production use.
14
+
Shared Element Transitions are an experimental feature not recommended for production use yet.
15
15
16
-
Shared Element Transitions are currently only supported on **old React Native architecture** (Paper).
16
+
**Architecture support:**
17
+
18
+
-**Reanimated 3** supports Shared Element Transitions on the **Old Architecture** (Paper).
19
+
-**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.
20
+
21
+
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)
17
22
18
23
:::
19
24
@@ -25,8 +30,9 @@ Shared Element Transitions are currently only supported on **old React Native ar
25
30
26
31
Before continuing this guide make sure your app meets these criteria:
27
32
28
-
- 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).
33
+
- You are using [`@react-navigation/native-stack`](native-stack-navigator.md). JS-based [`@react-navigation/stack`](stack-navigator.md) or other navigators are not supported.
29
34
- You have [`react-native-reanimated`](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started)**v3.0.0 or higher** installed and configured.
35
+
- 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).
30
36
31
37
## Minimal example
32
38
@@ -36,10 +42,7 @@ To create a shared transition:
36
42
2. Assign the same `sharedTransitionTag` to elements on different screens.
37
43
3. Navigate between screens. The transition will start automatically.
`sharedTransitionTag` is a string that has to be unique in the context of a single screen, but has to match elements between screens. This prop allows Reanimated to identify and animate the elements, similarly to the [`key`](https://react.dev/learn/rendering-lists#keeping-list-items-in-order-with-key) property, which tells React which element in the list is which.
183
113
184
114
## Customizing the transition
185
115
186
-
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.
116
+
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.
187
117
188
-
:::warning
118
+
Custom transition configuration is not fully finalized and might change in a future release.
189
119
190
-
Custom SharedTransition API is not finalized and might change in a future release.
120
+
### Old Architecture (Reanimated 3)
191
121
192
-
:::
193
-
194
-
To customize the transition you need to pass all the properties besides `transform`.
122
+
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()`:
sharedTransitionStyle={customTransition} // add this to both elements on both screens
146
+
sharedTransitionStyle={customTransition}
147
+
/>
148
+
);
149
+
}
150
+
```
151
+
152
+
### New Architecture (Reanimated 4)
153
+
154
+
On the New Architecture, the default transition animates `width`, `height`, `originX`, `originY`, `transform`, `backgroundColor`, and `opacity` using `withTiming` with a 500 ms duration.
155
+
156
+
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/).
224
180
225
-
## Alternatives
181
+
## Limitations
182
+
183
+
Shared Element Transitions currently have several limitations to be aware of:
184
+
185
+
- Only the [native stack navigator](native-stack-navigator.md) is supported
186
+
- Other navigators such as JS stack, drawer, and bottom tabs are not supported
187
+
- Transitions with native modals don't work properly on iOS
188
+
189
+
### New Architecture specific limitations (Reanimated 4)
190
+
191
+
The following limitations apply specifically when using Reanimated 4 on the New Architecture:
226
192
227
-
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.
193
+
- The feature must be enabled via the `ENABLE_SHARED_ELEMENT_TRANSITIONS` feature flag
194
+
- Custom animation functions are not supported; you can only customize duration and use spring-based animations
195
+
- Some properties (e.g., `backgroundColor`) are not supported in progress-based transitions (iOS back gesture)
196
+
- There are performance bottlenecks with transforms being recalculated too eagerly
197
+
- On iOS, you may encounter issues with vertical positioning due to header height information propagation
228
198
229
-
The [`react-native-navigation`](https://github.com/wix/react-native-navigation) also comes with support for Shared Element Transitions. You can read more about it [here](https://wix.github.io/react-native-navigation/docs/style-animations#shared-element-transitions).
199
+
The limitations will be addressed in future Reanimated releases.
0 commit comments