|
|
(19 intermediate revisions by one other user not shown) |
Line 1: |
Line 1: |
| /* Any JavaScript here will be loaded for all users on every page load. */
| |
| document.addEventListener("DOMContentLoaded", function () {
| |
| const container = document.body;
| |
|
| |
|
| function createSnowflake() {
| |
| const snowflake = document.createElement("div");
| |
| snowflake.className = "snowflake";
| |
| snowflake.innerHTML = "❄";
| |
| container.appendChild(snowflake);
| |
|
| |
| const animationDuration = Math.random() * 3 + 2; // between 2 and 5 seconds
| |
| snowflake.style.animation = `fall ${animationDuration}s linear infinite`;
| |
|
| |
| const startX = Math.random() * window.innerWidth;
| |
| snowflake.style.left = `${startX}px`;
| |
|
| |
| const endX = Math.random() * window.innerWidth;
| |
| const rotation = Math.random() * 360;
| |
| snowflake.style.transform = `translate(${endX}px, ${window.innerHeight}px) rotate(${rotation}deg)`;
| |
| }
| |
|
| |
| function createSnowflakes(quantity) {
| |
| for (let i = 0; i < quantity; i++) {
| |
| createSnowflake();
| |
| }
| |
| }
| |
|
| |
| createSnowflakes(50); // Adjust the quantity of snowflakes as needed
| |
| });
| |