mirror of
https://github.com/imfing/hextra.git
synced 2025-06-20 00:51:18 -04:00
feat: Back To Top (#105)
* Scroll to top * Update scripts.html --------- Co-authored-by: Xin <xin@imfing.com>
This commit is contained in:
18
assets/js/back-to-top.js
Normal file
18
assets/js/back-to-top.js
Normal 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'
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user