backtotop

This commit is contained in:
troy
2022-02-14 12:23:22 +01:00
parent 8170b81554
commit d318faca2c
7 changed files with 104 additions and 7 deletions

2
backtotop.min.js vendored Normal file
View File

@@ -0,0 +1,2 @@
!function(){"use strict";function trackScroll(){var scrolled=window.pageYOffset,coords=document.documentElement.clientHeight;console.log(coords,scrolled),scrolled>coords&&goTopBtn.classList.add("back_to_top-show"),scrolled<coords&&goTopBtn.classList.remove("back_to_top-show")}function backToTop(){window.pageYOffset>0&&(window.scrollBy(0,-30),setTimeout(backToTop,0))}var goTopBtn=document.createElement("div");goTopBtn.id="back_to_top",goTopBtn.innerHTML="UP",document.body.appendChild(goTopBtn),window.addEventListener("scroll",trackScroll),goTopBtn.addEventListener("click",backToTop)}();
//# sourceMappingURL=backtotop.min.js.map