mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-18 11:36:36 +00:00
fix(context-menu): set initial y offset of context menu based on window height #577
This commit is contained in:
parent
7380165298
commit
29745564a6
1 changed files with 9 additions and 1 deletions
|
@ -78,7 +78,15 @@
|
|||
on:contextmenu|preventDefault="{(e) => {
|
||||
if (level > 1) return;
|
||||
if (open || x === 0) x = e.x;
|
||||
if (open || y === 0) y = e.y;
|
||||
if (open || y === 0) {
|
||||
const { height } = ref.getBoundingClientRect();
|
||||
|
||||
if (window.innerHeight - height < e.y) {
|
||||
y = e.y - height;
|
||||
} else {
|
||||
y = e.y;
|
||||
}
|
||||
}
|
||||
position.set([x, y]);
|
||||
open = true;
|
||||
}}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue