From f9a93abc98474fd50cebd7de81e992dcad85c318 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Sat, 25 Dec 2021 09:42:15 +0100 Subject: Snow improvements --- content/script.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'content') diff --git a/content/script.js b/content/script.js index df5a9c0..b972200 100644 --- a/content/script.js +++ b/content/script.js @@ -12,21 +12,22 @@ function createSnowFlake() { 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"); - snowFlake.classList.add("o-icon--snow"); - snowFlake.ariaHidden = true; + snowFlake.classList.add("o-icon", "o-icon--snow"); + snowFlake.setAttribute("aria-hidden", "true"); - snowFlake.style.width = Math.random() * 10 + 10 + 'px'; + snowFlake.style.fontSize = Math.random() * 0.5 + 0.7 + 'em'; snowFlake.style.left = Math.random() * window.innerWidth + 'px'; - snowFlake.style.animationDuration = Math.random() * 3 + 2 + 's'; + snowFlake.style.animationDuration = aniDuration + 'ms'; snowFlake.style.opacity = Math.random(); snowFlake.appendChild(snowFlakeInner); document.body.appendChild(snowFlake); - setTimeout(() => { snowFlake.remove(); }, 5000); + setTimeout(() => { snowFlake.remove(); }, aniDuration); } setInterval(createSnowFlake, 100); -- cgit v1.2.3-54-g00ecf