Fix #1029 sidebar not auto-scrolling

This commit is contained in:
morphologue 2019-10-05 16:53:40 +10:00
parent 09c738468f
commit 699844a5c3
2 changed files with 3 additions and 2 deletions

View File

@ -435,6 +435,7 @@ function playpen_text(playpen) {
(function sidebar() { (function sidebar() {
var html = document.querySelector("html"); var html = document.querySelector("html");
var sidebar = document.getElementById("sidebar"); var sidebar = document.getElementById("sidebar");
var sidebarScrollBox = document.getElementById("sidebar-scrollbox");
var sidebarLinks = document.querySelectorAll('#sidebar a'); var sidebarLinks = document.querySelectorAll('#sidebar a');
var sidebarToggleButton = document.getElementById("sidebar-toggle"); var sidebarToggleButton = document.getElementById("sidebar-toggle");
var sidebarResizeHandle = document.getElementById("sidebar-resize-handle"); var sidebarResizeHandle = document.getElementById("sidebar-resize-handle");
@ -522,7 +523,7 @@ function playpen_text(playpen) {
// Scroll sidebar to current active section // Scroll sidebar to current active section
var activeSection = sidebar.querySelector(".active"); var activeSection = sidebar.querySelector(".active");
if (activeSection) { if (activeSection) {
sidebar.scrollTop = activeSection.offsetTop; sidebarScrollBox.scrollTop = activeSection.offsetTop;
} }
})(); })();

View File

@ -84,7 +84,7 @@
</script> </script>
<nav id="sidebar" class="sidebar" aria-label="Table of contents"> <nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div class="sidebar-scrollbox"> <div id="sidebar-scrollbox" class="sidebar-scrollbox">
{{#toc}}{{/toc}} {{#toc}}{{/toc}}
</div> </div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div> <div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>