@@ -37,6 +37,7 @@ class Drawer extends React.PureComponent {
37
37
levelDom = [ ] ;
38
38
39
39
contextDom = null ;
40
+ contextWrapDom = null ;
40
41
41
42
mousePos = null ;
42
43
@@ -65,15 +66,24 @@ class Drawer extends React.PureComponent {
65
66
66
67
componentDidUpdate ( ) {
67
68
this . renderPickerComponent ( this . getChildToRender ( ) ) ;
68
- this . contextDom = this . container . getElementsByClassName ( `${
69
- this . props . className } -content`) [ 0 ] ;
70
69
}
71
70
72
71
componentWillUnmount ( ) {
73
72
if ( this . container ) {
74
- ReactDOM . unmountComponentAtNode ( this . container ) ;
75
- this . container . parentNode . removeChild ( this . container ) ;
76
- this . container = null ;
73
+ this . setLevelDomTransform ( false , true ) ;
74
+ this . contextWrapDom . style . transform = '' ;
75
+ this . container . style . opacity = 0 ;
76
+ this . container . style . transition = 'opacity .3s' ;
77
+ const removeElemetFunc = ( ) => {
78
+ this . container . removeEventListener ( transitionEnd , removeElemetFunc ) ;
79
+ this . levelDom . forEach ( dom => {
80
+ dom . style . transition = '' ;
81
+ } ) ;
82
+ ReactDOM . unmountComponentAtNode ( this . container ) ;
83
+ this . container . parentNode . removeChild ( this . container ) ;
84
+ this . container = null ;
85
+ } ;
86
+ this . container . addEventListener ( transitionEnd , removeElemetFunc ) ;
77
87
}
78
88
}
79
89
@@ -207,10 +217,10 @@ class Drawer extends React.PureComponent {
207
217
}
208
218
}
209
219
210
- setLevelDomTransform = ( open ) => {
220
+ setLevelDomTransform = ( open , openTransition ) => {
211
221
const { placement, levelTransition, width, onChange } = this . props ;
212
222
this . levelDom . forEach ( dom => {
213
- if ( this . isOpenChange ) {
223
+ if ( this . isOpenChange || openTransition ) {
214
224
dom . style . transition = levelTransition ;
215
225
dom . addEventListener ( transitionEnd , this . trnasitionEnd ) ;
216
226
}
@@ -270,11 +280,20 @@ class Drawer extends React.PureComponent {
270
280
onTouchEnd = { ( e ) => { this . onTouchEnd ( e , true ) ; } }
271
281
onClick = { ( e ) => { this . onTouchEnd ( e , true ) ; } }
272
282
/>
273
- < div className = { `${ className } -content-wrapper` } style = { contentStyle } >
283
+ < div
284
+ className = { `${ className } -content-wrapper` }
285
+ style = { contentStyle }
286
+ ref = { ( c ) => {
287
+ this . contextWrapDom = c ;
288
+ } }
289
+ >
274
290
< div
275
291
className = { `${ className } -content` }
276
292
onTouchStart = { this . touchStart }
277
293
onTouchEnd = { this . touchEnd }
294
+ ref = { ( c ) => {
295
+ this . contextDom = c ;
296
+ } }
278
297
>
279
298
{ children }
280
299
</ div >
0 commit comments