From f96b52ca0c959d36d018094523992434bb286be2 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Fri, 25 Apr 2025 22:44:05 +0900 Subject: feat(blog/nuldoc): show static icon image until dynamic icon canvas is ready in /about/ page --- vhosts/blog/static/my-icon.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'vhosts/blog/static/my-icon.js') diff --git a/vhosts/blog/static/my-icon.js b/vhosts/blog/static/my-icon.js index 13086daf..52990cc5 100644 --- a/vhosts/blog/static/my-icon.js +++ b/vhosts/blog/static/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); -- cgit v1.2.3-70-g09d2