yequari.com/static/js/winter.js

38 lines
881 B
JavaScript

console.log("winter");
const snowContent = ['&#10052', '&#10053', '&#10054']
const snowflake = '● '
const snowContainer = document.getElementById('winter');
const random = (num) => {
return Math.floor(Math.random() * num);
}
const getRandomStyles = () => {
const top = random(100);
const left = random(100);
const dur = random(10) + 10;
const size = random(15) + 15;
return `
top: -${top}%;
left: ${left}%;
font-size: ${size}px;
animation-duration: ${dur}s;
`;
}
const createSnow = (num) => {
for (var i = num; i > 0; i--) {
var snow = document.createElement("div");
snow.className = "snow";
snow.style.cssText = getRandomStyles();
snow.innerHTML = snowContent[random(2)];
// snow.innerHTML = snowflake;
snowContainer.append(snow);
}
}
window.addEventListener("load", () => {
createSnow(30)
});