diff --git a/assets/js/appearance.js b/assets/js/appearance.js index 32cd39c..0cdfd15 100644 --- a/assets/js/appearance.js +++ b/assets/js/appearance.js @@ -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) => { diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index defe45f..28c8daf 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -29,19 +29,23 @@