diff options
author | Hsieh Chin Fan <pham@topo.tw> | 2024-09-29 21:01:03 +0800 |
---|---|---|
committer | Hsieh Chin Fan <pham@topo.tw> | 2024-09-29 21:19:07 +0800 |
commit | 27feb1302304eede3cdc58ffde5ce8e0f0019da4 (patch) | |
tree | 0db88a3c17f4761470d0b3e39b3ad16e36fbe2c5 /src/dumbyUtils.mjs | |
parent | 110d8890e171573adad1fe171a122dfbc89f6faa (diff) |
feat: add submenu for map/block/layout switching
* Add general classes into MenuItem
* Use MutationObserver for data-mode
* Automatically unfocus other maps when one is focused
TODO:
* hover effect on submenu item doesn't work, why?
* shorcuts hint in selector ".folder.menu-item" not looks great
Diffstat (limited to 'src/dumbyUtils.mjs')
-rw-r--r-- | src/dumbyUtils.mjs | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/src/dumbyUtils.mjs b/src/dumbyUtils.mjs index cfac00b..140d671 100644 --- a/src/dumbyUtils.mjs +++ b/src/dumbyUtils.mjs | |||
@@ -1,17 +1,12 @@ | |||
1 | export function focusNextMap(reverse = false) { | 1 | export function focusNextMap(reverse = false) { |
2 | const renderedList = Array.from( | 2 | const renderedList = this.utils.renderedMaps(); |
3 | this.htmlHolder.querySelectorAll('[data-render=fulfilled]'), | 3 | |
4 | ); | ||
5 | const mapNum = renderedList.length; | 4 | const mapNum = renderedList.length; |
6 | if (mapNum === 0) return; | 5 | if (mapNum === 0) return; |
7 | 6 | ||
8 | // Get current focused map element | 7 | // Get current focused map element |
9 | const currentFocus = this.container.querySelector('.mapclay.focus'); | 8 | const currentFocus = this.container.querySelector('.mapclay.focus'); |
10 | 9 | ||
11 | // Remove class name of focus for ALL candidates | ||
12 | // This may trigger animation | ||
13 | renderedList.forEach(ele => ele.classList.remove('focus')); | ||
14 | |||
15 | // Get next existing map element | 10 | // Get next existing map element |
16 | const padding = reverse ? -1 : 1; | 11 | const padding = reverse ? -1 : 1; |
17 | let nextIndex = currentFocus | 12 | let nextIndex = currentFocus |