Concept Mill: keep the server-rendered ship dark on deep links

The server renders the first ship so the stage is never empty, but on a
slow connection a deep link showed it until the requested render decoded.
It now stays dark unless it is the ship the hash asks for.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-08 02:07:43 +02:00
commit 329311b356

View file

@ -208,7 +208,10 @@ function setup(root: HTMLElement) {
let liveRef = live
let nextRef = next
function swap(variant: Variant, ship: Ship) {
if (liveRef.getAttribute("src") === variant.image) return
if (liveRef.getAttribute("src") === variant.image) {
liveRef.classList.add("is-live")
return
}
const target = nextRef
target.alt = `Concept render of the ${ship.name}, ${variant.round}`
target.src = variant.image
@ -391,6 +394,9 @@ function setup(root: HTMLElement) {
stage.addEventListener("touchstart", onTouchStart, { passive: true })
stage.addEventListener("touchend", onTouchEnd, { passive: true })
// The server-rendered ship stays dark unless it is the one the hash asks
// for, so a slow deep link never shows the wrong ship first.
live.classList.remove("is-live")
const initial = parseHash()
select(initial?.i ?? 0, initial?.v, Boolean(initial))
root.classList.add("is-ready")