mirror of
https://github.com/moku-project/Moku.git
synced 2026-06-13 09:19:56 -05:00
fix: read idleTimeoutMin from settings; clean up idle + splash canvas fixes
This commit is contained in:
@@ -290,6 +290,7 @@
|
||||
if (logW <= 0 || logH <= 0) return
|
||||
if (logW === lastLogW && logH === lastLogH && scale === lastScale) return
|
||||
lastLogW = logW; lastLogH = logH; lastScale = scale
|
||||
if (live) cleanup() // release old offscreen canvases before rebuilding at new size
|
||||
const built = buildCards(logW, logH)
|
||||
const stamps = built.cards.map(c => buildStamp(c, scale))
|
||||
const vig = buildVignette(logW, logH, scale)
|
||||
@@ -339,10 +340,25 @@
|
||||
function resume() { if (!paused) return; paused = false; raf = requestAnimationFrame(frame) }
|
||||
function onVis() { document.hidden ? pause() : resume() }
|
||||
|
||||
// clears all canvas contexts and nulls live state so the GC can collect the offscreen bitmaps
|
||||
function cleanup() {
|
||||
if (live) {
|
||||
live.stamps.forEach(canvas => {
|
||||
const c = canvas.getContext('2d')
|
||||
if (c) c.clearRect(0, 0, canvas.width, canvas.height)
|
||||
})
|
||||
const vigCtx = live.vignette.getContext('2d')
|
||||
if (vigCtx) vigCtx.clearRect(0, 0, live.vignette.width, live.vignette.height)
|
||||
}
|
||||
ctx.clearRect(0, 0, el.width, el.height)
|
||||
live = null
|
||||
}
|
||||
|
||||
document.addEventListener('visibilitychange', onVis)
|
||||
raf = requestAnimationFrame(frame)
|
||||
return () => {
|
||||
cancelAnimationFrame(raf)
|
||||
cleanup()
|
||||
extraCleanup?.()
|
||||
document.removeEventListener('visibilitychange', onVis)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user