@@ -2,7 +2,6 @@ import * as React from 'react';
22import * as ReactDOM from 'react-dom' ;
33import KeyCode from 'rc-util/lib/KeyCode' ;
44import contains from 'rc-util/lib/Dom/contains' ;
5- import switchScrollingEffect from 'rc-util/lib/switchScrollingEffect' ;
65import Animate from 'rc-animate' ;
76import LazyRenderBox from './LazyRenderBox' ;
87import IDialogPropTypes from './IDialogPropTypes' ;
@@ -45,17 +44,9 @@ function offset(el: any) {
4544 return pos ;
4645}
4746
48- // https://github.com/ant-design/ant-design/issues/19340
49- // https://github.com/ant-design/ant-design/issues/19332
50- interface ICacheOverflow {
51- overflowX ?: string ;
52- overflowY ?: string ;
53- overflow ?: string ;
54- }
55- let cacheOverflow : ICacheOverflow = { } ;
56-
5747export interface IDialogChildProps extends IDialogPropTypes {
5848 getOpenCount : ( ) => number ;
49+ switchScrollingEffect ?: ( ) => void ;
5950}
6051
6152export default class Dialog extends React . Component < IDialogChildProps , any > {
@@ -81,10 +72,12 @@ export default class Dialog extends React.Component<IDialogChildProps, any> {
8172 private sentinelEnd : HTMLElement ;
8273 private dialogMouseDown : boolean ;
8374 private timeoutId : number ;
75+ private switchScrollingEffect : ( ) => void ;
8476
8577 constructor ( props : IDialogChildProps ) {
8678 super ( props ) ;
8779 this . titleId = `rcDialogTitle${ uuid ++ } ` ;
80+ this . switchScrollingEffect = props . switchScrollingEffect || ( ( ) => { } ) ;
8881 }
8982
9083 componentDidMount ( ) {
@@ -377,39 +370,6 @@ export default class Dialog extends React.Component<IDialogChildProps, any> {
377370 return transitionName ;
378371 }
379372
380- switchScrollingEffect = ( ) => {
381- const { getOpenCount } = this . props ;
382- const openCount = getOpenCount ( ) ;
383-
384- if ( openCount === 1 ) {
385- if ( cacheOverflow . hasOwnProperty ( 'overflowX' ) ) {
386- return ;
387- }
388- cacheOverflow = {
389- overflowX : document . body . style . overflowX ,
390- overflowY : document . body . style . overflowY ,
391- overflow : document . body . style . overflow ,
392- } as ICacheOverflow ;
393- switchScrollingEffect ( ) ;
394- // Must be set after switchScrollingEffect
395- document . body . style . overflow = 'hidden' ;
396- } else if ( ! openCount ) {
397- // IE browser doesn't merge overflow style, need to set it separately
398- // https://github.com/ant-design/ant-design/issues/19393
399- if ( cacheOverflow . overflow !== undefined ) {
400- document . body . style . overflow = cacheOverflow . overflow ;
401- }
402- if ( cacheOverflow . overflowX !== undefined ) {
403- document . body . style . overflowX = cacheOverflow . overflowX ;
404- }
405- if ( cacheOverflow . overflowY !== undefined ) {
406- document . body . style . overflowY = cacheOverflow . overflowY ;
407- }
408- cacheOverflow = { } ;
409- switchScrollingEffect ( true ) ;
410- }
411- }
412-
413373 close = ( e : any ) => {
414374 const { onClose } = this . props ;
415375 if ( onClose ) {
0 commit comments