Skip to content

Commit

Permalink
refactor: address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
crisbeto committed Jul 27, 2017
1 parent b5b2b30 commit 9c319f3
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/lib/menu/menu-directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ export interface MdMenuDefaultOptions {
export const MD_MENU_DEFAULT_OPTIONS =
new InjectionToken<MdMenuDefaultOptions>('md-menu-default-options');

/**
* Start elevation for the menu panel.
* @docs-private
*/
const MD_MENU_BASE_ELEVATION = 2;


@Component({
moduleId: module.id,
selector: 'md-menu, mat-menu',
Expand Down Expand Up @@ -75,7 +82,7 @@ export class MdMenu implements AfterContentInit, MdMenuPanel, OnDestroy {
/** Current state of the panel animation. */
_panelAnimationState: 'void' | 'enter-start' | 'enter' = 'void';

/** Parent menu os the current menu panel. */
/** Parent menu of the current menu panel. */
parentMenu: MdMenuPanel | undefined;

/** Layout direction of the menu. */
Expand Down Expand Up @@ -198,11 +205,11 @@ export class MdMenu implements AfterContentInit, MdMenuPanel, OnDestroy {

/**
* Sets the menu panel elevation.
* @param depth Amount of parent menus that come before the menu.
* @param depth Number of parent menus that come before the menu.
*/
setElevation(depth: number): void {
// The elevation starts at 2 and increases by one for each level.
const newElevation = `mat-elevation-z${depth + 2}`;
// The elevation starts at the base and increases by one for each level.
const newElevation = `mat-elevation-z${MD_MENU_BASE_ELEVATION + depth}`;
const customElevation = Object.keys(this._classList).find(c => c.startsWith('mat-elevation-z'));

if (!customElevation || customElevation === this._previousElevation) {
Expand Down

0 comments on commit 9c319f3

Please sign in to comment.