Skip to content

Commit a097fe6

Browse files
authored
Merge pull request #2891 from ehuss/divide-by-zero-heading-bug
Avoid divide-by-zero in heading nav computation
2 parents 7b7dee4 + 4b5004b commit a097fe6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

crates/mdbook-html/front-end/templates/toc.js.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ window.customElements.define('mdbook-sidebar-scrollbox', MDBookSidebarScrollbox)
127127
// proportional to the difference in size.
128128
if (documentHeight < windowHeight * 2) {
129129
const maxPixelsBelow = documentHeight - windowHeight;
130-
const t = 1 - pixelsBelow / maxPixelsBelow;
130+
const t = 1 - pixelsBelow / Math.max(1, maxPixelsBelow);
131131
const clamp = Math.max(0, Math.min(1, t));
132132
adjustedBottomAdd *= clamp;
133133
}

0 commit comments

Comments
 (0)