feat: add to top button as an option

This commit is contained in:
Henk Verlinde
2022-06-21 20:52:44 +02:00
parent 75d250b240
commit dd6f7b578b
4 changed files with 32 additions and 0 deletions

20
assets/js/to-top.js Normal file
View File

@ -0,0 +1,20 @@
var topbutton = document.getElementById('toTop');
if (topbutton !== null) {
topbutton.style.display = 'none';
window.onscroll = function() {
scrollFunction()
};
}
function scrollFunction() {
if (document.body.scrollTop > 40 || document.documentElement.scrollTop > 40) {
topbutton.style.display = 'block';
} else {
topbutton.style.display = 'none';
}
}