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
+18-6Lines changed: 18 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -1,20 +1,29 @@
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 nativestack 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/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/).
4
4
5
-
Before continuing, make sure to install and configure [`react-native-reanimated`](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation).
6
-
7
-
> Note: Shared Element Transitions require React Native Reanimated v3.0.0 or higher, and as of writing this guide, it's considered an experimental feature not recommended for production use.
5
+
> Note: As of writing this guide, Shared Element Transitions are considered an experimental feature not recommended for production use.
Before continuing this guide make sure your app meets these criteria:
16
+
17
+
- You are using [`@react-navigation/native-stack`](/docs/native-stack-navigator). The Shared Element Transitions feature isn't supported in JS-based [`@react-navigation/stack`](/docs/stack-navigator).
18
+
- You have [`react-native-reanimated`](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation)**v3.0.0 or higher** installed and configured.
19
+
15
20
## Minimal example
16
21
17
-
To create a shared transition, simply assign the same `sharedTransitionTag` to elements on different screens in a native stack. This prop is a string that has to be unique in the context of a single screen, but has to match elements between screens. 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, `sharedElementTag` allows Reanimated to identify and animate elements. Components that you'd like to animate have to be `Animated` versions imported from `react-native-reanimated`. The animation will start automatically when you navigate between screens.
22
+
To create a shared transition:
23
+
24
+
1. Use `Animated` components imported from `react-native-reanimated`.
25
+
2. Assign the same `sharedTransitionTag` to elements on different screens.
26
+
3. Navigate between screens. The transition will start automatically.
18
27
19
28
```jsx
20
29
import*asReactfrom'react';
@@ -24,6 +33,7 @@ import { createNativeStackNavigator } from '@react-navigation/native-stack';
`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.
90
+
79
91
## Customizing the transition
80
92
81
93
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.
@@ -115,6 +127,6 @@ You can find a full Shared Element Transitions reference in the [React Native Re
115
127
116
128
## Alternatives
117
129
118
-
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 Stack navigator. This solution, however, isn't actively maintained.
130
+
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.
119
131
120
132
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).
Copy file name to clipboardExpand all lines: versioned_docs/version-7.x/shared-element-transitions.md
+18-6Lines changed: 18 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -1,20 +1,29 @@
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 nativestack 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/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/).
4
4
5
-
Before continuing, make sure to install and configure [`react-native-reanimated`](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation).
6
-
7
-
> Note: Shared Element Transitions require React Native Reanimated v3.0.0 or higher, and as of writing this guide, it's considered an experimental feature not recommended for production use.
5
+
> Note: As of writing this guide, Shared Element Transitions are considered an experimental feature not recommended for production use.
Before continuing this guide make sure your app meets these criteria:
16
+
17
+
- You are using [`@react-navigation/native-stack`](/docs/native-stack-navigator). The Shared Element Transitions feature isn't supported in JS-based [`@react-navigation/stack`](/docs/stack-navigator).
18
+
- You have [`react-native-reanimated`](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation)**v3.0.0 or higher** installed and configured.
19
+
15
20
## Minimal example
16
21
17
-
To create a shared transition, simply assign the same `sharedTransitionTag` to elements on different screens in a native stack. This prop is a string that has to be unique in the context of a single screen, but has to match elements between screens. 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, `sharedElementTag` allows Reanimated to identify and animate elements. Components that you'd like to animate have to be `Animated` versions imported from `react-native-reanimated`. The animation will start automatically when you navigate between screens.
22
+
To create a shared transition:
23
+
24
+
1. Use `Animated` components imported from `react-native-reanimated`.
25
+
2. Assign the same `sharedTransitionTag` to elements on different screens.
26
+
3. Navigate between screens. The transition will start automatically.
18
27
19
28
```jsx
20
29
import*asReactfrom'react';
@@ -24,6 +33,7 @@ import { createNativeStackNavigator } from '@react-navigation/native-stack';
`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.
90
+
79
91
## Customizing the transition
80
92
81
93
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.
@@ -115,6 +127,6 @@ You can find a full Shared Element Transitions reference in the [React Native Re
115
127
116
128
## Alternatives
117
129
118
-
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 Stack navigator. This solution, however, isn't actively maintained.
130
+
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.
119
131
120
132
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).
0 commit comments