| 79 | } |
| 80 | |
| 81 | positionMenu(e) { |
| 82 | let clickCoords = this.getPosition(e); |
| 83 | |
| 84 | let menuWidth = this.menu.offsetWidth + 4; |
| 85 | let menuHeight = this.menu.offsetHeight + 4; |
| 86 | |
| 87 | let windowWidth = window.innerWidth; |
| 88 | let windowHeight = window.innerHeight; |
| 89 | |
| 90 | if (windowWidth - clickCoords.x < menuWidth) { |
| 91 | this.menu.style.left = windowWidth - menuWidth + "px"; |
| 92 | } else { |
| 93 | this.menu.style.left = clickCoords.x + "px"; |
| 94 | } |
| 95 | |
| 96 | if (windowHeight - clickCoords.y < menuHeight) { |
| 97 | this.menu.style.top = windowHeight - menuHeight + "px"; |
| 98 | } else { |
| 99 | this.menu.style.top = clickCoords.y + "px"; |
| 100 | } |
| 101 | } |
| 102 | } |