Skip to content

Commit

Permalink
Fix bug in scrolling of left panel
Browse files Browse the repository at this point in the history
Scrolling of the left panel (table of contents) was broken in the
rare cases where the height of left panel is much bigger than the
height of the actual page contents. This can happen in Reaktor
Library because the "Pages in folder X" listing has been moved
from the bottom of the content section to the left panel, below
table of contents.

By default, the `main.js` script attaches a `d-fixed` class on the
left panel to make the table of contents hover next to the
contents as the page is scrolled down. However, if the left panel
height is much bigger than the height of the contents (for example
when there are a lot of files in a folder, but there is no text
content on the index page itself), this `d-fixed` class actually
breaks the scrolling and the list cannot be scrolled all the way
to bottom.

The fix is to simply compare the heights of the left panel and
content elements, and only attach the `d-fixed` class when content
element's height is bigger than left panel element height.
  • Loading branch information
tommi-h authored and oamaok committed Nov 7, 2024
1 parent 9c2a2f5 commit 256be83
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion public/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ $(document).ready(function() {

// make TOC sticky
var $toc = $(".g-left-panel");
if ($toc.length) {
var $content = $(".g-main-content-wrapper")
if ($toc.length && $content.height() > $toc.height()) {
var stickyTop = $toc.offset().top - 100;
$window.on('scroll', function(){
($window.scrollTop() >= stickyTop) ? $toc.addClass('d-fixed') : $toc.removeClass('d-fixed');
Expand Down

0 comments on commit 256be83

Please sign in to comment.