There was an error while loading. Please reload this page.
1 parent e0eaa3e commit c60373eCopy full SHA for c60373e
1 file changed
assets/js/back-to-top.js
@@ -5,13 +5,16 @@
5
if (!button) return;
6
7
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;
11
var ticking = false;
12
13
function update() {
14
var scrollY = window.scrollY || window.pageYOffset;
15
var pageHeight = document.documentElement.scrollHeight;
16
var isScrollable = pageHeight > window.innerHeight;
- var atBottom = isScrollable && window.innerHeight + scrollY >= pageHeight - 4;
17
+ var atBottom = isScrollable && window.innerHeight + scrollY >= pageHeight - BOTTOM_FUDGE_PX;
18
button.classList.toggle("is-visible", scrollY > SHOW_AFTER_PX || atBottom);
19
ticking = false;
20
}
0 commit comments