Skip to content

Commit

Permalink
Fix: Scroll sidebar to current active section (rust-lang#1067)
Browse files Browse the repository at this point in the history
  • Loading branch information
lihz6 committed Oct 11, 2019
1 parent 2b3304c commit dae9b5f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/theme/book.js
Original file line number Diff line number Diff line change
Expand Up @@ -521,10 +521,12 @@ function playpen_text(playpen) {
}, { passive: true });

// Scroll sidebar to current active section
var activeSection = sidebar.querySelector(".active");
if (activeSection) {
sidebarScrollBox.scrollTop = activeSection.offsetTop;
}
window.addEventListener('load', function() {
var activeSection = sidebar.querySelector(".active");
if (activeSection) {
activeSection.scrollIntoViewIfNeeded();
}
});
})();

(function chapterNavigation() {
Expand Down

0 comments on commit dae9b5f

Please sign in to comment.