Wire up scroll to top button

This commit is contained in:
Jake Howard 2022-06-19 17:10:35 +01:00
parent 43bbb7fbcd
commit 294d5bd656
Signed by: jake
GPG key ID: 57AFB45680EDD477
3 changed files with 5 additions and 2 deletions

View file

@ -6,4 +6,8 @@ window.addEventListener("load", () => {
navbarBurger.classList.toggle("is-active"); navbarBurger.classList.toggle("is-active");
navbar.classList.toggle("is-active"); navbar.classList.toggle("is-active");
}); });
document.getElementById("scroll-top").addEventListener("click", () => {
window.scrollTo({ top: 0, behavior: "smooth" });
});
}); });

View file

@ -12,7 +12,6 @@
html, html,
body { body {
height: 100%; height: 100%;
overflow-y: auto;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }

View file

@ -33,7 +33,7 @@
</div> </div>
</div> </div>
</div> </div>
<button class="button is-radiusless">Top</button> <button class="button is-radiusless" id="scroll-top">Top <i class="fas fa-angle-up ml-2" aria-hidden="true"></i></button>
</div> </div>
</div> </div>
</div> </div>