Skip to content

Commit

Permalink
fix(menu): remove exception when async loading
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasBurleson authored and kennethcachia committed Sep 23, 2015
1 parent d4ae972 commit c05e952
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/components/menu/js/menuServiceProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,24 +410,22 @@ function MenuProvider($$interimElementProvider) {
right: boundryNodeRect.right - MENU_EDGE_MARGIN
};

var alignTarget, alignTargetRect, existingOffsets;
var alignTarget, alignTargetRect = { top:0, left : 0, right:0, bottom:0 }, existingOffsets = { top:0, left : 0, right:0, bottom:0 };
var positionMode = opts.mdMenuCtrl.positionMode();

if (positionMode.top == 'target' || positionMode.left == 'target' || positionMode.left == 'target-right') {
// TODO: Allow centering on an arbitrary node, for now center on first menu-item's child
alignTarget = firstVisibleChild();
if (!alignTarget) {
throw Error('Error positioning menu. No visible children.');
if ( alignTarget ) {
// TODO: Allow centering on an arbitrary node, for now center on first menu-item's child
alignTarget = alignTarget.firstElementChild || alignTarget;
alignTarget = alignTarget.querySelector('[md-menu-align-target]') || alignTarget;
alignTargetRect = alignTarget.getBoundingClientRect();

existingOffsets = {
top: parseFloat(containerNode.style.top || 0),
left: parseFloat(containerNode.style.left || 0)
};
}

alignTarget = alignTarget.firstElementChild || alignTarget;
alignTarget = alignTarget.querySelector('[md-menu-align-target]') || alignTarget;
alignTargetRect = alignTarget.getBoundingClientRect();

existingOffsets = {
top: parseFloat(containerNode.style.top || 0),
left: parseFloat(containerNode.style.left || 0)
};
}

var position = {};
Expand Down

0 comments on commit c05e952

Please sign in to comment.