@@ -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. */
@@ -117,7 +115,7 @@ export class MatDrawerContent implements AfterContentInit {
117115 host : {
118116 'class' : 'mat-drawer' ,
119117 '[@transform]' : '_animationState' ,
120- '(@transform.start)' : '_onAnimationStart()' ,
118+ '(@transform.start)' : '_onAnimationStart($event )' ,
121119 '(@transform.done)' : '_onAnimationEnd($event)' ,
122120 '(keydown)' : 'handleKeydown($event)' ,
123121 // must prevent the browser from aligning text based on value
@@ -177,7 +175,7 @@ export class MatDrawer implements AfterContentInit, OnDestroy {
177175 private _opened : boolean = false ;
178176
179177 /** Emits whenever the drawer has started animating. */
180- _animationStarted = new EventEmitter < void > ( ) ;
178+ _animationStarted = new EventEmitter < AnimationEvent > ( ) ;
181179
182180 /** Whether the drawer is animating. Used to prevent overlapping animations. */
183181 _isAnimating = false ;
@@ -320,9 +318,9 @@ export class MatDrawer implements AfterContentInit, OnDestroy {
320318 }
321319 }
322320
323- _onAnimationStart ( ) {
321+ _onAnimationStart ( event : AnimationEvent ) {
324322 this . _isAnimating = true ;
325- this . _animationStarted . emit ( ) ;
323+ this . _animationStarted . emit ( event ) ;
326324 }
327325
328326 _onAnimationEnd ( event : AnimationEvent ) {
@@ -453,13 +451,19 @@ export class MatDrawerContainer implements AfterContentInit, OnDestroy {
453451 * is properly hidden.
454452 */
455453 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- } ) ;
454+ RxChain . from ( drawer . _animationStarted )
455+ . call ( takeUntil , this . _drawers . changes )
456+ . call ( filter , ( event : AnimationEvent ) => event . fromState !== event . toState )
457+ . subscribe ( ( event : AnimationEvent ) => {
458+ // Set the transition class on the container so that the animations occur. This should not
459+ // be set initially because animations should only be triggered via a change in state.
460+ if ( event . toState !== 'open-instant' ) {
461+ this . _renderer . addClass ( this . _element . nativeElement , 'mat-drawer-transition' ) ;
462+ }
463+
464+ this . _updateContentMargins ( ) ;
465+ this . _changeDetectorRef . markForCheck ( ) ;
466+ } ) ;
463467
464468 if ( drawer . mode !== 'side' ) {
465469 takeUntil . call ( merge ( drawer . onOpen , drawer . onClose ) , this . _drawers . changes ) . subscribe ( ( ) =>
@@ -468,8 +472,8 @@ export class MatDrawerContainer implements AfterContentInit, OnDestroy {
468472 }
469473
470474 /**
471- * Subscribes to drawer onPositionChanged event in order to re-validate drawers when the position
472- * changes.
475+ * Subscribes to drawer onPositionChanged event in order to
476+ * re-validate drawers when the position changes.
473477 */
474478 private _watchDrawerPosition ( drawer : MatDrawer ) : void {
475479 if ( ! drawer ) {
0 commit comments