Files
hugo/assets/js/scroll-to-top.js
kbrianngeno a85b9146ee
Some checks failed
Blowfish Docs Deploy / build (push) Has been cancelled
Blowfish Docs Deploy / deploy (push) Has been cancelled
Test Build / Build Example Site (push) Has been cancelled
First commit
Delete exampleSite
Add initial content, images & docker-compose.yml
Use extend-head.html for analytics
Set remote url to gitea.novicelab.io
2026-03-14 14:37:54 +00:00

14 lines
506 B
JavaScript

function scrollToTop() {
const scrollToTop = document.getElementById("scroll-to-top");
if (window.scrollY > window.innerHeight * 0.5) {
scrollToTop.classList.remove("translate-y-4", "opacity-0");
scrollToTop.classList.add("translate-y-0", "opacity-100");
} else {
scrollToTop.classList.remove("translate-y-0", "opacity-100");
scrollToTop.classList.add("translate-y-4", "opacity-0");
}
}
window.addEventListener("scroll", scrollToTop);
window.addEventListener("load", scrollToTop);