move global search input to a general location

- create a global search store
- create a half-baked context menu store
-
This commit is contained in:
geoffrey45
2022-03-12 08:56:38 +03:00
parent 39fba364d3
commit 658e7cdbb7
21 changed files with 538 additions and 245 deletions
+34
View File
@@ -0,0 +1,34 @@
import perks from "./perks";
export default function normalizeContextMenu(x, y) {
const app_dom = perks.getElem("app", "id");
const context_menu = perks.getElem("context-menu-visible", "class");
const { left: scopeOffsetX, top: scopeOffsetY } =
app_dom.getBoundingClientRect();
const scopeX = x - scopeOffsetX;
const scopeY = y - scopeOffsetY;
const outOfBoundsX = scopeX + context_menu.clientHeight > app_dom.clientWidth;
const outOfBoundsY =
scopeY + context_menu.clientHeight > app_dom.clientHeight;
let normalizedX = x;
let normalizedY = y;
if (outOfBoundsX) {
normalizedX =
scopeOffsetX + app_dom.clientWidth - context_menu.clientHeight;
}
if (outOfBoundsY) {
normalizedY =
scopeOffsetY + app_dom.clientHeight - context_menu.clientHeight;
}
return {
normalizedX,
normalizedY,
};
}