@@ -33,10 +33,9 @@ import {
3333} from '@angular/core' ;
3434import { DOCUMENT } from '@angular/platform-browser' ;
3535import { merge } from 'rxjs/observable/merge' ;
36- import { first } from 'rxjs/operator/first' ;
37- import { startWith } from 'rxjs/operator/startWith' ;
38- import { takeUntil } from 'rxjs/operator/takeUntil' ;
3936import { Subject } from 'rxjs/Subject' ;
37+ import { Subscription } from 'rxjs/Subscription' ;
38+ import { RxChain , filter , first , startWith , takeUntil } from '@angular/cdk/rxjs' ;
4039
4140
4241/** Throws an exception when two MatDrawer are matching the same position. */
@@ -117,7 +116,7 @@ export class MatDrawerContent implements AfterContentInit {
117116 host : {
118117 'class' : 'mat-drawer' ,
119118 '[@transform]' : '_animationState' ,
120- '(@transform.start)' : '_onAnimationStart()' ,
119+ '(@transform.start)' : '_onAnimationStart($event )' ,
121120 '(@transform.done)' : '_onAnimationEnd($event)' ,
122121 '(keydown)' : 'handleKeydown($event)' ,
123122 // must prevent the browser from aligning text based on value
@@ -177,7 +176,7 @@ export class MatDrawer implements AfterContentInit, OnDestroy {
177176 private _opened : boolean = false ;
178177
179178 /** Emits whenever the drawer has started animating. */
180- _animationStarted = new EventEmitter < void > ( ) ;
179+ _animationStarted = new EventEmitter < AnimationEvent > ( ) ;
181180
182181 /** Whether the drawer is animating. Used to prevent overlapping animations. */
183182 _isAnimating = false ;
@@ -320,9 +319,9 @@ export class MatDrawer implements AfterContentInit, OnDestroy {
320319 }
321320 }
322321
323- _onAnimationStart ( ) {
322+ _onAnimationStart ( event : AnimationEvent ) {
324323 this . _isAnimating = true ;
325- this . _animationStarted . emit ( ) ;
324+ this . _animationStarted . emit ( event ) ;
326325 }
327326
328327 _onAnimationEnd ( event : AnimationEvent ) {
@@ -453,13 +452,19 @@ export class MatDrawerContainer implements AfterContentInit, OnDestroy {
453452 * is properly hidden.
454453 */
455454 private _watchDrawerToggle ( drawer : MatDrawer ) : void {
456- takeUntil . call ( drawer . _animationStarted , this . _drawers . changes ) . subscribe ( ( ) => {
457- // Set the transition class on the container so that the animations occur. This should not
458- // be set initially because animations should only be triggered via a change in state.
459- this . _renderer . addClass ( this . _element . nativeElement , 'mat-drawer-transition' ) ;
460- this . _updateContentMargins ( ) ;
461- this . _changeDetectorRef . markForCheck ( ) ;
462- } ) ;
455+ RxChain . from ( drawer . _animationStarted )
456+ . call ( takeUntil , this . _drawers . changes )
457+ . call ( filter , ( event : AnimationEvent ) => event . fromState !== event . toState )
458+ . subscribe ( ( event : AnimationEvent ) => {
459+ // Set the transition class on the container so that the animations occur. This should not
460+ // be set initially because animations should only be triggered via a change in state.
461+ if ( event . toState !== 'open-instant' ) {
462+ this . _renderer . addClass ( this . _element . nativeElement , 'mat-drawer-transition' ) ;
463+ }
464+
465+ this . _updateContentMargins ( ) ;
466+ this . _changeDetectorRef . markForCheck ( ) ;
467+ } ) ;
463468
464469 if ( drawer . mode !== 'side' ) {
465470 takeUntil . call ( merge ( drawer . onOpen , drawer . onClose ) , this . _drawers . changes ) . subscribe ( ( ) =>
@@ -468,8 +473,8 @@ export class MatDrawerContainer implements AfterContentInit, OnDestroy {
468473 }
469474
470475 /**
471- * Subscribes to drawer onPositionChanged event in order to re-validate drawers when the position
472- * changes.
476+ * Subscribes to drawer onPositionChanged event in order to
477+ * re-validate drawers when the position changes.
473478 */
474479 private _watchDrawerPosition ( drawer : MatDrawer ) : void {
475480 if ( ! drawer ) {
0 commit comments