Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions contextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,10 @@
topCoordinate = event.pageY - menuHeight;
/// If the element is a nested menu, adds the height of the parent li to the topCoordinate to align with the parent
if(level && level > 0) {
topCoordinate += event.event.currentTarget.offsetHeight;
// but not so much that it overflows off the bottom of the window
var maxHeight = $document[0].body.clientHeight - $window.scrollY - menuHeight - 20;
var adjustedHeight = topCoordinate + event.event.currentTarget.offsetHeight;
topCoordinate = Math.min(maxHeight, adjustedHeight);
}
} else if(winHeight <= menuHeight) {
// If it really can't fit, reset the height of the menu to one that will fit
Expand All @@ -410,7 +413,7 @@

var leftCoordinate = event.pageX;
var menuWidth = angular.element($ul[0]).prop('offsetWidth');
var winWidth = event.view.innerWidth + window.pageXOffset;
var winWidth = event.view.innerWidth + $window.pageXOffset;
var padding = 5;

if (leftOriented) {
Expand All @@ -427,7 +430,11 @@
}
} else {
if (leftCoordinate > menuWidth && winWidth - leftCoordinate - padding < menuWidth) {
leftCoordinate = winWidth - menuWidth - padding;
if(level && level > 0) {
leftCoordinate = leftCoordinate - (1.5 * menuWidth);
} else {
leftCoordinate = winWidth - menuWidth - padding;
}
} else if(winWidth - leftCoordinate < menuWidth) {
var reduceThresholdX = 5;
if(leftCoordinate < reduceThresholdX + padding) {
Expand Down