@@ -30,7 +30,6 @@ import {FocusTrapFactory, FocusTrap} from '../core/a11y/focus-trap';
3030import { ESCAPE } from '../core/keyboard/keycodes' ;
3131import { first } from '../core/rxjs/index' ;
3232import { DOCUMENT } from '@angular/platform-browser' ;
33- import { merge } from 'rxjs/observable/merge' ;
3433
3534
3635/** Throws an exception when two MdSidenav are matching the same side. */
@@ -76,7 +75,7 @@ export class MdSidenavToggleResult {
7675 host : {
7776 'class' : 'mat-sidenav' ,
7877 '[@transform]' : '_getAnimationState()' ,
79- '(@transform.start)' : '_isAnimating = true ' ,
78+ '(@transform.start)' : '_onAnimationStart() ' ,
8079 '(@transform.done)' : '_onAnimationEnd($event)' ,
8180 '(keydown)' : 'handleKeydown($event)' ,
8281 // must prevent the browser from aligning text based on value
@@ -122,6 +121,9 @@ export class MdSidenav implements AfterContentInit, OnDestroy {
122121 /** Whether the sidenav is opened. */
123122 private _opened : boolean = false ;
124123
124+ /** Emits whenever the sidenav has started animating. */
125+ _animationStarted = new EventEmitter < void > ( ) ;
126+
125127 /** Whether the sidenav is animating. Used to prevent overlapping animations. */
126128 _isAnimating = false ;
127129
@@ -255,6 +257,11 @@ export class MdSidenav implements AfterContentInit, OnDestroy {
255257 return 'void' ;
256258 }
257259
260+ _onAnimationStart ( ) {
261+ this . _isAnimating = true ;
262+ this . _animationStarted . emit ( ) ;
263+ }
264+
258265 _onAnimationEnd ( event : AnimationEvent ) {
259266 const { fromState, toState} = event ;
260267
@@ -361,9 +368,7 @@ export class MdSidenavContainer implements AfterContentInit {
361368 * is properly hidden.
362369 */
363370 private _watchSidenavToggle ( sidenav : MdSidenav ) : void {
364- merge ( sidenav . onOpenStart , sidenav . onCloseStart ) . subscribe ( ( ) => {
365- this . _changeDetectorRef . markForCheck ( ) ;
366- } ) ;
371+ sidenav . _animationStarted . subscribe ( ( ) => this . _changeDetectorRef . markForCheck ( ) ) ;
367372
368373 if ( sidenav . mode !== 'side' ) {
369374 sidenav . onOpen . subscribe ( ( ) => this . _setContainerClass ( true ) ) ;
@@ -399,9 +404,7 @@ export class MdSidenavContainer implements AfterContentInit {
399404 this . _start = this . _end = null ;
400405
401406 // 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 => {
405408 if ( sidenav . align == 'end' ) {
406409 if ( this . _end != null ) {
407410 throwMdDuplicatedSidenavError ( 'end' ) ;
@@ -413,7 +416,7 @@ export class MdSidenavContainer implements AfterContentInit {
413416 }
414417 this . _start = sidenav ;
415418 }
416- }
419+ } ) ;
417420
418421 this . _right = this . _left = null ;
419422
0 commit comments