Différences entre versions de « MediaWiki:Common.js »
Sauter à la navigation
Sauter à la recherche
m |
m |
||
| Ligne 1 : | Ligne 1 : | ||
console.log("it's tiiiiiime"); | console.log("it's tiiiiiime"); | ||
| + | |||
var snowflakes = ["❄", "❅", "❆"]; | var snowflakes = ["❄", "❅", "❆"]; | ||
| − | + | function createSnowflake() { | |
| − | + | var snowflake = document.createElement('div'); | |
| − | + | snowflake.className = 'snowflake'; | |
| − | + | snowflake.innerHTML = snowflakes[Math.floor(Math.random() * snowflakes.length)]; | |
| − | + | snowflake.style.left = Math.random() * (document.documentElement.clientWidth || document.body.clientWidth) + 'px'; | |
| − | + | snowflake.style.top = '0'; | |
| − | + | ||
| + | // Trigger reflow to apply initial position before transitioning | ||
| + | void snowflake.offsetWidth; | ||
| + | |||
| + | snowflake.style.top = '100vh'; // Set the end position | ||
| + | document.body.appendChild(snowflake); | ||
| − | + | setTimeout(function () { | |
| − | + | document.body.removeChild(snowflake); | |
| − | + | }, 5000); | |
| − | + | } | |
| − | + | function generateSnowflakes() { | |
| − | + | for (var i = 0; i < 20; i++) { // Create initial snowflakes | |
| − | + | createSnowflake(); | |
| − | + | } | |
| − | + | setInterval(createSnowflake, 500); // Create a new snowflake every 500 milliseconds | |
| − | + | } | |
| − | + | generateSnowflakes(); | |
Version du 21 janvier 2024 à 16:33
console.log("it's tiiiiiime");
var snowflakes = ["❄", "❅", "❆"];
function createSnowflake() {
var snowflake = document.createElement('div');
snowflake.className = 'snowflake';
snowflake.innerHTML = snowflakes[Math.floor(Math.random() * snowflakes.length)];
snowflake.style.left = Math.random() * (document.documentElement.clientWidth || document.body.clientWidth) + 'px';
snowflake.style.top = '0';
// Trigger reflow to apply initial position before transitioning
void snowflake.offsetWidth;
snowflake.style.top = '100vh'; // Set the end position
document.body.appendChild(snowflake);
setTimeout(function () {
document.body.removeChild(snowflake);
}, 5000);
}
function generateSnowflakes() {
for (var i = 0; i < 20; i++) { // Create initial snowflakes
createSnowflake();
}
setInterval(createSnowflake, 500); // Create a new snowflake every 500 milliseconds
}
generateSnowflakes();