diff --git a/assets/js/appearance.js b/assets/js/appearance.js index dd5ad69d..15f0eed8 100644 --- a/assets/js/appearance.js +++ b/assets/js/appearance.js @@ -38,7 +38,22 @@ if (document.documentElement.getAttribute("data-auto-appearance") === "true") { }); } +function add_to_top_elem() { + var body = document.body, + html = document.documentElement; + + const height = Math.max( + body.scrollHeight, + body.offsetHeight, + html.clientHeight, + html.scrollHeight, + html.offsetHeight + ) - 150; + document.getElementById("to-top").hidden = height < window.innerHeight; +} + window.addEventListener("DOMContentLoaded", (event) => { + add_to_top_elem(); var switchers = document.querySelectorAll("[id^='appearance-switcher']"); switchers.forEach((switcher) => { switcher.addEventListener("click", () => { diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 4f492147..7be938ab 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -29,18 +29,20 @@