@@ -30,7 +30,6 @@ import {FocusTrapFactory, FocusTrap} from '../core/a11y/focus-trap';
30
30
import { ESCAPE } from '../core/keyboard/keycodes' ;
31
31
import { first } from '../core/rxjs/index' ;
32
32
import { DOCUMENT } from '@angular/platform-browser' ;
33
- import { merge } from 'rxjs/observable/merge' ;
34
33
35
34
36
35
/** Throws an exception when two MdSidenav are matching the same side. */
@@ -76,7 +75,7 @@ export class MdSidenavToggleResult {
76
75
host : {
77
76
'class' : 'mat-sidenav' ,
78
77
'[@transform]' : '_getAnimationState()' ,
79
- '(@transform.start)' : '_isAnimating = true ' ,
78
+ '(@transform.start)' : '_onAnimationStart() ' ,
80
79
'(@transform.done)' : '_onAnimationEnd($event)' ,
81
80
'(keydown)' : 'handleKeydown($event)' ,
82
81
// must prevent the browser from aligning text based on value
@@ -122,6 +121,9 @@ export class MdSidenav implements AfterContentInit, OnDestroy {
122
121
/** Whether the sidenav is opened. */
123
122
private _opened : boolean = false ;
124
123
124
+ /** Emits whenever the sidenav has started animating. */
125
+ _animationStarted = new EventEmitter < void > ( ) ;
126
+
125
127
/** Whether the sidenav is animating. Used to prevent overlapping animations. */
126
128
_isAnimating = false ;
127
129
@@ -255,6 +257,11 @@ export class MdSidenav implements AfterContentInit, OnDestroy {
255
257
return 'void' ;
256
258
}
257
259
260
+ _onAnimationStart ( ) {
261
+ this . _isAnimating = true ;
262
+ this . _animationStarted . emit ( ) ;
263
+ }
264
+
258
265
_onAnimationEnd ( event : AnimationEvent ) {
259
266
const { fromState, toState} = event ;
260
267
@@ -361,9 +368,7 @@ export class MdSidenavContainer implements AfterContentInit {
361
368
* is properly hidden.
362
369
*/
363
370
private _watchSidenavToggle ( sidenav : MdSidenav ) : void {
364
- merge ( sidenav . onOpenStart , sidenav . onCloseStart ) . subscribe ( ( ) => {
365
- this . _changeDetectorRef . markForCheck ( ) ;
366
- } ) ;
371
+ sidenav . _animationStarted . subscribe ( ( ) => this . _changeDetectorRef . markForCheck ( ) ) ;
367
372
368
373
if ( sidenav . mode !== 'side' ) {
369
374
sidenav . onOpen . subscribe ( ( ) => this . _setContainerClass ( true ) ) ;
@@ -399,9 +404,7 @@ export class MdSidenavContainer implements AfterContentInit {
399
404
this . _start = this . _end = null ;
400
405
401
406
// Ensure that we have at most one start and one end sidenav.
402
- // NOTE: We must call toArray on _sidenavs even though it's iterable
403
- // (see https://github.com/Microsoft/TypeScript/issues/3164).
404
- for ( let sidenav of this . _sidenavs . toArray ( ) ) {
407
+ this . _sidenavs . forEach ( sidenav => {
405
408
if ( sidenav . align == 'end' ) {
406
409
if ( this . _end != null ) {
407
410
throwMdDuplicatedSidenavError ( 'end' ) ;
@@ -413,7 +416,7 @@ export class MdSidenavContainer implements AfterContentInit {
413
416
}
414
417
this . _start = sidenav ;
415
418
}
416
- }
419
+ } ) ;
417
420
418
421
this . _right = this . _left = null ;
419
422
0 commit comments