mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 04:23:01 +00:00
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:
@@ -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,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user