From bcee1a0f4615d90bd714adf8bea79baffe006579 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Wed, 29 Dec 2021 19:16:35 +0100 Subject: Added lightbox --- content/snow.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 content/snow.js (limited to 'content/snow.js') 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 @@ +(() => { + function createSnowFlake() { + setTimeout(() => createSnowFlake(), 50 / Math.log10(window.innerWidth / 1000 + 1)); + + if (document.hidden) { + return; + } + + 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() * 100 + '%'; + snowFlake.style.animationDuration = aniDuration + 'ms'; + snowFlake.style.opacity = Math.random(); + + setTimeout(() => snowFlake.remove(), aniDuration); + + snowFlake.appendChild(snowFlakeInner); + document.body.appendChild(snowFlake); + } + + createSnowFlake(); +})(); -- cgit v1.2.3-54-g00ecf