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