|
@@ -108,6 +108,7 @@ class ContextMenu2 {
|
|
}
|
|
}
|
|
|
|
|
|
function refreshPos() {
|
|
function refreshPos() {
|
|
|
|
+ // Make sure the menu never goes out of bounds
|
|
var rect = rootElement.getBoundingClientRect();
|
|
var rect = rootElement.getBoundingClientRect();
|
|
var y = originalPos.y + Std.parseInt(js.Browser.window.getComputedStyle(rootElement).getPropertyValue("--offset-y"));
|
|
var y = originalPos.y + Std.parseInt(js.Browser.window.getComputedStyle(rootElement).getPropertyValue("--offset-y"));
|
|
var x = originalPos.x + Std.parseInt(js.Browser.window.getComputedStyle(rootElement).getPropertyValue("--offset-x"));
|
|
var x = originalPos.x + Std.parseInt(js.Browser.window.getComputedStyle(rootElement).getPropertyValue("--offset-x"));
|
|
@@ -123,8 +124,14 @@ class ContextMenu2 {
|
|
if (x + rect.width > js.Browser.window.innerWidth) {
|
|
if (x + rect.width > js.Browser.window.innerWidth) {
|
|
if (parentMenu != null) {
|
|
if (parentMenu != null) {
|
|
x = parentMenu.rootElement.getBoundingClientRect().left - rect.width;
|
|
x = parentMenu.rootElement.getBoundingClientRect().left - rect.width;
|
|
|
|
+ } else {
|
|
|
|
+ // put the menu to the left of the cursor if there is no parent menu
|
|
|
|
+ x = originalPos.x - rect.width;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if (x < 0) {
|
|
|
|
+ x = 0;
|
|
|
|
+ }
|
|
rootElement.style.left = '${x}px';
|
|
rootElement.style.left = '${x}px';
|
|
rootElement.style.top = '${y}px';
|
|
rootElement.style.top = '${y}px';
|
|
}
|
|
}
|