Finally actually really improve contextmenu positioning.

why am i so bad at this
This commit is contained in:
voussoir 2022-03-23 18:39:15 -07:00
parent e6f5d16a03
commit 6695717acd
No known key found for this signature in database
GPG key ID: 5F7554F8C26DACCB

View file

@ -35,8 +35,8 @@ function show_menu(event, menu)
const html = document.documentElement; const html = document.documentElement;
const over_right = Math.max(0, event.clientX + menu.offsetWidth - html.clientWidth); const over_right = Math.max(0, event.clientX + menu.offsetWidth - html.clientWidth);
const over_bottom = Math.max(0, event.clientY + menu.offsetHeight - html.clientHeight); const over_bottom = Math.max(0, event.clientY + menu.offsetHeight - html.clientHeight);
const left = event.pageX - over_right; const left = event.clientX - over_right;
const top = event.pageY - over_bottom; const top = event.clientY - over_bottom;
menu.style.left = left + "px"; menu.style.left = left + "px";
menu.style.top = top + "px"; menu.style.top = top + "px";
} }