Skip to content

Commit 9efa9fd

Browse files
authored
Merge pull request #1052 from morphologue/fix-sidebar-autoscroll
Fix #1029 sidebar not auto-scrolling
2 parents 8a33407 + 699844a commit 9efa9fd

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/theme/book.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@ function playpen_text(playpen) {
435435
(function sidebar() {
436436
var html = document.querySelector("html");
437437
var sidebar = document.getElementById("sidebar");
438+
var sidebarScrollBox = document.getElementById("sidebar-scrollbox");
438439
var sidebarLinks = document.querySelectorAll('#sidebar a');
439440
var sidebarToggleButton = document.getElementById("sidebar-toggle");
440441
var sidebarResizeHandle = document.getElementById("sidebar-resize-handle");
@@ -522,7 +523,7 @@ function playpen_text(playpen) {
522523
// Scroll sidebar to current active section
523524
var activeSection = sidebar.querySelector(".active");
524525
if (activeSection) {
525-
sidebar.scrollTop = activeSection.offsetTop;
526+
sidebarScrollBox.scrollTop = activeSection.offsetTop;
526527
}
527528
})();
528529

src/theme/index.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
</script>
8585

8686
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
87-
<div class="sidebar-scrollbox">
87+
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
8888
{{#toc}}{{/toc}}
8989
</div>
9090
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>

0 commit comments

Comments
 (0)