diff options
author | Volpeon <git@volpeon.ink> | 2021-12-29 19:16:35 +0100 |
---|---|---|
committer | Volpeon <git@volpeon.ink> | 2021-12-29 19:16:35 +0100 |
commit | bcee1a0f4615d90bd714adf8bea79baffe006579 (patch) | |
tree | 2cd6b6cd74a47420a4b4a5b0eedb5ae185d91a05 /content/snow.js | |
parent | Initial gallery macro (diff) | |
download | volpeon.ink-bcee1a0f4615d90bd714adf8bea79baffe006579.tar.gz volpeon.ink-bcee1a0f4615d90bd714adf8bea79baffe006579.tar.bz2 volpeon.ink-bcee1a0f4615d90bd714adf8bea79baffe006579.zip |
Added lightbox
Diffstat (limited to 'content/snow.js')
-rw-r--r-- | content/snow.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/content/snow.js b/content/snow.js new file mode 100644 index 0000000..5913d1e --- /dev/null +++ b/content/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", "/symbols.svg#icon-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 | })(); | ||