-
Notifications
You must be signed in to change notification settings - Fork 182
/
Copy pathAnimation.js
51 lines (41 loc) · 1.04 KB
/
Animation.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
* Animation Component For react-reveal
*
* Copyright © Roman Nosov 2017
*
* This source code is licensed under the MIT license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
import React from 'react';
import { element, instanceOf, object } from 'prop-types';
import Stepper from './lib/Stepper';
const
propTypes = {
steps: instanceOf(Stepper).isRequired,
children: element.isRequired,
},
defaultProps = {
},
childContextTypes = {
stepper: object,
};
class Animation extends React.Component {
constructor(props) {
super(props);
this.stepper = props.steps;
}
getChildContext() {
return { stepper: this.stepper };
}
static step(...args) {
return new Stepper().step(...args);
}
render() {
const { steps, children, ...props } = this.props;
return React.cloneElement(React.Children.only(children), props);
}
}
Animation.propTypes = propTypes;
Animation.defaultProps = defaultProps;
Animation.childContextTypes = childContextTypes;
export default Animation;