Skip to content

Commit c60373e

Browse files
aclark4lifeCopilot
andcommitted
Name back-to-top bottom-fudge constant for clarity
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent e0eaa3e commit c60373e

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

assets/js/back-to-top.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@
55
if (!button) return;
66

77
var SHOW_AFTER_PX = 600;
8+
// Small fudge factor so sub-pixel scroll rounding still counts as "at
9+
// the bottom" of the page.
10+
var BOTTOM_FUDGE_PX = 4;
811
var ticking = false;
912

1013
function update() {
1114
var scrollY = window.scrollY || window.pageYOffset;
1215
var pageHeight = document.documentElement.scrollHeight;
1316
var isScrollable = pageHeight > window.innerHeight;
14-
var atBottom = isScrollable && window.innerHeight + scrollY >= pageHeight - 4;
17+
var atBottom = isScrollable && window.innerHeight + scrollY >= pageHeight - BOTTOM_FUDGE_PX;
1518
button.classList.toggle("is-visible", scrollY > SHOW_AFTER_PX || atBottom);
1619
ticking = false;
1720
}

0 commit comments

Comments
 (0)