Skip to content

Commit

Permalink
fix: ensure current link in globaltoc is in viewport
Browse files Browse the repository at this point in the history
  • Loading branch information
lepture committed Feb 28, 2024
1 parent 52e39e3 commit 202f96e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions static/js/globaltoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,9 @@ function createToggleButton (el) {
return button
}

const currentLink = document.querySelector('.globaltoc a.current')
if (currentLink && currentLink.scrollIntoViewIfNeeded) {
currentLink.scrollIntoViewIfNeeded()
}

addToggleToc()

0 comments on commit 202f96e

Please sign in to comment.