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
@@ -17,6 +23,7 @@ Declarative routing library for React ⚛ with page transitions and animations
17
23
-[Transitions](#transitions)
18
24
-[Shared Element Transition](#shared-element-transition)
19
25
-[API Documentation](#api-documentation)
26
+
-[Stack.Screen](#stackscreen)
20
27
-[Router Config](#router-config)
21
28
-[Animation Config](#animation-config)
22
29
-[Shared Element Config](#sharedelementconfig)
@@ -33,7 +40,7 @@ npm install react-motion-router
33
40
34
41
#### Basic
35
42
36
-
Use the `Router` component to place your screens. Pass a React component to the component prop of `Stack.Screen` to be rendered when navigated to.
43
+
Use the `Router` component to render your screens. Pass a React component to the component prop of `Stack.Screen` to be rendered when the path prop of the screen has been navigated to.
37
44
38
45
```
39
46
...
@@ -103,11 +110,11 @@ All data passed to the navigate function is accessible on the target screen thro
103
110
104
111
#### Default Parameters
105
112
106
-
A default parameter can be passed to the screen by passing a value to the default_params prop on `Stack.Screen` component.
113
+
A default parameter can be passed to the screen by passing a value to the defaultParams prop on `Stack.Screen` component.
@@ -131,6 +138,27 @@ Transitions are a feature baked into react-motion-router; hence the name... To t
131
138
</Router>
132
139
```
133
140
141
+
You can subscribe to the transition progress by using the motion consumer component.
142
+
143
+
```
144
+
import {Motion} from 'react-motion-router';
145
+
146
+
...
147
+
<Motion.Consumer>
148
+
{(progress) => {
149
+
return (
150
+
<div>{progress}</div>
151
+
);
152
+
}}
153
+
</Motion.Consumer>
154
+
155
+
// OR Class.contextType
156
+
157
+
static contextType = Motion;
158
+
```
159
+
160
+
The progress is updated as the animation plays and can be used to update DOM style attributes or control playback of an animation.
161
+
134
162
#### Shared Element Transition
135
163
136
164
To do a shared element transition wrap the component you would like shared between screens and supply it with a unique ID prop.
@@ -173,24 +201,34 @@ That's it! The element will transition from one screen to the next seemlessly. T
173
201
This way the X and Y axis are animated independently and can alter the path of the shared element while transitioning.
174
202
175
203
## API Documentation
204
+
#### Stack.Screen
205
+
| Property | Type | Description |
206
+
| ------ | ------ | ------ |
207
+
| path | string | Pathname of the screen.|
208
+
| animation | AnimationConfig | Config object used to modify the router's transition behaviour. In and out animation can also be set independently.|
209
+
| component | any | A valid React Component to be rendered. |
210
+
| defaultParams | Object | A dictionary of parameters that can be accessed by the rendered component. |
176
211
177
212
#### Router Config
178
213
179
214
Config object used to modify the behaviour of the Router.
180
215
| Property | Type | Description |
181
216
| ------ | ------ | ------ |
182
-
| default_route | string | If the user navigates directly to a route other than the default and navigate.go_back() is called the app will navigate to the default route instead of closing. |
183
-
| page_load_transition | boolean | Set to false if you wish to disable page transitions when the application first loads. |
184
-
| animation | AnimationConfig | Config object used to modify the router's transition behaviour. |
217
+
| defaultRoute | string | If the user navigates directly to a route other than the default and navigate.goBack() is called the app will navigate to the default route instead of leaving the website. |
218
+
| pageLoadTransition | boolean | Set to false if you wish to disable page transitions when the application first loads. |
219
+
| animation | AnimationConfig | Config object used to modify the router's global transition behaviour. In and out animation can also be set independently. |
220
+
| swipeAreaWidth | number | Area in pixels from the left edge of the screen that gesture navigation can be triggered from. |
221
+
| hysteresis | number | Percent from 0-100 which specifies minimum gesture progress before navigation is triggered. |
222
+
| minFlingVelocity | number | Minimum average velocity of swipe gesture before navigation is triggered even if hysteresis was not reached. |
185
223
186
224
#### Animation Config
187
225
188
226
Config object used to modify the router's transition behaviour.
189
227
| Property | Type | Description |
190
228
| ------ | ------ | ------ |
191
-
| type | "slide"or "fade" | The animation type used for page transitions. |
229
+
| type | "slide", "fade", "zoom" or "none" | The animation type used for page transitions. |
192
230
| duration | number | The time in milliseconds for how long page transitions are from start to end. |
193
-
| direction | "left", "right", "up"or "down" | The direction used for slide transitions. The direction is swapped automatically on back navigation. i.e. The user presses their browser back button or navigation.go_back() is called. |
231
+
| direction | "left", "right", "up", "down", "in" or "out" | The direction used for slide transitions. The direction is swapped automatically on back navigation. i.e. The user presses their browser back button or navigation.goBack() is called. |
194
232
195
233
#### Shared Element Transitions
196
234
@@ -204,17 +242,17 @@ Config object used to modify the router's transition behaviour.
|transform_origin| TransformOrigin | Changes transform alignment of shared element. |
245
+
|transformOrigin| TransformOrigin | Changes transform alignment of shared element. |
208
246
| duration | number | The time in milliseconds for how long the shared element transition is from start to end |
209
-
|easing_function| CSS <easing-function>| Denotes a mathematical function that describes the rate at which a numerical value changes.<sup>[1](https://developer.mozilla.org/en-US/docs/Web/CSS/easing-function)</sup> |
247
+
|easingFunction| CSS <easing-function>| Denotes a mathematical function that describes the rate at which a numerical value changes.<sup>[1](https://developer.mozilla.org/en-US/docs/Web/CSS/easing-function)</sup> |
210
248
211
249
It is useful to note that the duration and easing function properties can also be set on the X and Y axis as independent values by specifying an X or Y property on the shared element config object.
0 commit comments