fix: align constant menu to the right edge
This commit is contained in:
@@ -438,7 +438,6 @@ function openConstMenu() {
|
|||||||
constMenuEl = document.createElement('div');
|
constMenuEl = document.createElement('div');
|
||||||
constMenuEl.className = 'mode-menu';
|
constMenuEl.className = 'mode-menu';
|
||||||
constMenuEl.style.top = `${rect.bottom + 6 + window.scrollY}px`;
|
constMenuEl.style.top = `${rect.bottom + 6 + window.scrollY}px`;
|
||||||
constMenuEl.style.left = `${rect.left + window.scrollX}px`;
|
|
||||||
constants.forEach((constant) => {
|
constants.forEach((constant) => {
|
||||||
const button = document.createElement('button');
|
const button = document.createElement('button');
|
||||||
button.type = 'button';
|
button.type = 'button';
|
||||||
@@ -456,8 +455,8 @@ function openConstMenu() {
|
|||||||
});
|
});
|
||||||
document.body.appendChild(constMenuEl);
|
document.body.appendChild(constMenuEl);
|
||||||
const menuRect = constMenuEl.getBoundingClientRect();
|
const menuRect = constMenuEl.getBoundingClientRect();
|
||||||
const maxLeft = Math.max(8, window.innerWidth - menuRect.width - 8);
|
const desiredLeft = rect.right + window.scrollX - menuRect.width;
|
||||||
constMenuEl.style.left = `${Math.max(8, Math.min(maxLeft, rect.left + window.scrollX))}px`;
|
constMenuEl.style.left = `${Math.max(8, desiredLeft)}px`;
|
||||||
}
|
}
|
||||||
|
|
||||||
constButton.addEventListener('click', (event) => {
|
constButton.addEventListener('click', (event) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user