@@ -14,32 +14,37 @@ import * as Styled from './styled';
1414
1515# Custom animations
1616
17- Everything is a custom animation in ` yubaba ` - all animations available out of the box will use the same methods to make them as you will.
18- There are two types of animations you can build with ` yubaba ` .
17+ Everything is a custom animation in ` yubaba ` -
18+ all animations that come with ` yubaba ` are built in exactly the same way you will build yours .
1919
2020## Lifecyle of an animation
2121
22- There are three lifecycles of an animation which you will see in the next few examples.
22+ There are three phases of an animation:
2323
24- 1 . ` beforeAnimate() ` - useful for prepping any animations or elements.
25- 2 . ` animate() ` - primary step for an animation.
26- 3 . ` afterAnimate() ` - useful for performing any extra animations after all primary animations have completed.
24+ 1 . ` beforeAnimate() ` used for any initial work needed for an animation, e.g. moving the destination ontop of the origin
25+ 2 . ` animate() ` used for the primary animation, e.g. moving from origin to destination
26+ 3 . ` afterAnimate() ` used for any supplementary post-animation animation, e.g. fading out
2727
28- Each lifecyle method has the same type signature:
28+ <br />
29+
30+ Each phase method has the same type signature:
2931
3032``` js
3133(elements , onFinish , setChildProps ) => JSX .Element | void ;
3234```
3335
3436> ** Tip -** Notice you can return JSX elements.
35- > If you do it will be created for that lifecycle - and reconciled from the result of every following lifecycle .
36- > This means if you return JSX elements in ` beforeAnimate() ` , but not in ` animate() ` or ` afterAnimate() ` - it will be removed!
37+ > If you do it will be created for that phase - and reconciled from the result of the following phases .
38+ > This means if you return JSX elements in ` beforeAnimate() ` but not in ` animate() ` or ` afterAnimate() ` it will be removed!
3739
38- ### elements
40+ ### What is ` elements `
3941
4042This contains snapshot data for the origin and destination elements.
4143Use this for doing any dynamic calculation for your animation.
4244
45+ > ** Tip -** Notice there is a ` render ` property in origin and destination -
46+ > this is the render prop that consumers pass through which you can use to create the same element if needed!
47+
4348``` js
4449{
4550 origin: {
@@ -59,16 +64,15 @@ Use this for doing any dynamic calculation for your animation.
5964}
6065```
6166
62- > ** Tip -** You'll notice there is a ` render ` prop in there - this is the render prop
63- > that consumers pass through which you can use to create the same element if needed!
64- > You can also use the destination ` element ` to set style/classNames directly if needing that extra perf boost.
67+ > ** Tip -** You can use the destination ` element ` to set style/classNames directly for better performance -
68+ > but remember you'll be doing it outside of the React lifecycle.
6569
66- ### onFinish() arg
70+ ### What is ` onFinish() `
6771
68- Call this method when you've completed the lifecycle .
69- Animations will not continue to the next stage until all animations finish the current lifecycle .
72+ Call this method when you've completed the phase .
73+ Animations will not continue to the next stage until all animations finish the current phase .
7074
71- ### setChildProps() arg
75+ ### What is ` setChildProps() `
7276
7377This will set the wrapped child props.
7478
@@ -81,7 +85,7 @@ setChildProps({
8185
8286## Focal animations
8387
84- The first is a focal animation - which means animating the wrapped element .
88+ The first is a [ focal animation] ( /focal-animations ) .
8589We are going to make a custom animation that makes the target element _ do one full 360deg rotation_ .
8690
8791``` js
@@ -177,7 +181,7 @@ export default class OneFullRotation extends Component {
177181
178182### Composing animations
179183
180- Another amazing feature of ` yubaba ` is the ability to compose animations - with a small change we can compose the two.
184+ Composability is a primary feature of ` yubaba ` - with a small change we can compose the two animations together .
181185If we introduce [ Move] ( /move ) we can make the element rotate and move to the new destination.
182186
183187``` diff
@@ -221,11 +225,11 @@ beforeAnimate = (elements, onFinish, setChildProps) => {
221225
222226## Supporting animations
223227
224- Sometimes we want _ extra _ things to happen during an animation,
228+ Sometimes we want to [ support the primary focal animation] ( /supporting-animation ) ,
225229for example the [ Swipe] ( /swipe ) animation creates a new element that swipes over the screen.
226230
227231This is different to a regular focal animation because it _ creates_ new elements through the animation lifecycle.
228- We can do this by _ returning elements_ from the animation lifecycle methods .
232+ We can do this by _ returning elements_ from an animation phase .
229233
230234For this example let's make something similar to swipe except it starts from the middle of the screen.
231235
@@ -249,7 +253,7 @@ export default class SupportingAnimation extends React.Component {
249253 left: 0 ,
250254 right: 0 ,
251255 bottom: 0 ,
252- backgroundColor: ' black ' ,
256+ backgroundColor: ' #468cee ' ,
253257 zIndex: 9999999 ,
254258 transform: ' scaleX(0)' ,
255259 }}
@@ -271,7 +275,7 @@ export default class SupportingAnimation extends React.Component {
271275 left: 0 ,
272276 right: 0 ,
273277 bottom: 0 ,
274- backgroundColor: ' black ' ,
278+ backgroundColor: ' #468cee ' ,
275279 zIndex: 9999999 ,
276280 transform: ' none' ,
277281 transition: ' transform 400ms' ,
@@ -284,7 +288,7 @@ export default class SupportingAnimation extends React.Component {
284288 setTimeout (onFinish, 200 );
285289
286290 // After animations have finished we "fade out" the supplementary animation.
287- // It will be cleaned up (removed) after this lifecycle event .
291+ // It will be cleaned up (removed) after this phase .
288292 return (
289293 < div
290294 aria- hidden= " true"
@@ -294,7 +298,7 @@ export default class SupportingAnimation extends React.Component {
294298 left: 0 ,
295299 right: 0 ,
296300 bottom: 0 ,
297- backgroundColor: ' black ' ,
301+ backgroundColor: ' #468cee ' ,
298302 zIndex: 9999999 ,
299303 transform: ' none' ,
300304 transition: ' opacity 200ms' ,
0 commit comments