Difference between revisions of "MediaWiki:Common.js"
Jump to navigation
Jump to search
m |
m |
||
Line 5: | Line 5: | ||
document.addEventListener("scroll", function() { | document.addEventListener("scroll", function() { | ||
const isVisible = window.pageYOffset > 400; | const isVisible = window.pageYOffset > 400; | ||
− | |||
backToTop.style.opacity = isVisible ? '1' : '0'; | backToTop.style.opacity = isVisible ? '1' : '0'; | ||
+ | }); | ||
+ | backToTop.addEventListener("transitionstart", function() { | ||
+ | if (backToTop.style.opacity == 0) backToTop.hidden = false; | ||
}); | }); | ||
backToTop.addEventListener("transitionend", function() { | backToTop.addEventListener("transitionend", function() { |
Revision as of 01:15, 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';
});
backToTop.addEventListener("transitionstart", function() {
if (backToTop.style.opacity == 0) backToTop.hidden = false;
});
backToTop.addEventListener("transitionend", function() {
if (backToTop.style.opacity == 0) backToTop.hidden = true;
});
}