/
scale-in.jsx
66 lines (55 loc) · 1.32 KB
/
scale-in.jsx
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
const React = require('react/addons');
const ReactTransitionGroup = React.addons.TransitionGroup;
const StylePropable = require('../mixins/style-propable');
const ScaleInChild = require('./scale-in-child');
const ScaleIn = React.createClass({
mixins: [StylePropable],
propTypes: {
childStyle: React.PropTypes.object,
enterDelay: React.PropTypes.number,
maxScale: React.PropTypes.number,
minScale: React.PropTypes.number,
},
getDefaultProps() {
return {
enterDelay: 0,
};
},
render() {
const {
children,
childStyle,
enterDelay,
maxScale,
minScale,
style,
...other,
} = this.props;
const mergedRootStyles = this.mergeAndPrefix({
position: 'relative',
overflow: 'hidden',
height: '100%',
}, style);
const newChildren = React.Children.map(children, (child) => {
return (
<ScaleInChild
key={child.key}
enterDelay={enterDelay}
maxScale={maxScale}
minScale={minScale}
style={childStyle}>
{child}
</ScaleInChild>
);
});
return (
<ReactTransitionGroup
{...other}
style={mergedRootStyles}
component="div">
{newChildren}
</ReactTransitionGroup>
);
},
});
module.exports = ScaleIn;