@@ -53,6 +53,9 @@ export class OverlayRef implements PortalOutlet, OverlayReference {
5353 } ;
5454 } ) ;
5555
56+ /** Whether animations are disabled for this overlay. */
57+ private readonly _animationsDisabled : boolean ;
58+
5659 /** Stream of keydown events dispatched to this overlay. */
5760 _keydownEvents = new Subject < KeyboardEvent > ( ) ;
5861
@@ -68,13 +71,19 @@ export class OverlayRef implements PortalOutlet, OverlayReference {
6871 private _keyboardDispatcher : OverlayKeyboardDispatcher ,
6972 private _document : Document ,
7073 // @breaking -change 8.0.0 `_location` parameter to be made required.
71- private _location ?: Location ) {
74+ private _location ?: Location ,
75+ /**
76+ * @deprecated `animationMode` parameter to be made required.
77+ * @breaking -change 8.0.0
78+ */
79+ animationMode ?: string ) {
7280
7381 if ( _config . scrollStrategy ) {
7482 _config . scrollStrategy . attach ( this ) ;
7583 }
7684
7785 this . _positionStrategy = _config . positionStrategy ;
86+ this . _animationsDisabled = animationMode === 'NoopAnimations' ;
7887 }
7988
8089 /** The overlay's HTML element */
@@ -351,6 +360,10 @@ export class OverlayRef implements PortalOutlet, OverlayReference {
351360 this . _backdropElement = this . _document . createElement ( 'div' ) ;
352361 this . _backdropElement . classList . add ( 'cdk-overlay-backdrop' ) ;
353362
363+ if ( this . _animationsDisabled ) {
364+ this . _backdropElement . classList . add ( 'cdk-overlay-backdrop-transition-disabled' ) ;
365+ }
366+
354367 if ( this . _config . backdropClass ) {
355368 this . _toggleClasses ( this . _backdropElement , this . _config . backdropClass , true ) ;
356369 }
@@ -420,20 +433,26 @@ export class OverlayRef implements PortalOutlet, OverlayReference {
420433 clearTimeout ( timeoutId ) ;
421434 } ;
422435
423- backdropToDetach . classList . remove ( 'cdk-overlay-backdrop-showing' ) ;
436+ if ( this . _animationsDisabled ) {
437+ // When the animations are disabled via the `NoopAnimationsModule`, we can be
438+ // fairly certain that they won't happen so we can remove the element immediately.
439+ finishDetach ( ) ;
440+ } else {
441+ backdropToDetach . classList . remove ( 'cdk-overlay-backdrop-showing' ) ;
424442
425- this . _ngZone . runOutsideAngular ( ( ) => {
426- backdropToDetach ! . addEventListener ( 'transitionend' , finishDetach ) ;
427- } ) ;
443+ this . _ngZone . runOutsideAngular ( ( ) => {
444+ backdropToDetach ! . addEventListener ( 'transitionend' , finishDetach ) ;
445+ } ) ;
428446
429- // If the backdrop doesn't have a transition, the `transitionend` event won't fire.
430- // In this case we make it unclickable and we try to remove it after a delay.
431- backdropToDetach . style . pointerEvents = 'none' ;
447+ // If the backdrop doesn't have a transition, the `transitionend` event won't fire.
448+ // In this case we make it unclickable and we try to remove it after a delay.
449+ backdropToDetach . style . pointerEvents = 'none' ;
432450
433- // Run this outside the Angular zone because there's nothing that Angular cares about.
434- // If it were to run inside the Angular zone, every test that used Overlay would have to be
435- // either async or fakeAsync.
436- timeoutId = this . _ngZone . runOutsideAngular ( ( ) => setTimeout ( finishDetach , 500 ) ) ;
451+ // Run this outside the Angular zone because there's nothing that Angular cares about.
452+ // If it were to run inside the Angular zone, every test that used Overlay would have to be
453+ // either async or fakeAsync.
454+ timeoutId = this . _ngZone . runOutsideAngular ( ( ) => setTimeout ( finishDetach , 500 ) ) ;
455+ }
437456 }
438457
439458 /** Toggles a single CSS class or an array of classes on an element. */
0 commit comments