Skip to content

armgit / bento

Public Imported from GitHub
0

Bento, the office suite that fits in a file

fix: keep active slide thumbnail visible (#149)

Yishen Tu4877d36519e1
diff --git a/slides/src/editor/editor.ts b/slides/src/editor/editor.ts
index 96ef20d3..7e3113f0 100644
--- a/slides/src/editor/editor.ts
+++ b/slides/src/editor/editor.ts
@@ -1604,9 +1604,13 @@ export class Editor {
}
private highlightSidebar() {
+ let active: HTMLElement | undefined
this.sidebar.querySelectorAll<HTMLElement>('.ed-thumb').forEach((n) => {
- n.classList.toggle('active', Number(n.dataset.index) === this.store.currentIndex)
+ const isActive = Number(n.dataset.index) === this.store.currentIndex
+ n.classList.toggle('active', isActive)
+ if (isActive) active = n
})
+ active?.scrollIntoView({ block: 'nearest', inline: 'nearest' })
}
private scheduleThumbs() {