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 05:06:28 -04:00
committed by GitHub
parent 2df3c563bf
commit d1bed05843
4 changed files with 32 additions and 1 deletions

18
assets/js/back-to-top.js Normal file
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'
});
}