improved context menu logic

This commit is contained in:
subnub
2024-07-26 07:38:29 -04:00
parent 19abbb0387
commit c04a7cb142
2 changed files with 35 additions and 17 deletions
-12
View File
@@ -13,21 +13,9 @@ export const useContextMenu = () => {
if (e) e.stopPropagation();
if (e) e.preventDefault();
const contextWidth = 245;
const contextHeight = 260;
const { innerWidth: windowWidth, innerHeight: windowHeight } = window;
let X = e.clientX;
let Y = e.clientY;
if (X + contextWidth > windowWidth) {
X = windowWidth - contextWidth;
}
if (Y + contextHeight > windowHeight) {
Y = windowHeight - contextHeight - 60;
}
setContextData({
...contextData,
selected: true,