add child level context menu

- more typescript
This commit is contained in:
geoffrey45
2022-03-16 01:21:53 +03:00
parent f11005e523
commit 29124ce717
14 changed files with 209 additions and 82 deletions
+14 -7
View File
@@ -17,20 +17,27 @@ export default (mouseX, mouseY) => {
const outOfBoundsOnY = scopeY + contextMenu.clientHeight > scope.clientHeight;
let normalizedX = mouseX;
let normalizedY = mouseY;
let normalX = mouseX;
let normalY = mouseY;
let normalizedX = false;
let normalizedY = false;
if (window.innerWidth - normalX < 375) {
normalizedX = true;
}
// ? normalize on X
if (outOfBoundsOnX) {
normalizedX = scopeOffsetX + scope.clientWidth - contextMenu.clientWidth;
normalizedX -= 10
normalX = scopeOffsetX + scope.clientWidth - contextMenu.clientWidth;
normalX -= 10;
}
// ? normalize on Y
if (outOfBoundsOnY) {
normalizedY = scopeOffsetY + scope.clientHeight - contextMenu.clientHeight;
normalizedY -= 10
normalY = scopeOffsetY + scope.clientHeight - contextMenu.clientHeight;
normalY -= 10;
normalizedY = true;
}
return { normalizedX, normalizedY };
return { normalX, normalY, normalizedX, normalizedY };
};