Skip to content

Commit

Permalink
fix: update to also obey site settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Jh123x committed Apr 30, 2024
1 parent 65fa14c commit 86416cb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
27 changes: 17 additions & 10 deletions assets/js/appearance.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,24 @@ if (document.documentElement.getAttribute("data-auto-appearance") === "true") {
}

function add_to_top_elem() {
var body = document.body,
html = document.documentElement;
var body = document.body;
var 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;
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) => {
Expand Down
6 changes: 4 additions & 2 deletions layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@
<div class="relative flex grow flex-col">
<main id="main-content" class="grow">
{{ block "main" . }}{{ end }}
</main>
{{ if .Site.Params.footer.showScrollToTop | default true }}
<div
class="pointer-events-none absolute bottom-0 end-0 top-[100vh] w-12"
id="to-top"
hidden
hidden="{{ .Site.Params.footer.showScrollToTop | default true -}}"
>
<a
href="#the-top"
Expand All @@ -43,7 +45,7 @@
&uarr;
</a>
</div>
</main>
{{ end }}
{{- partial "footer.html" . -}}
{{ if .Site.Params.enableSearch | default false }}
{{- partial "search.html" . -}}
Expand Down

0 comments on commit 86416cb

Please sign in to comment.