@@ -33,10 +33,8 @@ 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 { RxChain , filter , first , startWith , takeUntil } from '@angular/cdk/rxjs' ;
4038
4139
4240/** Throws an exception when two MatDrawer are matching the same position. */
@@ -114,7 +112,7 @@ export class MatDrawerContent implements AfterContentInit {
114112 host : {
115113 'class' : 'mat-drawer' ,
116114 '[@transform]' : '_animationState' ,
117- '(@transform.start)' : '_onAnimationStart()' ,
115+ '(@transform.start)' : '_onAnimationStart($event )' ,
118116 '(@transform.done)' : '_onAnimationEnd($event)' ,
119117 '(keydown)' : 'handleKeydown($event)' ,
120118 // must prevent the browser from aligning text based on value
@@ -174,7 +172,7 @@ export class MatDrawer implements AfterContentInit, OnDestroy {
174172 private _opened : boolean = false ;
175173
176174 /** Emits whenever the drawer has started animating. */
177- _animationStarted = new EventEmitter < void > ( ) ;
175+ _animationStarted = new EventEmitter < AnimationEvent > ( ) ;
178176
179177 /** Whether the drawer is animating. Used to prevent overlapping animations. */
180178 _isAnimating = false ;
@@ -317,9 +315,9 @@ export class MatDrawer implements AfterContentInit, OnDestroy {
317315 }
318316 }
319317
320- _onAnimationStart ( ) {
318+ _onAnimationStart ( event : AnimationEvent ) {
321319 this . _isAnimating = true ;
322- this . _animationStarted . emit ( ) ;
320+ this . _animationStarted . emit ( event ) ;
323321 }
324322
325323 _onAnimationEnd ( event : AnimationEvent ) {
@@ -448,13 +446,19 @@ export class MatDrawerContainer implements AfterContentInit, OnDestroy {
448446 * is properly hidden.
449447 */
450448 private _watchDrawerToggle ( drawer : MatDrawer ) : void {
451- takeUntil . call ( drawer . _animationStarted , this . _drawers . changes ) . subscribe ( ( ) => {
452- // Set the transition class on the container so that the animations occur. This should not
453- // be set initially because animations should only be triggered via a change in state.
454- this . _renderer . addClass ( this . _element . nativeElement , 'mat-drawer-transition' ) ;
455- this . _updateContentMargins ( ) ;
456- this . _changeDetectorRef . markForCheck ( ) ;
457- } ) ;
449+ RxChain . from ( drawer . _animationStarted )
450+ . call ( takeUntil , this . _drawers . changes )
451+ . call ( filter , ( event : AnimationEvent ) => event . fromState !== event . toState )
452+ . subscribe ( ( event : AnimationEvent ) => {
453+ // Set the transition class on the container so that the animations occur. This should not
454+ // be set initially because animations should only be triggered via a change in state.
455+ if ( event . toState !== 'open-instant' ) {
456+ this . _renderer . addClass ( this . _element . nativeElement , 'mat-drawer-transition' ) ;
457+ }
458+
459+ this . _updateContentMargins ( ) ;
460+ this . _changeDetectorRef . markForCheck ( ) ;
461+ } ) ;
458462
459463 if ( drawer . mode !== 'side' ) {
460464 takeUntil . call ( merge ( drawer . onOpen , drawer . onClose ) , this . _drawers . changes ) . subscribe ( ( ) =>
@@ -463,8 +467,8 @@ export class MatDrawerContainer implements AfterContentInit, OnDestroy {
463467 }
464468
465469 /**
466- * Subscribes to drawer onPositionChanged event in order to re-validate drawers when the position
467- * changes.
470+ * Subscribes to drawer onPositionChanged event in order to
471+ * re-validate drawers when the position changes.
468472 */
469473 private _watchDrawerPosition ( drawer : MatDrawer ) : void {
470474 if ( ! drawer ) {
0 commit comments