mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
refactor(menu): set animation origin based on overlay position (#5347)
Uses the menu panel's overlay position to determine the animation origin, instead of the trigger. These changes make it easier to follow and avoid having to correct it explicitly based on the `overlapTrigger` flag, in addition to fixing some issues in nested menus.
This commit is contained in:
committed by
mmalerba
parent
dd230a3090
commit
b3957d8083
@@ -238,13 +238,9 @@ export class MdMenuTrigger implements AfterViewInit, OnDestroy {
|
||||
* correct, even if a fallback position is used for the overlay.
|
||||
*/
|
||||
private _subscribeToPositions(position: ConnectedPositionStrategy): void {
|
||||
this._positionSubscription = position.onPositionChange.subscribe((change) => {
|
||||
const posX: MenuPositionX = change.connectionPair.originX === 'start' ? 'after' : 'before';
|
||||
let posY: MenuPositionY = change.connectionPair.originY === 'top' ? 'below' : 'above';
|
||||
|
||||
if (!this.menu.overlapTrigger) {
|
||||
posY = posY === 'below' ? 'above' : 'below';
|
||||
}
|
||||
this._positionSubscription = position.onPositionChange.subscribe(change => {
|
||||
const posX: MenuPositionX = change.connectionPair.overlayX === 'start' ? 'after' : 'before';
|
||||
const posY: MenuPositionY = change.connectionPair.overlayY === 'top' ? 'below' : 'above';
|
||||
|
||||
this.menu.setPositionClasses(posX, posY);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user