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: reason-react-native/src/apis/LayoutAnimation.md
+41-9Lines changed: 41 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,24 +3,47 @@ id: apis/LayoutAnimation
3
3
title: LayoutAnimation
4
4
---
5
5
6
-
`LayoutAnimation` API offers a simpler alternative to `Animated` API. Instead of directly manipulating values for various style props, it suffices to specify the animation to be run before the next render. Specification of the animation should happen in the reducer, before `state` is updated.
6
+
`LayoutAnimation` API offers a simpler alternative to `Animated` API. Instead of
7
+
directly manipulating values for various style props, it suffices to specify the
8
+
animation to be run before the next render. Specification of the animation
9
+
should happen in the reducer, before `state` is updated.
10
+
11
+
`LayoutAnimation` is still experimental on Android and needs to be explicitly
12
+
enabled with the `UIManager` method `setLayoutAnimationEnabledExperimental`.
13
+
However, as that method should be removed when `LayoutAnimation` is no longer
14
+
experimental, the external declaration for it wraps its type in `option` to
15
+
avoid runtime errors when that happens. `LayoutAnimation` may be enabled, if it
16
+
is not already enabled by default, by means of a statement such as:
-`configureNext` is the method to specify the animation, takes an argument of type `layoutAnimationConfig`.
27
+
-`configureNext` is the method to specify the animation, takes an argument of
28
+
type `layoutAnimationConfig`.
11
29
12
30
```reason
13
31
configureNext(layoutAnimationConfig)
14
32
```
15
33
16
-
-`configureNextWithEndCallback` is a convenience function, which allows specification of a callback function (of type `unit => unit`) to be run after the animation, in addition to `layoutAnimationConfig`.
34
+
-`configureNextWithEndCallback` is a convenience function, which allows
35
+
specification of a callback function (of type `unit => unit`) to be run after
36
+
the animation, in addition to `layoutAnimationConfig`.
`layoutAnimationConfig` can be created with the `layoutAnimationConfig` constructor
44
+
`layoutAnimationConfig` can be created with the `layoutAnimationConfig`
45
+
constructor
46
+
24
47
```reason
25
48
layoutAnimationConfig:
26
49
(
@@ -31,6 +54,7 @@ layoutAnimationConfig:
31
54
unit
32
55
)
33
56
```
57
+
34
58
or by means of the helper function `create`
35
59
36
60
```reason
@@ -49,7 +73,6 @@ create:
49
73
)
50
74
```
51
75
52
-
53
76
`animationConfig` can in turn be created with the `animationConfig` constructor
54
77
55
78
```reason
@@ -75,11 +98,15 @@ animationConfig:
75
98
76
99
## Presets
77
100
78
-
There are presets for `linear`, `spring` and `easeInEaseOut` transitions which allow a very straightforward way to setup animation. Presets may either be passed as ready-made `layoutAnimationConfig` to `configureNext` and `configureNextWithEndCallback` as below
101
+
There are presets for `linear`, `spring` and `easeInEaseOut` transitions which
102
+
allow a very straightforward way to setup animation. Presets may either be
103
+
passed as ready-made `layoutAnimationConfig` to `configureNext` and
or equivalently as already passed to `configureNext` as
84
111
85
112
```reason
@@ -89,8 +116,9 @@ LayoutAnimation.spring()
89
116
90
117
## Example
91
118
92
-
The example below illustrates animated transition (`spring`) between two views, such as registration and login forms. Animation is specified in the reducer, as below. Making use of `presets` is also illustrated (commented out).
93
-
119
+
The example below illustrates animated transition (`spring`) between two views,
120
+
such as registration and login forms. Animation is specified in the reducer, as
121
+
below, before state is returned.
94
122
95
123
```reason
96
124
open ReactNative;
@@ -157,11 +185,15 @@ let make = () => {
157
185
};
158
186
```
159
187
160
-
Above animation specification is that of the `spring` preset. Accordingly, the animation could have been specified as
188
+
Note that above animation specification is that of the `spring` preset.
189
+
Accordingly, the animation could have been specified as
0 commit comments