ScrollTo function
This commit is contained in:
parent
39673d1c12
commit
a66afce9f4
1 changed files with 10 additions and 1 deletions
|
|
@ -1,5 +1,10 @@
|
||||||
function ScrollTo() {
|
function ScrollTo(element) {
|
||||||
|
|
||||||
|
/* Scroll to the element top */
|
||||||
|
element.ScrollTo({
|
||||||
|
top: 0,
|
||||||
|
behavior: "smooth"
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function ShowElement(element) {
|
function ShowElement(element) {
|
||||||
|
|
@ -36,4 +41,8 @@ document.addEventListener("scroll", () => {
|
||||||
document.querySelector(".scroll-up-button"),
|
document.querySelector(".scroll-up-button"),
|
||||||
/* How far the user has to scroll to show the element */
|
/* How far the user has to scroll to show the element */
|
||||||
0.50);
|
0.50);
|
||||||
|
});
|
||||||
|
|
||||||
|
document.querySelector(".scroll-up-button").addEventListener("click", () => {
|
||||||
|
ScrollTo(document.documentElement);
|
||||||
});
|
});
|
||||||
Loading…
Reference in a new issue