mirror of
https://github.com/Fluffy-Bean/image-gallery.git
synced 2025-05-18 17:34:55 +00:00
Added "Top" button 👀
This commit is contained in:
parent
d6c9951233
commit
4ab1b39650
12 changed files with 78 additions and 13 deletions
11
scripts/top.js
Normal file
11
scripts/top.js
Normal 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";
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue