@@ -33,11 +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' ;
4037import { Subscription } from 'rxjs/Subscription' ;
38+ import { RxChain , filter , first , startWith , takeUntil } from '@angular/cdk/rxjs' ;
4139
4240
4341/** Throws an exception when two MdDrawer are matching the same position. */
@@ -118,7 +116,7 @@ export class MdDrawerContent implements AfterContentInit {
118116 host : {
119117 'class' : 'mat-drawer' ,
120118 '[@transform]' : '_animationState' ,
121- '(@transform.start)' : '_onAnimationStart()' ,
119+ '(@transform.start)' : '_onAnimationStart($event )' ,
122120 '(@transform.done)' : '_onAnimationEnd($event)' ,
123121 '(keydown)' : 'handleKeydown($event)' ,
124122 // must prevent the browser from aligning text based on value
@@ -178,7 +176,7 @@ export class MdDrawer implements AfterContentInit, OnDestroy {
178176 private _opened : boolean = false ;
179177
180178 /** Emits whenever the drawer has started animating. */
181- _animationStarted = new EventEmitter < void > ( ) ;
179+ _animationStarted = new EventEmitter < AnimationEvent > ( ) ;
182180
183181 /** Whether the drawer is animating. Used to prevent overlapping animations. */
184182 _isAnimating = false ;
@@ -321,9 +319,9 @@ export class MdDrawer implements AfterContentInit, OnDestroy {
321319 }
322320 }
323321
324- _onAnimationStart ( ) {
322+ _onAnimationStart ( event : AnimationEvent ) {
325323 this . _isAnimating = true ;
326- this . _animationStarted . emit ( ) ;
324+ this . _animationStarted . emit ( event ) ;
327325 }
328326
329327 _onAnimationEnd ( event : AnimationEvent ) {
@@ -444,13 +442,19 @@ export class MdDrawerContainer implements AfterContentInit, OnDestroy {
444442 * is properly hidden.
445443 */
446444 private _watchDrawerToggle ( drawer : MdDrawer ) : void {
447- takeUntil . call ( drawer . _animationStarted , this . _drawers . changes ) . subscribe ( ( ) => {
448- // Set the transition class on the container so that the animations occur. This should not
449- // be set initially because animations should only be triggered via a change in state.
450- this . _renderer . addClass ( this . _element . nativeElement , 'mat-drawer-transition' ) ;
451- this . _updateContentMargins ( ) ;
452- this . _changeDetectorRef . markForCheck ( ) ;
453- } ) ;
445+ RxChain . from ( drawer . _animationStarted )
446+ . call ( takeUntil , this . _drawers . changes )
447+ . call ( filter , ( event : AnimationEvent ) => event . fromState !== event . toState )
448+ . subscribe ( ( event : AnimationEvent ) => {
449+ // Set the transition class on the container so that the animations occur. This should not
450+ // be set initially because animations should only be triggered via a change in state.
451+ if ( event . toState !== 'open-instant' ) {
452+ this . _renderer . addClass ( this . _element . nativeElement , 'mat-drawer-transition' ) ;
453+ }
454+
455+ this . _updateContentMargins ( ) ;
456+ this . _changeDetectorRef . markForCheck ( ) ;
457+ } ) ;
454458
455459 if ( drawer . mode !== 'side' ) {
456460 takeUntil . call ( merge ( drawer . onOpen , drawer . onClose ) , this . _drawers . changes ) . subscribe ( ( ) =>
@@ -459,8 +463,8 @@ export class MdDrawerContainer implements AfterContentInit, OnDestroy {
459463 }
460464
461465 /**
462- * Subscribes to drawer onPositionChanged event in order to re-validate drawers when the position
463- * changes.
466+ * Subscribes to drawer onPositionChanged event in order to
467+ * re-validate drawers when the position changes.
464468 */
465469 private _watchDrawerPosition ( drawer : MdDrawer ) : void {
466470 if ( ! drawer ) {
0 commit comments