Contest menu angularjs height and width calc
menu.css({
position: 'fixed',
top: 0,
left: 0,
transform: $interpolate('translate({{x}}px, {{y}}px)')({
x: scope.position.x, y: scope.position.y
})
});
scope.menu = menu;
scope.menu.bind('click', closeMenu);
$timeout(function() {
scope.menuHeight = menu.height();
scope.menuWidth = menu.width();
//alert('Window Height :'+scope.windowHeight+'Menu Height:'+scope.menuHeight+'Menu Top'+scope.position.y);
var menuHeight = scope.menuHeight;
var menuWidth = scope.menuWidth;
var menuLeft = menuWidth + scope.position.x;
var childLeft = menuLeft + menuWidth;
var gChildLeft = menuLeft + (menuWidth * 2);
var menuBottom = menuHeight + scope.position.y;
var menuHightbottom = menuBottom + menuHeight;
var gMenuHightbottom = menuBottom + (menuHeight * 2);
var widthDiff = (menuLeft - scope.windowWidth) + 25;
var heightDiff = (menuBottom - scope.windowHeight) + 25;
//alert('Window Width :'+scope.windowWidth+'Menu Left:'+menuLeft+'Diff : '+widthDiff);
if (menuBottom > scope.windowHeight) {
menu.css({
marginTop: -heightDiff
});
}
if (menuLeft > scope.windowWidth) {
menu.css({
marginLeft: -widthDiff
});
}
if (childLeft > scope.windowWidth) {
menu.find('.submenu').addClass('moveleft');
}
if (gChildLeft > scope.windowWidth) {
menu.find('.innersubmenu').addClass('moveleft');
}
if (menuHightbottom > scope.windowHeight) {
menu.find('.submenu').addClass('moveBottom');
}
if (gMenuHightbottom > scope.windowWidth) {
menu.find('.innersubmenu').addClass('moveBottom');
}
}, 10);
Comments
Post a Comment