blob: b972200c37e43a4302b58cb3d0076ad9e245132e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
let i = 0;
function createSnowFlake() {
const threshold = -10 * Math.log10(window.innerWidth / 1000);
if (++i < threshold) {
return;
}
i = 0;
const snowFlake = document.createElementNS("http://www.w3.org/2000/svg", "svg");
const snowFlakeInner = document.createElementNS("http://www.w3.org/2000/svg", "use");
const aniDuration = (Math.random() * 3 + 2) * 1000;
snowFlakeInner.setAttribute("href", "/symbols.svg#icon-asterisk");
snowFlake.classList.add("o-icon", "o-icon--snow");
snowFlake.setAttribute("aria-hidden", "true");
snowFlake.style.fontSize = Math.random() * 0.5 + 0.7 + 'em';
snowFlake.style.left = Math.random() * window.innerWidth + 'px';
snowFlake.style.animationDuration = aniDuration + 'ms';
snowFlake.style.opacity = Math.random();
snowFlake.appendChild(snowFlakeInner);
document.body.appendChild(snowFlake);
setTimeout(() => { snowFlake.remove(); }, aniDuration);
}
setInterval(createSnowFlake, 100);
|