Skip to content

Commit 8ff3418

Browse files
committed
Update demo and docs.
1 parent 143ee62 commit 8ff3418

File tree

7 files changed

+80
-22
lines changed

7 files changed

+80
-22
lines changed

.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@
155155
"no-multiple-empty-lines": [2, { // http://eslint.org/docs/rules/no-multiple-empty-lines
156156
"max": 2
157157
}],
158-
"no-nested-ternary": 2, // http://eslint.org/docs/rules/no-nested-ternary
158+
"no-nested-ternary": 0, // http://eslint.org/docs/rules/no-nested-ternary
159159
"no-new-object": 2, // http://eslint.org/docs/rules/no-new-object
160160
"no-spaced-func": 2, // http://eslint.org/docs/rules/no-spaced-func
161161
"no-trailing-spaces": 2, // http://eslint.org/docs/rules/no-trailing-spaces

CHANGELOG.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
### v3.0.0 (x May 2017)
1+
### v3.0.0 (27 August 2017)
22

3+
* [ENHANCEMENT] Treat a child rendering `null` as if there is no child; specifically helps avoid errors with RR4.
34
* [ENHANCEMENT] Maintain component callback refs by not overwriting with string refs similar to `react-transition-group`.
45
* [FEATURE] Only add the `isLeaving` prop to children if opted in with `notifyLeaving={true}` since it's
56
a departure from `react-transition-group` features.
67
* [ENHANCEMENT] Use `requestAnimationFrame` to queue the height transition rather than a timeout.
78
* [ENHANCEMENT] Handle the enter and leave animation of changes due to successive child updates before the current transition ends.
8-
* Clear the selection after transitions to avoid the child being selected after multiple clicks.
9-
* Entering child renders with absolute positioning since switching from relative to abs on a premature leave cancels the active enter animation.
10-
* Fix enter animation of absolutely positioned elements in Chrome not working by skipping one animation frame in the Child component.
11-
* Fix Edge glitch when render starts by always applying container `position`, `display` (use a `div`) and `overflow` styles.
9+
* [ENHANCEMENT] Clear the selection after transitions to avoid the child being selected after multiple clicks.
10+
* [ENHANCEMENT] Entering child renders with absolute positioning since switching from relative to abs on a premature leave cancels the active enter animation.
11+
* [ENHANCEMENT] Fix enter animation of absolutely positioned elements in Chrome not working by skipping one animation frame in the Child component.
12+
* [ENHANCEMENT] Fix Edge glitch when render starts by always applying container `position`, `display` (use a `div`) and `overflow` styles.
1213

1314
### v2.2.1 (29 April 2017)
1415

README.md

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ follows the exact same API as `ReactCSSTransitionGroup`, with support for `trans
3939
and `transitionAppear`. When the `key` of the child component changes, the previous component is animated out
4040
and the new component animated in. During this process:
4141

42-
- The leaving component continues to be rendered as usual with `static` positioning.
43-
- The entering component is positioned on top of the leaving component with `absolute` positioning.
42+
- All leaving components continue to be rendered; if the animation is slow there may be multiple components
43+
in the process of leaving.
44+
- The entering component is positioned on top of the leaving component(s) with `absolute` positioning.
4445
- The height of the container is set to that of the leaving component, and then immediately to that of the
4546
entering component. If the `transitionName` is a `String` the `{animation-name}-height` class name is applied
4647
to it, and if `transitionName` is an `Object` the `transitionName.height` class will be used if present.
@@ -145,6 +146,47 @@ the duration of the transition. In this case:
145146
See the live example [here](http://marnusw.github.io/react-css-transition-replace#fade-wait).
146147

147148

149+
### React-Router v4
150+
151+
Animated transitions of react-router v4 routes is supported with two caveats shown in the example below:
152+
153+
1. The current `location` must be applied to the `Switch` to force it to maintain the previous matched route on
154+
the leaving component.
155+
2. If the `Switch` might render `null`, i.e. there is no catch-all `"*"` route, the `Switch` must be wrapped in a
156+
`div` or similar for the leave transition to work; if not the previous component will disappear instantaneously
157+
when there is no match.
158+
159+
```javascript
160+
<Router>
161+
<div className="router-example">
162+
<ul>
163+
<li><Link to="/">Home</Link></li>
164+
<li><Link to="/one">One</Link></li>
165+
<li><Link to="/two">Two</Link></li>
166+
<li><Link to="/three">Three (no match)</Link></li>
167+
</ul>
168+
<Route render={({location}) => (
169+
<ReactCSSTransitionReplace
170+
transitionName="fade"
171+
transitionEnterTimeout={500}
172+
transitionLeaveTimeout={500}
173+
>
174+
<div key={location.pathname}>
175+
<Switch location={location}>
176+
<Route path="/" exact component={Home}/>
177+
<Route path="/one" component={One}/>
178+
<Route path="/two" component={Two}/>
179+
</Switch>
180+
</div>
181+
</ReactCSSTransitionReplace>
182+
)}/>
183+
</div>
184+
</Router>
185+
```
186+
187+
See the live example [here](http://marnusw.github.io/react-css-transition-replace#react-router-v4).
188+
189+
148190
### Hardware acceleration for smoother transitions
149191

150192
For smoother transitions hardware acceleration, which is achieved by using translate3d instead of the 2D

UPGRADE_GUIDE.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
# Upgrade Guide
22

3+
## 2.2.1 -> 3.0.0
4+
5+
Applying the `isLeaving` prop on leaving children is now an opt-in behaviour controlled
6+
by the `notifyLeaving` prop.
7+
8+
39
## 2.1.0 -> 2.2.0
410

511
The library has always had a bug causing subsequent changes while an animation is in
612
progress to be ignored. This has been fixed in v2.2.0. While the functioning of the
713
library is now technically more correct, this but may have been a feature used to
814
smooth over multiple transitions by some which will no longer be the case.
915

10-
If this causes problems it might be worthwhile to introduce a flag that could direct
11-
the component to ignore changes during transitions to restore the previous behaviour.
12-
1316

1417
## 1.3.0 -> 2.0.0
1518

@@ -20,7 +23,7 @@ You can pass `transitionName={{ height: 'my-height-className' }}` now, if
2023
you need to use a custom className (useful for `css-modules`).
2124

2225
The leaving component will receive `isLeaving={true}` prop during it's leaving transition.
23-
You can use it in your child components to prevent their rerendering during that period, for example.
26+
You can use it in your child components to prevent their re-rendering during that period, for example.
2427

2528

2629
## 1.0.x -> 1.1.0

demo/assets/styles.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ p {
1919
margin-bottom: 0;
2020
}
2121

22+
hr {
23+
border-color: #bbb;
24+
}
25+
2226
.examples > p {
2327
margin-bottom: 20px;
2428
}

demo/components/AnimatedRouter.jsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,13 @@ const AnimatedRouter = () => (
4242
transitionEnterTimeout={500}
4343
transitionLeaveTimeout={500}
4444
>
45-
<Switch key={location.pathname} location={location}>
46-
<Route path="/" exact component={Home}/>
47-
<Route path="/one" component={One}/>
48-
<Route path="/two" component={Two}/>
49-
</Switch>
45+
<div key={location.pathname}>
46+
<Switch location={location}>
47+
<Route path="/" exact component={Home}/>
48+
<Route path="/one" component={One}/>
49+
<Route path="/two" component={Two}/>
50+
</Switch>
51+
</div>
5052
</ReactCSSTransitionReplace>
5153
)}/>
5254

demo/components/Demo.jsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,19 +91,25 @@ class Demo extends React.Component {
9191
<img key="img1" src="img/vista1.jpg" width="600" height="235"/>
9292
</ContentAddRemove>
9393

94-
<h3 id="roll-up">Height and Width animation</h3>
95-
<p></p>
94+
<h3 id="height-and-width">Height and Width animation</h3>
95+
<p>By setting the <code>changeWidth</code> prop the container width is managed along with the height.
96+
This example realizes the same effect as above using this property and just a fade CSS animation.
97+
In this case the <code>height</code> class should configure the transition of both the height
98+
and width properties: <code>transition: height .5s ease-in-out, width .5s ease-in-out;</code>
99+
</p>
96100

97101
<ContentAddRemove
98102
transitionName="fade-fast" transitionEnterTimeout={500} transitionLeaveTimeout={500} changeWidth
99103
>
100104
<img key="img1" src="img/vista1.jpg" width="600" height="235"/>
101105
</ContentAddRemove>
102106

103-
<h3 id="react-router">React Router v4</h3>
104-
<p></p>
107+
<h3 id="react-router-v4">React Router v4</h3>
108+
<p>Animating React-Router v4 transitions is supported. See the <a
109+
href="https://github.com/marnusw/react-css-transition-replace#cross-fading-two-components"
110+
target="_blank">example</a> for details.</p>
105111

106-
<AnimatedRouter />
112+
<AnimatedRouter/>
107113
</div>
108114
</Grid>
109115
</div>

0 commit comments

Comments
 (0)