🔀 Merge pull request #806 from Jh123x/fix/772/set-to-top-elem-on-scrollable-height

feat: add js to check height and decide if to top is required
This commit is contained in:
James Panther
2024-08-29 12:15:52 +10:00
committed by GitHub
2 changed files with 38 additions and 12 deletions
+22
View File
@@ -38,7 +38,29 @@ if (document.documentElement.getAttribute("data-auto-appearance") === "true") {
});
}
function add_to_top_elem() {
var body = document.body;
var html = document.documentElement;
const height =
Math.max(
body.scrollHeight,
body.offsetHeight,
html.clientHeight,
html.scrollHeight,
html.offsetHeight
) - 150;
const elem = document.getElementById("to-top");
if (elem === null || elem === undefined) {
return;
}
elem.hidden = height < window.innerHeight;
}
window.addEventListener("DOMContentLoaded", (event) => {
add_to_top_elem();
setThemeColor();
var switchers = document.querySelectorAll("[id^='appearance-switcher']");
switchers.forEach((switcher) => {