@@ -98,15 +98,18 @@ class DrawerChild extends React.Component<IDrawerChildProps, IState> {
98
98
} catch ( err ) { }
99
99
this . passive = passiveSupported ? { passive : false } : false ;
100
100
}
101
- const { open } = this . props ;
101
+ const { open, getContainer } = this . props ;
102
+ const container = getContainer && getContainer ( ) ;
102
103
this . drawerId = `drawer_id_${ Number (
103
104
( Date . now ( ) + Math . random ( ) )
104
105
. toString ( )
105
106
. replace ( '.' , Math . round ( Math . random ( ) * 9 ) . toString ( ) ) ,
106
107
) . toString ( 16 ) } `;
107
108
this . getLevelDom ( this . props ) ;
108
109
if ( open ) {
109
- currentDrawer [ this . drawerId ] = open ;
110
+ if ( container && container . parentNode === document . body ) {
111
+ currentDrawer [ this . drawerId ] = open ;
112
+ }
110
113
// 默认打开状态时推出 level;
111
114
this . openLevelTransition ( ) ;
112
115
this . forceUpdate ( ( ) => {
@@ -116,12 +119,15 @@ class DrawerChild extends React.Component<IDrawerChildProps, IState> {
116
119
}
117
120
118
121
public componentDidUpdate ( prevProps : IDrawerChildProps ) {
119
- const { open } = this . props ;
122
+ const { open, getContainer } = this . props ;
123
+ const container = getContainer && getContainer ( ) ;
120
124
if ( open !== prevProps . open ) {
121
125
if ( open ) {
122
126
this . domFocus ( ) ;
123
127
}
124
- currentDrawer [ this . drawerId ] = ! ! open ;
128
+ if ( container && container . parentNode === document . body ) {
129
+ currentDrawer [ this . drawerId ] = ! ! open ;
130
+ }
125
131
this . openLevelTransition ( ) ;
126
132
}
127
133
}
@@ -238,7 +244,7 @@ class DrawerChild extends React.Component<IDrawerChildProps, IState> {
238
244
) => {
239
245
const { placement, levelMove, duration, ease, showMask } = this . props ;
240
246
// router 切换时可能会导至页面失去滚动条,所以需要时时获取。
241
- this . levelDom . forEach ( ( dom ) => {
247
+ this . levelDom . forEach ( dom => {
242
248
dom . style . transition = `transform ${ duration } ${ ease } ` ;
243
249
addEventListener ( dom , transitionEnd , this . transitionEnd ) ;
244
250
let levelValue = open ? value : 0 ;
@@ -285,6 +291,7 @@ class DrawerChild extends React.Component<IDrawerChildProps, IState> {
285
291
const { getOpenCount, getContainer, showMask, open } = this . props ;
286
292
const container = getContainer && getContainer ( ) ;
287
293
const openCount = getOpenCount && getOpenCount ( ) ;
294
+ console . log ( openCount ) ;
288
295
// 处理 body 滚动
289
296
if ( container && container . parentNode === document . body && showMask ) {
290
297
const eventArray = [ 'touchstart' ] ;
@@ -436,7 +443,7 @@ class DrawerChild extends React.Component<IDrawerChildProps, IState> {
436
443
} ;
437
444
438
445
private getCurrentDrawerSome = ( ) =>
439
- ! Object . keys ( currentDrawer ) . some ( ( key ) => currentDrawer [ key ] ) ;
446
+ ! Object . keys ( currentDrawer ) . some ( key => currentDrawer [ key ] ) ;
440
447
441
448
private getLevelDom = ( { level, getContainer } : IDrawerChildProps ) => {
442
449
if ( windowIsUndefined ) {
@@ -460,8 +467,8 @@ class DrawerChild extends React.Component<IDrawerChildProps, IState> {
460
467
}
461
468
} ) ;
462
469
} else if ( level ) {
463
- dataToArray ( level ) . forEach ( ( key ) => {
464
- document . querySelectorAll ( key ) . forEach ( ( item ) => {
470
+ dataToArray ( level ) . forEach ( key => {
471
+ document . querySelectorAll ( key ) . forEach ( item => {
465
472
this . levelDom . push ( item ) ;
466
473
} ) ;
467
474
} ) ;
@@ -556,7 +563,7 @@ class DrawerChild extends React.Component<IDrawerChildProps, IState> {
556
563
className = { `${ prefixCls } -mask` }
557
564
onClick = { maskClosable ? onClose : undefined }
558
565
style = { maskStyle }
559
- ref = { ( c ) => {
566
+ ref = { c => {
560
567
this . maskDom = c as HTMLElement ;
561
568
} }
562
569
/>
@@ -569,13 +576,13 @@ class DrawerChild extends React.Component<IDrawerChildProps, IState> {
569
576
width : isNumeric ( width ) ? `${ width } px` : width ,
570
577
height : isNumeric ( height ) ? `${ height } px` : height ,
571
578
} }
572
- ref = { ( c ) => {
579
+ ref = { c => {
573
580
this . contentWrapper = c as HTMLElement ;
574
581
} }
575
582
>
576
583
< div
577
584
className = { `${ prefixCls } -content` }
578
- ref = { ( c ) => {
585
+ ref = { c => {
579
586
this . contentDom = c as HTMLElement ;
580
587
} }
581
588
onTouchStart = {
0 commit comments