Difference between revisions of "MediaWiki:Common.js"

From Frictional Wiki
Jump to navigation Jump to search
 
m
 
(14 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
/* Any JavaScript here will be loaded for all users on every page load. */
 
/* Any JavaScript here will be loaded for all users on every page load. */
console.log('test')
+
 
 +
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() {
 +
    backToTop.style.display = "block";
 +
  });
 +
  backToTop.addEventListener("transitionend", function() {
 +
    if (backToTop.style.opacity == 0) backToTop.style.display = "none";
 +
  });*/
 +
}

Latest revision as of 01:42, 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() {
    backToTop.style.display = "block";
  });
  backToTop.addEventListener("transitionend", function() {
    if (backToTop.style.opacity == 0) backToTop.style.display = "none";
  });*/
}