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:
Kristiyan Kostadinov
2017-07-07 18:06:45 +02:00
committed by mmalerba
parent dd230a3090
commit b3957d8083
+3 -7
View File
@@ -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);
});