feat: Back To Top (#105)

* Scroll to top

* Update scripts.html

---------

Co-authored-by: Xin <xin@imfing.com>
This commit is contained in:
Remy Sheppard
2023-10-01 10:06:28 +01:00
committed by GitHub
co-authored by Xin
parent 2df3c563bf
commit d1bed05843
4 changed files with 32 additions and 1 deletions
+18
View File
@@ -0,0 +1,18 @@
const backToTop = document.querySelector("#backToTop");
document.addEventListener("scroll", (event) => {
if (window.scrollY > 300) {
backToTop.classList.remove("opacity-0");
} else {
backToTop.classList.add("opacity-0");
}
});
function scrollUp() {
window.scroll({
top: 0,
left: 0,
behavior: 'smooth'
});
}