diff --git a/src/components/contextmenus/index.jsx b/src/components/contextmenus/index.jsx index 3fcc3e6..0b080ea 100644 --- a/src/components/contextmenus/index.jsx +++ b/src/components/contextmenus/index.jsx @@ -13,7 +13,7 @@ export const types = { }; const ContextMenu = ({ - type, x, y, args, close, + type, x, y, args, close, align, }) => { const wrapperRef = useRef(null); @@ -23,16 +23,37 @@ const ContextMenu = ({ return null; } + const style = {}; + switch (align) { + case 'tr': { + style.right = window.innerWidth - x; + style.top = y; + break; + } + case 'br': { + style.right = window.innerWidth - x; + style.bottom = window.innerHeight - y; + break; + } + case 'bl': { + style.left = x; + style.bottom = window.innerHeight - y; + break; + } + default: { + // also 'tl' + style.left = x; + style.top = y; + } + } + const Content = types[type]; return ReactDOM.createPortal((
diff --git a/src/components/windows/Chat.jsx b/src/components/windows/Chat.jsx index b2796e8..2e026bc 100644 --- a/src/components/windows/Chat.jsx +++ b/src/components/windows/Chat.jsx @@ -162,6 +162,7 @@ const Chat = () => { y={cmArgs.y} args={cmArgs.args} close={closeCm} + align={cmArgs.align} />