This repository was archived by the owner on Apr 11, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ export default class Expand extends React.Component {
17
17
] ) ,
18
18
className : React . PropTypes . string ,
19
19
collapseDuration : React . PropTypes . number ,
20
+ componentDidExpand : React . PropTypes . func ,
21
+ componentWillExpand : React . PropTypes . func ,
20
22
expandDuration : React . PropTypes . number ,
21
23
style : React . PropTypes . object
22
24
}
Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ export default class ExpandChild extends React.Component {
12
12
React . PropTypes . node
13
13
] ) ,
14
14
collapseDuration : React . PropTypes . number ,
15
+ componentDidExpand : React . PropTypes . func ,
16
+ componentWillExpand : React . PropTypes . func ,
15
17
expandDuration : React . PropTypes . number
16
18
}
17
19
@@ -76,16 +78,33 @@ export default class ExpandChild extends React.Component {
76
78
}
77
79
78
80
componentWillEnter ( done ) {
79
- const { animateOnExpand, expandDuration } = this . props ;
81
+ const {
82
+ animateOnExpand,
83
+ componentDidExpand,
84
+ componentWillExpand,
85
+ expandDuration
86
+ } = this . props ;
87
+
80
88
const maxHeight = this . componentHeight ( ) ;
81
89
const calc = ( progress ) => maxHeight * progress ;
82
90
83
91
this . style = { height : 0 } ;
84
92
93
+ const callback = ( ) => {
94
+ if ( componentDidExpand ) {
95
+ componentDidExpand ( ) ;
96
+ }
97
+ done ( ) ;
98
+ } ;
99
+
100
+ if ( componentWillExpand ) {
101
+ componentWillExpand ( ) ;
102
+ }
103
+
85
104
if ( animateOnExpand ) {
86
- this . animate ( calc , expandDuration , done ) ;
105
+ this . animate ( calc , expandDuration , callback ) ;
87
106
} else {
88
- done ( ) ;
107
+ callback ( ) ;
89
108
}
90
109
}
91
110
You can’t perform that action at this time.
0 commit comments