Added "Top" button 👀

This commit is contained in:
Michał Gdula 2022-07-26 13:34:48 +01:00
parent d6c9951233
commit 4ab1b39650
12 changed files with 78 additions and 13 deletions

11
scripts/top.js Normal file
View file

@ -0,0 +1,11 @@
button = document.getElementById("back-to-top");
window.onscroll = function() {scrollFunction()};
function scrollFunction() {
if (document.body.scrollTop > 300 || document.documentElement.scrollTop > 20) {
button.style.right = "1rem";
} else {
button.style.right = "-2.5rem";
}
}