Skip to content

Commit

Permalink
Improve watcher for scroll issues
Browse files Browse the repository at this point in the history
  • Loading branch information
pradyunsg committed May 15, 2024
1 parent 5e3440b commit 38f17af
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/furo/assets/scripts/furo.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ import Gumshoe from "./gumshoe-patched.js";
////////////////////////////////////////////////////////////////////////////////
var tocScroll = null;
var header = null;
var lastScrollTop = window.pageYOffset || document.documentElement.scrollTop;
var lastScrollTop = document.documentElement.scrollTop;
const GO_TO_TOP_OFFSET = 64;

function scrollHandlerForHeader() {
if (Math.floor(header.getBoundingClientRect().top) == 0) {
function scrollHandlerForHeader(positionY) {
const headerTop = Math.floor(header.getBoundingClientRect().top);

console.log(`headerTop: ${headerTop}`);
if (headerTop == 0 && positionY != headerTop) {
header.classList.add("scrolled");
} else {
header.classList.remove("scrolled");
Expand Down Expand Up @@ -62,7 +65,7 @@ function scrollHandlerForTOC(positionY) {
}

function scrollHandler(positionY) {
scrollHandlerForHeader();
scrollHandlerForHeader(positionY);
scrollHandlerForBackToTop(positionY);
scrollHandlerForTOC(positionY);
}
Expand Down

0 comments on commit 38f17af

Please sign in to comment.