fix(scroll-to-top): resolve overlap with buy me a coffee button

This commit is contained in:
ZhenShuo Leo committed 2025-09-23 17:57:58 +08:00
1 parent 019388def8
commit b777d4e59e
4 files changed
+53 -24

No files matched your search

+13
View File
@@ -0,0 +1,13 @@
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);