mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-19 22:09:37 +00:00
feat: preload images for adjacent rooms to prevent flash on navigate
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1649,6 +1649,35 @@
|
||||
renderMap()
|
||||
|
||||
addLog(`Entered: ${room.title}`)
|
||||
preloadAdjacentImages(room)
|
||||
}
|
||||
|
||||
// --- Image preloading ---
|
||||
const preloaded = new Set()
|
||||
|
||||
function preloadImage(src) {
|
||||
if (preloaded.has(src)) return
|
||||
preloaded.add(src)
|
||||
const img = new Image()
|
||||
img.src = src
|
||||
}
|
||||
|
||||
function preloadAdjacentImages(room) {
|
||||
for (const c of room.choices) {
|
||||
const target = rooms[c.room]
|
||||
if (!target) continue
|
||||
preloadImage(`images/${c.room}.png`)
|
||||
if (target.challenge) {
|
||||
for (const ch of target.challenge.choices) {
|
||||
if (ch.icon) preloadImage(`icons/${ch.icon}.png`)
|
||||
}
|
||||
}
|
||||
if (target.artifacts) {
|
||||
for (const a of target.artifacts) {
|
||||
if (a.icon) preloadImage(`icons/${a.icon}.png`)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function showChallenge(roomId, challenge) {
|
||||
|
||||
Reference in New Issue
Block a user