66 * found in the LICENSE file at https://angular.io/license
77 */
88
9- import { AnimationEvent } from '@angular/animations' ;
109import { FocusKeyManager } from '@angular/cdk/a11y' ;
1110import { Direction } from '@angular/cdk/bidi' ;
1211import { ESCAPE , LEFT_ARROW , RIGHT_ARROW } from '@angular/cdk/keycodes' ;
@@ -31,6 +30,7 @@ import {
3130 ViewChild ,
3231 ViewEncapsulation ,
3332 NgZone ,
33+ OnInit ,
3434} from '@angular/core' ;
3535import { Observable } from 'rxjs/Observable' ;
3636import { merge } from 'rxjs/observable/merge' ;
@@ -82,7 +82,7 @@ const MAT_MENU_BASE_ELEVATION = 2;
8282 ] ,
8383 exportAs : 'matMenu'
8484} )
85- export class MatMenu implements AfterContentInit , MatMenuPanel , OnDestroy {
85+ export class MatMenu implements OnInit , AfterContentInit , MatMenuPanel , OnDestroy {
8686 private _keyManager : FocusKeyManager < MatMenuItem > ;
8787 private _xPosition : MenuPositionX = this . _defaultOptions . xPosition ;
8888 private _yPosition : MenuPositionY = this . _defaultOptions . yPosition ;
@@ -95,7 +95,7 @@ export class MatMenu implements AfterContentInit, MatMenuPanel, OnDestroy {
9595 _classList : { [ key : string ] : boolean } = { } ;
9696
9797 /** Current state of the panel animation. */
98- _panelAnimationState : 'void' | 'enter-start' | 'enter ' = 'void' ;
98+ _panelAnimationState : 'void' | 'enter' = 'void' ;
9999
100100 /** Parent menu of the current menu panel. */
101101 parentMenu : MatMenuPanel | undefined ;
@@ -191,6 +191,10 @@ export class MatMenu implements AfterContentInit, MatMenuPanel, OnDestroy {
191191 private _ngZone : NgZone ,
192192 @Inject ( MAT_MENU_DEFAULT_OPTIONS ) private _defaultOptions : MatMenuDefaultOptions ) { }
193193
194+ ngOnInit ( ) {
195+ this . setPositionClasses ( ) ;
196+ }
197+
194198 ngAfterContentInit ( ) {
195199 this . _keyManager = new FocusKeyManager < MatMenuItem > ( this . items ) . withWrap ( ) . withTypeAhead ( ) ;
196200 this . _tabSubscription = this . _keyManager . tabOut . subscribe ( ( ) => this . close . emit ( 'keydown' ) ) ;
@@ -292,19 +296,18 @@ export class MatMenu implements AfterContentInit, MatMenuPanel, OnDestroy {
292296
293297 /** Starts the enter animation. */
294298 _startAnimation ( ) {
295- this . _panelAnimationState = 'enter-start' ;
299+ // @deletion -target 6.0.0 Combine with _resetAnimation.
300+ this . _panelAnimationState = 'enter' ;
296301 }
297302
298303 /** Resets the panel animation to its initial state. */
299304 _resetAnimation ( ) {
305+ // @deletion -target 6.0.0 Combine with _startAnimation.
300306 this . _panelAnimationState = 'void' ;
301307 }
302308
303309 /** Callback that is invoked when the panel animation completes. */
304- _onAnimationDone ( event : AnimationEvent ) {
305- // After the initial expansion is done, trigger the second phase of the enter animation.
306- if ( event . toState === 'enter-start' ) {
307- this . _panelAnimationState = 'enter' ;
308- }
310+ _onAnimationDone ( _event : AnimationEvent ) {
311+ // @deletion -target 6.0.0 Not being used anymore. To be removed.
309312 }
310313}
0 commit comments