6
6
* found in the LICENSE file at https://angular.io/license
7
7
*/
8
8
9
- import { AnimationEvent } from '@angular/animations' ;
10
9
import { FocusKeyManager } from '@angular/cdk/a11y' ;
11
10
import { Direction } from '@angular/cdk/bidi' ;
12
11
import { ESCAPE , LEFT_ARROW , RIGHT_ARROW } from '@angular/cdk/keycodes' ;
@@ -31,6 +30,7 @@ import {
31
30
ViewChild ,
32
31
ViewEncapsulation ,
33
32
NgZone ,
33
+ OnInit ,
34
34
} from '@angular/core' ;
35
35
import { Observable } from 'rxjs/Observable' ;
36
36
import { merge } from 'rxjs/observable/merge' ;
@@ -82,7 +82,7 @@ const MAT_MENU_BASE_ELEVATION = 2;
82
82
] ,
83
83
exportAs : 'matMenu'
84
84
} )
85
- export class MatMenu implements AfterContentInit , MatMenuPanel , OnDestroy {
85
+ export class MatMenu implements OnInit , AfterContentInit , MatMenuPanel , OnDestroy {
86
86
private _keyManager : FocusKeyManager < MatMenuItem > ;
87
87
private _xPosition : MenuPositionX = this . _defaultOptions . xPosition ;
88
88
private _yPosition : MenuPositionY = this . _defaultOptions . yPosition ;
@@ -95,7 +95,7 @@ export class MatMenu implements AfterContentInit, MatMenuPanel, OnDestroy {
95
95
_classList : { [ key : string ] : boolean } = { } ;
96
96
97
97
/** Current state of the panel animation. */
98
- _panelAnimationState : 'void' | 'enter-start' | 'enter ' = 'void' ;
98
+ _panelAnimationState : 'void' | 'enter' = 'void' ;
99
99
100
100
/** Parent menu of the current menu panel. */
101
101
parentMenu : MatMenuPanel | undefined ;
@@ -191,6 +191,10 @@ export class MatMenu implements AfterContentInit, MatMenuPanel, OnDestroy {
191
191
private _ngZone : NgZone ,
192
192
@Inject ( MAT_MENU_DEFAULT_OPTIONS ) private _defaultOptions : MatMenuDefaultOptions ) { }
193
193
194
+ ngOnInit ( ) {
195
+ this . setPositionClasses ( ) ;
196
+ }
197
+
194
198
ngAfterContentInit ( ) {
195
199
this . _keyManager = new FocusKeyManager < MatMenuItem > ( this . items ) . withWrap ( ) . withTypeAhead ( ) ;
196
200
this . _tabSubscription = this . _keyManager . tabOut . subscribe ( ( ) => this . close . emit ( 'keydown' ) ) ;
@@ -292,19 +296,18 @@ export class MatMenu implements AfterContentInit, MatMenuPanel, OnDestroy {
292
296
293
297
/** Starts the enter animation. */
294
298
_startAnimation ( ) {
295
- this . _panelAnimationState = 'enter-start' ;
299
+ // @deletion -target 6.0.0 Combine with _resetAnimation.
300
+ this . _panelAnimationState = 'enter' ;
296
301
}
297
302
298
303
/** Resets the panel animation to its initial state. */
299
304
_resetAnimation ( ) {
305
+ // @deletion -target 6.0.0 Combine with _startAnimation.
300
306
this . _panelAnimationState = 'void' ;
301
307
}
302
308
303
309
/** 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.
309
312
}
310
313
}
0 commit comments