diff options
Diffstat (limited to 'src/dumbyUtils.mjs')
-rw-r--r-- | src/dumbyUtils.mjs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/dumbyUtils.mjs b/src/dumbyUtils.mjs index ba0bbf8..fc9eab9 100644 --- a/src/dumbyUtils.mjs +++ b/src/dumbyUtils.mjs | |||
@@ -49,7 +49,10 @@ export function focusNextBlock(reverse = false) { | |||
49 | const nextBlock = blocks[nextIndex] | 49 | const nextBlock = blocks[nextIndex] |
50 | blocks.forEach(b => b.classList.remove('focus')) | 50 | blocks.forEach(b => b.classList.remove('focus')) |
51 | nextBlock?.classList?.add('focus') | 51 | nextBlock?.classList?.add('focus') |
52 | nextBlock.scrollIntoView({ behavior: 'smooth', block: "nearest" }) | 52 | const scrollBlock = nextBlock.getBoundingClientRect().height > nextBlock.parentElement.getBoundingClientRect().height * 0.8 |
53 | ? 'nearest' | ||
54 | : 'center' | ||
55 | nextBlock.scrollIntoView({ behavior: 'smooth', block: scrollBlock }) | ||
53 | } | 56 | } |
54 | 57 | ||
55 | export function removeBlockFocus() { | 58 | export function removeBlockFocus() { |