Skip to content

Commit

Permalink
Adds automatic scrolling to toc
Browse files Browse the repository at this point in the history
Signed-off-by: Robert Fekete <[email protected]>
  • Loading branch information
fekete-robert committed Aug 14, 2023
1 parent 0b68b80 commit 547de53
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions layouts/partials/scripts.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,14 @@
</script>
{{ end }}

<!-- Scroll left-side toc to current entry, from https://github.com/google/docsy/issues/348 -->
<script>
(function() {
var a = document.querySelector("#td-section-nav");
addEventListener("beforeunload", function(b) {
localStorage.setItem("menu.scrollTop", a.scrollTop)
}), a.scrollTop = localStorage.getItem("menu.scrollTop")
})()
</script>

{{ partial "hooks/body-end.html" . -}}

0 comments on commit 547de53

Please sign in to comment.