summaryrefslogtreecommitdiffstats
path: root/content/assets/snow.js
diff options
context:
space:
mode:
Diffstat (limited to 'content/assets/snow.js')
-rw-r--r--content/assets/snow.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/content/assets/snow.js b/content/assets/snow.js
new file mode 100644
index 0000000..562e9c0
--- /dev/null
+++ b/content/assets/snow.js
@@ -0,0 +1,30 @@
1(() => {
2 function createSnowFlake() {
3 setTimeout(() => createSnowFlake(), 50 / Math.log10(window.innerWidth / 1000 + 1));
4
5 if (document.hidden) {
6 return;
7 }
8
9 const snowFlake = document.createElementNS("http://www.w3.org/2000/svg", "svg");
10 const snowFlakeInner = document.createElementNS("http://www.w3.org/2000/svg", "use");
11 const aniDuration = (Math.random() * 3 + 2) * 1000;
12
13 snowFlakeInner.setAttribute("href", "/icons.svg#asterisk");
14
15 snowFlake.classList.add("o-icon", "o-icon--snow");
16 snowFlake.setAttribute("aria-hidden", "true");
17
18 snowFlake.style.fontSize = Math.random() * 0.5 + 0.7 + 'em';
19 snowFlake.style.left = Math.random() * 100 + '%';
20 snowFlake.style.animationDuration = aniDuration + 'ms';
21 snowFlake.style.opacity = Math.random();
22
23 setTimeout(() => snowFlake.remove(), aniDuration);
24
25 snowFlake.appendChild(snowFlakeInner);
26 document.body.appendChild(snowFlake);
27 }
28
29 createSnowFlake();
30})();