summaryrefslogtreecommitdiffstats
path: root/content/script.js
blob: df5a9c07d318849fb38a7a8c1633955c234821b2 (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
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");

    snowFlakeInner.setAttribute("href", "/symbols.svg#icon-asterisk");

    snowFlake.classList.add("o-icon");
    snowFlake.classList.add("o-icon--snow");
    snowFlake.ariaHidden = true;

	snowFlake.style.width = Math.random() * 10 + 10 + 'px';
	snowFlake.style.left = Math.random() * window.innerWidth + 'px';
	snowFlake.style.animationDuration = Math.random() * 3 + 2 + 's';
	snowFlake.style.opacity = Math.random();

    snowFlake.appendChild(snowFlakeInner);
	document.body.appendChild(snowFlake);

	setTimeout(() => { snowFlake.remove(); }, 5000);
}

setInterval(createSnowFlake, 100);