Fix #1029 sidebar not auto-scrolling
This commit is contained in:
parent
09c738468f
commit
699844a5c3
|
@ -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;
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
|
@ -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>
|
||||||
|
|
Loading…
Reference in New Issue