Skip to content

Commit d469ec8

Browse files
authored
Merge pull request #313 from silvenon/docs-timing
Add note about animation timing in the docs
2 parents 7c414c9 + 8e989dd commit d469ec8

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

src/Transition.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,18 @@ export const EXITING = 'exiting';
5555
* component (such as by adding styles or classes) when it changes states.
5656
*
5757
* There are 4 main states a Transition can be in:
58-
* - `entering`
59-
* - `entered`
60-
* - `exiting`
61-
* - `exited`
58+
* - `'entering'`
59+
* - `'entered'`
60+
* - `'exiting'`
61+
* - `'exited'`
6262
*
6363
* Transition state is toggled via the `in` prop. When `true` the component begins the
6464
* "Enter" stage. During this stage, the component will shift from its current transition state,
6565
* to `'entering'` for the duration of the transition and then to the `'entered'` stage once
6666
* it's complete. Let's take the following example:
6767
*
6868
* ```jsx
69-
* state= { in: false };
69+
* state = { in: false };
7070
*
7171
* toggleEnterState = () => {
7272
* this.setState({ in: true });
@@ -87,6 +87,14 @@ export const EXITING = 'exiting';
8787
*
8888
* When `in` is `false` the same thing happens except the state moves from `'exiting'` to `'exited'`.
8989
*
90+
* ## Timing
91+
*
92+
* Timing is often the trickiest part of animation, mistakes can result in slight delays
93+
* that are hard to pin down. A common example is when you want to add an exit transition,
94+
* you should set the desired final styles when the state is `'exiting'`. That's when the
95+
* transition to those styles will start and, if you matched the `timeout` prop with the
96+
* CSS Transition duration, it will end exactly when the state changes to `'exited'`.
97+
*
9098
* > **Note**: For simpler transitions the `Transition` component might be enough, but
9199
* > take into account that it's platform-agnostic, while the `CSSTransition` component
92100
* > [forces reflows](https://github.com/reactjs/react-transition-group/blob/5007303e729a74be66a21c3e2205e4916821524b/src/CSSTransition.js#L208-L215)

www/src/css/bootstrap.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pre {
1616
}
1717

1818
code {
19+
padding: 0;
1920
background: transparent;
2021
color: $hue-3;
2122
a & {

www/src/pages/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ class Index extends React.Component {
2424
return (
2525
<div>
2626
<h1>React Transition Group</h1>
27+
<blockquote>
28+
<p>
29+
Exposes simple components useful for defining entering and exiting
30+
transitions. React Transition Group is not an animation library like{' '}
31+
<a href="https://github.com/chenglou/react-motion">React-Motion</a>,
32+
it does not animate styles by itself. Instead it exposes transition
33+
stages, manages classes and group elements and manipulates the DOM
34+
in useful ways, making the implementation of actual visual
35+
transitions much easier.
36+
</p>
37+
</blockquote>
2738
<section>
2839
<h2>Getting Started</h2>
2940
<p />

0 commit comments

Comments
 (0)