diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-04-25 22:44:05 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-04-25 22:44:05 +0900 |
| commit | f96b52ca0c959d36d018094523992434bb286be2 (patch) | |
| tree | 9cd407f3039ef63420f318952fbe07b8ffdf0d33 /vhosts/blog/public/my-icon.js | |
| parent | b206b17dfffee47940d391dd8dfbcfd79cc6861e (diff) | |
| download | nsfisis.dev-f96b52ca0c959d36d018094523992434bb286be2.tar.gz nsfisis.dev-f96b52ca0c959d36d018094523992434bb286be2.tar.zst nsfisis.dev-f96b52ca0c959d36d018094523992434bb286be2.zip | |
feat(blog/nuldoc): show static icon image until dynamic icon canvas is ready in /about/ page
Diffstat (limited to 'vhosts/blog/public/my-icon.js')
| -rw-r--r-- | vhosts/blog/public/my-icon.js | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/vhosts/blog/public/my-icon.js b/vhosts/blog/public/my-icon.js index 13086daf..52990cc5 100644 --- a/vhosts/blog/public/my-icon.js +++ b/vhosts/blog/public/my-icon.js @@ -25,8 +25,7 @@ const init = () => { canvas.height = SIZE * DPR; canvas.style.width = `${SIZE}px`; canvas.style.height = `${SIZE}px`; - container.appendChild(canvas); - const ctx = canvas.getContext("2d"); + const ctx = canvas.getContext("2d", { willReadFrequently: true }); ctx.scale(DPR, DPR); let frameCount = 0; @@ -166,7 +165,12 @@ const init = () => { setTimeout(mainLoop, 1000 / FPS); } + mainLoop(); + while (container.firstChild) { + container.removeChild(container.firstChild); + } + container.appendChild(canvas); }; document.addEventListener("DOMContentLoaded", init); |
