Merge pull request #567 from SVG-Edit/issues/566

#566 When you display the context panel on the right of the screen, t…
master
JFH 2021-06-04 10:55:24 +02:00 committed by GitHub
commit 97d52f8745
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 2 deletions

View File

@ -306,8 +306,21 @@ export class SeCMenuDialog extends HTMLElement {
const current = this; const current = this;
const onMenuOpenHandler = (e) => { const onMenuOpenHandler = (e) => {
e.preventDefault(); e.preventDefault();
current.$dialog.style.top = e.pageY + 'px'; // Detect mouse position
current.$dialog.style.left = e.pageX + 'px'; let x = e.pageX;
let y = e.pageY;
const xOff = screen.width - 250; // menu width
const yOff = screen.height - (276 + 150); // menu height + bottom panel height and scroll bar
if (x > xOff) {
x = xOff;
}
if (y > yOff) {
y = yOff;
}
current.$dialog.style.top = y + 'px';
current.$dialog.style.left = x + 'px';
current.$dialog.style.display = 'block'; current.$dialog.style.display = 'block';
}; };
const onMenuCloseHandler = (e) => { const onMenuCloseHandler = (e) => {