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
@@ -78,46 +37,15 @@ In this component, when a new item is added to `ReactCSSTransitionGroup` it will
78
37
79
38
You can use these classes to trigger a CSS animation or transition. For example, try adding this CSS and adding a new list item:
80
39
81
-
```css
82
-
.example-enter {
83
-
opacity: 0.01;
84
-
}
85
-
86
-
.example-enter.example-enter-active {
87
-
opacity: 1;
88
-
transition: opacity 500msease-in;
89
-
}
90
-
91
-
.example-leave {
92
-
opacity: 1;
93
-
}
94
-
95
-
.example-leave.example-leave-active {
96
-
opacity: 0.01;
97
-
transition: opacity 300msease-in;
98
-
}
99
-
```
40
+
`embed:animation/animation.css`
100
41
101
42
You'll notice that animation durations need to be specified in both the CSS and the render method; this tells React when to remove the animation classes from the element and -- if it's leaving -- when to remove the element from the DOM.
102
43
103
44
### Animate Initial Mounting
104
45
105
46
`ReactCSSTransitionGroup` provides the optional prop `transitionAppear`, to add an extra transition phase at the initial mount of the component. There is generally no transition phase at the initial mount as the default value of `transitionAppear` is `false`. The following is an example which passes the prop `transitionAppear` with the value `true`.
106
47
107
-
```javascript{5-6}
108
-
render() {
109
-
return (
110
-
<ReactCSSTransitionGroup
111
-
transitionName="example"
112
-
transitionAppear={true}
113
-
transitionAppearTimeout={500}
114
-
transitionEnter={false}
115
-
transitionLeave={false}>
116
-
<h1>Fading at Initial Mount</h1>
117
-
</ReactCSSTransitionGroup>
118
-
);
119
-
}
120
-
```
48
+
`embed:animation/initial-mounting.js`
121
49
122
50
During the initial mount `ReactCSSTransitionGroup` will get the `example-appear` CSS class and the `example-appear-active` CSS class added in the next tick.
123
51
@@ -144,76 +72,21 @@ At the initial mount, all children of the `ReactCSSTransitionGroup` will `appear
144
72
145
73
It is also possible to use custom class names for each of the steps in your transitions. Instead of passing a string into transitionName you can pass an object containing either the `enter` and `leave` class names, or an object containing the `enter`, `enter-active`, `leave-active`, and `leave` class names. If only the enter and leave classes are provided, the enter-active and leave-active classes will be determined by appending '-active' to the end of the class name. Here are two examples using custom classes:
146
74
147
-
```javascript
148
-
// ...
149
-
<ReactCSSTransitionGroup
150
-
transitionName={ {
151
-
enter:'enter',
152
-
enterActive:'enterActive',
153
-
leave:'leave',
154
-
leaveActive:'leaveActive',
155
-
appear:'appear',
156
-
appearActive:'appearActive'
157
-
} }>
158
-
{item}
159
-
</ReactCSSTransitionGroup>
160
-
161
-
<ReactCSSTransitionGroup
162
-
transitionName={ {
163
-
enter:'enter',
164
-
leave:'leave',
165
-
appear:'appear'
166
-
} }>
167
-
{item2}
168
-
</ReactCSSTransitionGroup>
169
-
// ...
170
-
```
75
+
`embed:animation/custom-classes.js`
171
76
172
77
### Animation Group Must Be Mounted To Work
173
78
174
79
In order for it to apply transitions to its children, the `ReactCSSTransitionGroup` must already be mounted in the DOM or the prop `transitionAppear` must be set to `true`.
175
80
176
81
The example below would **not** work, because the `ReactCSSTransitionGroup` is being mounted along with the new item, instead of the new item being mounted within it. Compare this to the [Getting Started](#getting-started) section above to see the difference.
In the example above, we rendered a list of items into `ReactCSSTransitionGroup`. However, the children of `ReactCSSTransitionGroup` can also be one or zero items. This makes it possible to animate a single element entering or leaving. Similarly, you can animate a new element replacing the current element. For example, we can implement a simple image carousel like this:
200
88
201
-
```javascript{10}
202
-
import ReactCSSTransitionGroup from 'react-addons-css-transition-group';
0 commit comments