astrojs rewrite

This commit is contained in:
z0x 2024-10-26 18:00:28 -04:00
parent e7a707b4e2
commit 39c53b1bd1
20 changed files with 8110 additions and 26 deletions

27
src/js/snowflakes.ts Normal file
View file

@ -0,0 +1,27 @@
function createSnowflakes() {
const numSnowflakes = 50;
const maxSize = 0.2;
const maxTranslate = 10;
const container = document.getElementById('snowflake-container');
function randomBetween(min, max) {
return (Math.random() * max) + min;
}
if (container) {
for (let i = 0; i < numSnowflakes; i++) {
let randomSize = randomBetween(5, 25) + "px";
let randomLeft = randomBetween(0, window.innerWidth) + "px";
let randomDuration = randomBetween(3, 10);
const snowflake = document.createElement('div');
snowflake.classList.add('snowflake');
snowflake.style.width = randomSize;
snowflake.style.height = randomSize;
snowflake.style.left = randomLeft;
snowflake.style.animationDuration = randomDuration + "s";
snowflake.style.animationDelay = randomBetween(0, 5) + "s";
container.appendChild(snowflake);
}
}
}
createSnowflakes();