@@ -364,7 +364,6 @@ export class MatDrawer implements AfterViewInit, OnDestroy {
364364 } ) ;
365365 }
366366 } ) ,
367- renderer . listen ( element , 'transitionrun' , this . _handleTransitionEvent ) ,
368367 renderer . listen ( element , 'transitionend' , this . _handleTransitionEvent ) ,
369368 renderer . listen ( element , 'transitioncancel' , this . _handleTransitionEvent ) ,
370369 ] ;
@@ -572,6 +571,11 @@ export class MatDrawer implements AfterViewInit, OnDestroy {
572571 // Note: it's important to set this as early as possible,
573572 // otherwise the animation can look glitchy in some cases.
574573 this . _setIsAnimating ( true ) ;
574+
575+ // Previously we dispatched this in a `transitionrun` event, but it might not fire
576+ // if the element is hidden (see #32992). Since this event is load-bearing for the
577+ // margin calculations, we need it to fire consistently.
578+ setTimeout ( ( ) => this . _animationStarted . next ( ) ) ;
575579 } else {
576580 // Simulate the animation events if animations are disabled.
577581 setTimeout ( ( ) => {
@@ -646,17 +650,13 @@ export class MatDrawer implements AfterViewInit, OnDestroy {
646650
647651 if ( event . target === element ) {
648652 this . _ngZone . run ( ( ) => {
649- if ( event . type === 'transitionrun' ) {
650- this . _animationStarted . next ( event ) ;
651- } else {
652- // Don't toggle the animating state on `transitioncancel` since another animation should
653- // start afterwards. This prevents the drawer from blinking if an animation is interrupted.
654- if ( event . type === 'transitionend' ) {
655- this . _setIsAnimating ( false ) ;
656- }
657-
658- this . _animationEnd . next ( event ) ;
653+ // Don't toggle the animating state on `transitioncancel` since another animation should
654+ // start afterwards. This prevents the drawer from blinking if an animation is interrupted.
655+ if ( event . type === 'transitionend' ) {
656+ this . _setIsAnimating ( false ) ;
659657 }
658+
659+ this . _animationEnd . next ( event ) ;
660660 } ) ;
661661 }
662662 } ;
@@ -941,6 +941,7 @@ export class MatDrawerContainer implements AfterContentInit, DoCheck, OnDestroy
941941 * is properly hidden.
942942 */
943943 private _watchDrawerToggle ( drawer : MatDrawer ) : void {
944+ //
944945 drawer . _animationStarted . pipe ( takeUntil ( this . _drawers . changes ) ) . subscribe ( ( ) => {
945946 this . updateContentMargins ( ) ;
946947 this . _changeDetectorRef . markForCheck ( ) ;
0 commit comments