@@ -33,11 +33,9 @@ import {
33
33
} from '@angular/core' ;
34
34
import { DOCUMENT } from '@angular/platform-browser' ;
35
35
import { 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' ;
39
36
import { Subject } from 'rxjs/Subject' ;
40
37
import { Subscription } from 'rxjs/Subscription' ;
38
+ import { RxChain , filter , first , startWith , takeUntil } from '@angular/cdk/rxjs' ;
41
39
42
40
43
41
/** Throws an exception when two MdDrawer are matching the same position. */
@@ -118,7 +116,7 @@ export class MdDrawerContent implements AfterContentInit {
118
116
host : {
119
117
'class' : 'mat-drawer' ,
120
118
'[@transform]' : '_animationState' ,
121
- '(@transform.start)' : '_onAnimationStart()' ,
119
+ '(@transform.start)' : '_onAnimationStart($event )' ,
122
120
'(@transform.done)' : '_onAnimationEnd($event)' ,
123
121
'(keydown)' : 'handleKeydown($event)' ,
124
122
// must prevent the browser from aligning text based on value
@@ -178,7 +176,7 @@ export class MdDrawer implements AfterContentInit, OnDestroy {
178
176
private _opened : boolean = false ;
179
177
180
178
/** Emits whenever the drawer has started animating. */
181
- _animationStarted = new EventEmitter < void > ( ) ;
179
+ _animationStarted = new EventEmitter < AnimationEvent > ( ) ;
182
180
183
181
/** Whether the drawer is animating. Used to prevent overlapping animations. */
184
182
_isAnimating = false ;
@@ -321,9 +319,9 @@ export class MdDrawer implements AfterContentInit, OnDestroy {
321
319
}
322
320
}
323
321
324
- _onAnimationStart ( ) {
322
+ _onAnimationStart ( event : AnimationEvent ) {
325
323
this . _isAnimating = true ;
326
- this . _animationStarted . emit ( ) ;
324
+ this . _animationStarted . emit ( event ) ;
327
325
}
328
326
329
327
_onAnimationEnd ( event : AnimationEvent ) {
@@ -444,13 +442,19 @@ export class MdDrawerContainer implements AfterContentInit, OnDestroy {
444
442
* is properly hidden.
445
443
*/
446
444
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
+ } ) ;
454
458
455
459
if ( drawer . mode !== 'side' ) {
456
460
takeUntil . call ( merge ( drawer . onOpen , drawer . onClose ) , this . _drawers . changes ) . subscribe ( ( ) =>
@@ -459,8 +463,8 @@ export class MdDrawerContainer implements AfterContentInit, OnDestroy {
459
463
}
460
464
461
465
/**
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.
464
468
*/
465
469
private _watchDrawerPosition ( drawer : MdDrawer ) : void {
466
470
if ( ! drawer ) {
0 commit comments