Difference between revisions of "MediaWiki:Common.js"
Jump to navigation
Jump to search
m |
m |
||
Line 6: | Line 6: | ||
const isVisible = window.pageYOffset > 400; | const isVisible = window.pageYOffset > 400; | ||
backToTop.style.opacity = isVisible ? '1' : '0'; | backToTop.style.opacity = isVisible ? '1' : '0'; | ||
− | if(isVisible) backToTop. | + | if(isVisible) backToTop.style.display = 'block'; |
− | else setTimeout(function() { backToTop. | + | else setTimeout(function() { backToTop.style.display = 'none'; }, 500); |
}); | }); | ||
} | } |
Revision as of 00:59, 29 August 2020
/* Any JavaScript here will be loaded for all users on every page load. */
const backToTop = document.getElementById("BackToTop");
if(backToTop) {
document.addEventListener("scroll", function() {
const isVisible = window.pageYOffset > 400;
backToTop.style.opacity = isVisible ? '1' : '0';
if(isVisible) backToTop.style.display = 'block';
else setTimeout(function() { backToTop.style.display = 'none'; }, 500);
});
}