diff options
author | Hsieh Chin Fan <pham@topo.tw> | 2024-10-02 21:30:36 +0800 |
---|---|---|
committer | Hsieh Chin Fan <pham@topo.tw> | 2024-10-02 21:30:36 +0800 |
commit | 3b19e78aae8db22aa7ed1ec44574db5d75b6bf3f (patch) | |
tree | 8855e7a2729cd29092027d8af124ac4e08bd3b18 | |
parent | 2c265941b5312f23d1f798bdc06ecee2c001db4f (diff) |
style: reformat code
-rw-r--r-- | src/dumbyUtils.mjs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/dumbyUtils.mjs b/src/dumbyUtils.mjs index 7bf26c8..b0845bd 100644 --- a/src/dumbyUtils.mjs +++ b/src/dumbyUtils.mjs | |||
@@ -3,11 +3,11 @@ import LeaderLine from 'leader-line' | |||
3 | export function focusNextMap (reverse = false) { | 3 | export function focusNextMap (reverse = false) { |
4 | const renderedList = this.utils.renderedMaps() | 4 | const renderedList = this.utils.renderedMaps() |
5 | const index = renderedList.findIndex(e => e.classList.contains('focus')) | 5 | const index = renderedList.findIndex(e => e.classList.contains('focus')) |
6 | const nextIndex = | 6 | const nextIndex = (index + (reverse ? -1 : 1)) % renderedList.length |
7 | index === -1 ? 0 : (index + (reverse ? -1 : 1)) % renderedList.length | ||
8 | 7 | ||
9 | const nextMap = renderedList.at(nextIndex) | 8 | const nextMap = renderedList.at(nextIndex) |
10 | nextMap.classList.add('focus') | 9 | nextMap.classList.add('focus') |
10 | nextMap.scrollIntoView({ behavior: 'smooth' }) | ||
11 | } | 11 | } |
12 | 12 | ||
13 | export function focusNextBlock (reverse = false) { | 13 | export function focusNextBlock (reverse = false) { |
@@ -19,8 +19,7 @@ export function focusNextBlock (reverse = false) { | |||
19 | }) | 19 | }) |
20 | ) | 20 | ) |
21 | const index = blocks.findIndex(e => e.classList.contains('focus')) | 21 | const index = blocks.findIndex(e => e.classList.contains('focus')) |
22 | const nextIndex = | 22 | const nextIndex = (index + (reverse ? -1 : 1)) % blocks.length |
23 | index === -1 ? 0 : (index + (reverse ? -1 : 1)) % blocks.length | ||
24 | 23 | ||
25 | blocks.forEach(b => b.classList.remove('focus')) | 24 | blocks.forEach(b => b.classList.remove('focus')) |
26 | const nextBlock = blocks.at(nextIndex) | 25 | const nextBlock = blocks.at(nextIndex) |