Skip to content

Commit

Permalink
Merge pull request rust-lang#1052 from morphologue/fix-sidebar-autosc…
Browse files Browse the repository at this point in the history
…roll

Fix rust-lang#1029 sidebar not auto-scrolling
  • Loading branch information
ehuss committed Oct 5, 2019
2 parents 7a1e8d2 + 417a16a commit 2097a55
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/theme/book.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ function playpen_text(playpen) {
(function sidebar() {
var html = document.querySelector("html");
var sidebar = document.getElementById("sidebar");
var sidebarScrollBox = document.getElementById("sidebar-scrollbox");
var sidebarLinks = document.querySelectorAll('#sidebar a');
var sidebarToggleButton = document.getElementById("sidebar-toggle");
var sidebarResizeHandle = document.getElementById("sidebar-resize-handle");
Expand Down Expand Up @@ -522,7 +523,7 @@ function playpen_text(playpen) {
// Scroll sidebar to current active section
var activeSection = sidebar.querySelector(".active");
if (activeSection) {
sidebar.scrollTop = activeSection.offsetTop;
sidebarScrollBox.scrollTop = activeSection.offsetTop;
}
})();

Expand Down
2 changes: 1 addition & 1 deletion src/theme/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
</script>

<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div class="sidebar-scrollbox">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
{{#toc}}{{/toc}}
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
Expand Down

0 comments on commit 2097a55

Please sign in to comment.