MediaWiki:Common.js: Διαφορά μεταξύ των αναθεωρήσεων
Χωρίς σύνοψη επεξεργασίας |
Χωρίς σύνοψη επεξεργασίας |
||
Γραμμή 1: | Γραμμή 1: | ||
function reveal() { | $(function reveal() { | ||
var reveals = document.querySelectorAll(".reveal"); | var reveals = document.querySelectorAll(".reveal"); | ||
for (var i = 0; i < reveals.length; i++) { | for (var i = 0; i < reveals.length; i++) { | ||
var windowHeight = window.innerHeight; | var windowHeight = window.innerHeight-600; | ||
var elementTop = reveals[i].getBoundingClientRect().top; | var elementTop = reveals[i].getBoundingClientRect().top; | ||
var elementVisible = 150; | var elementVisible = 150; | ||
Γραμμή 13: | Γραμμή 13: | ||
} | } | ||
} | } | ||
} | }()); | ||
window.addEventListener("scroll", reveal); | window.addEventListener("scroll", reveal); |
Αναθεώρηση της 19:57, 15 Φεβρουαρίου 2023
$(function reveal() { var reveals = document.querySelectorAll(".reveal"); for (var i = 0; i < reveals.length; i++) { var windowHeight = window.innerHeight-600; var elementTop = reveals[i].getBoundingClientRect().top; var elementVisible = 150; if (elementTop < windowHeight - elementVisible) { reveals[i].classList.add("active"); } else { reveals[i].classList.remove("active"); } } }()); window.addEventListener("scroll", reveal);