parent
ae9a238289
commit
12d3db2dbc
@ -6,17 +6,17 @@ import { Icons } from '@ohif/ui-next';
|
|||||||
const ContextMenu = ({ items, ...props }) => {
|
const ContextMenu = ({ items, ...props }) => {
|
||||||
const contextMenuRef = useRef<HTMLDivElement>(null);
|
const contextMenuRef = useRef<HTMLDivElement>(null);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if(!contextMenuRef?.current) {
|
if (!contextMenuRef?.current) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const contextMenu = contextMenuRef.current;
|
const contextMenu = contextMenuRef.current;
|
||||||
|
|
||||||
const boundingClientRect = contextMenu.getBoundingClientRect();
|
const boundingClientRect = contextMenu.getBoundingClientRect();
|
||||||
if (boundingClientRect.bottom + boundingClientRect.height > window.innerHeight) {
|
if (boundingClientRect.bottom > window.innerHeight) {
|
||||||
props.defaultPosition.y = props.defaultPosition.y - boundingClientRect.height;
|
props.defaultPosition.y = props.defaultPosition.y - boundingClientRect.height;
|
||||||
}
|
}
|
||||||
if (boundingClientRect.right + boundingClientRect.width > window.innerWidth) {
|
if (boundingClientRect.right > window.innerWidth) {
|
||||||
props.defaultPosition.x = props.defaultPosition.x - boundingClientRect.width;
|
props.defaultPosition.x = props.defaultPosition.x - boundingClientRect.width;
|
||||||
}
|
}
|
||||||
}, [props.defaultPosition]);
|
}, [props.defaultPosition]);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user