diff options
| -rw-r--r-- | content/script.js | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/content/script.js b/content/script.js index b972200..78b18b0 100644 --- a/content/script.js +++ b/content/script.js | |||
| @@ -1,14 +1,4 @@ | |||
| 1 | let i = 0; | ||
| 2 | |||
| 3 | function createSnowFlake() { | 1 | function createSnowFlake() { |
| 4 | const threshold = -10 * Math.log10(window.innerWidth / 1000); | ||
| 5 | |||
| 6 | if (++i < threshold) { | ||
| 7 | return; | ||
| 8 | } | ||
| 9 | |||
| 10 | i = 0; | ||
| 11 | |||
| 12 | const snowFlake = document.createElementNS("http://www.w3.org/2000/svg", "svg"); | 2 | const snowFlake = document.createElementNS("http://www.w3.org/2000/svg", "svg"); |
| 13 | const snowFlakeInner = document.createElementNS("http://www.w3.org/2000/svg", "use"); | 3 | const snowFlakeInner = document.createElementNS("http://www.w3.org/2000/svg", "use"); |
| 14 | 4 | ||
| @@ -27,7 +17,8 @@ function createSnowFlake() { | |||
| 27 | snowFlake.appendChild(snowFlakeInner); | 17 | snowFlake.appendChild(snowFlakeInner); |
| 28 | document.body.appendChild(snowFlake); | 18 | document.body.appendChild(snowFlake); |
| 29 | 19 | ||
| 30 | setTimeout(() => { snowFlake.remove(); }, aniDuration); | 20 | setTimeout(() => snowFlake.remove(), aniDuration); |
| 21 | setTimeout(() => createSnowFlake(), 50 / Math.log10(window.innerWidth / 1000 + 1)); | ||
| 31 | } | 22 | } |
| 32 | 23 | ||
| 33 | setInterval(createSnowFlake, 100); | 24 | createSnowFlake(); |
