🐛 子菜单位置

This commit is contained in:
Vanessa 2022-07-27 01:33:12 +08:00
parent 6652ac5352
commit 05958328f5
2 changed files with 10 additions and 9 deletions

View file

@ -34,7 +34,8 @@ export class Menu {
const rect = subMenuElement.getBoundingClientRect();
let style = "";
const leftPosition = rect.left - this.element.clientWidth - rect.width
if (rect.right > window.innerWidth && Math.abs(leftPosition) < (rect.right - window.innerWidth)) {
if (rect.right > window.innerWidth && (
leftPosition > 0 || Math.abs(leftPosition) < (rect.right - window.innerWidth))) {
if (leftPosition >= 0) {
style = "left:auto;right:100%;";
} else {