diff options
Diffstat (limited to 'src')
| -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) |