aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/MenuItem.mjs
diff options
context:
space:
mode:
authorHsieh Chin Fan <pham@topo.tw>2024-10-02 15:07:01 +0800
committerHsieh Chin Fan <pham@topo.tw>2024-10-02 15:07:01 +0800
commit045e55ce0547544e064f09f87bd1f75d7fa088b0 (patch)
tree7170010388ddaaf3be7cab647f427ad398bf4b5a /src/MenuItem.mjs
parent061a9e7de3f3426225f73e3cbd59942c1ceae2c8 (diff)
feat: prevent menu show outside of window
Diffstat (limited to 'src/MenuItem.mjs')
-rw-r--r--src/MenuItem.mjs3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/MenuItem.mjs b/src/MenuItem.mjs
index e1cb582..a7724d3 100644
--- a/src/MenuItem.mjs
+++ b/src/MenuItem.mjs
@@ -1,3 +1,5 @@
1import { shiftByWindow } from './utils.mjs'
2
1class Item extends window.HTMLDivElement { 3class Item extends window.HTMLDivElement {
2 constructor ({ text, innerHTML, onclick, style }) { 4 constructor ({ text, innerHTML, onclick, style }) {
3 super() 5 super()
@@ -35,6 +37,7 @@ class Folder extends window.HTMLDivElement {
35 .querySelectorAll('.sub-menu') 37 .querySelectorAll('.sub-menu')
36 .forEach(sub => sub.remove()) 38 .forEach(sub => sub.remove())
37 this.appendChild(submenu) 39 this.appendChild(submenu)
40 shiftByWindow(submenu)
38 } 41 }
39 } 42 }
40} 43}