feat: move context menu to the left of the cursor if any part of it is beyond the right side of the viewport
This commit is contained in:
parent
51f8c28c54
commit
0540f22f5d
1 changed files with 4 additions and 0 deletions
|
@ -18,6 +18,10 @@ onMounted(() => {
|
|||
if (contextMenu) {
|
||||
contextMenu.style.left = props.pointerX.toString() + "px";
|
||||
contextMenu.style.top = props.pointerY.toString() + "px";
|
||||
const rect = contextMenu.getBoundingClientRect();
|
||||
if (rect.right > (window.innerWidth || document.documentElement.clientWidth)) {
|
||||
contextMenu.style.left = (props.pointerX - contextMenu.clientWidth).toString() + "px";
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue