Skip to content

Commit 132bbd1

Browse files
committed
perf: properly preload images
1 parent 969a184 commit 132bbd1

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

routes/stage-select/+page.svelte

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ onMount(() => {
5959
});
6060
</script>
6161

62+
<svelte:head>
63+
{#each blocks as { thumbnail }}
64+
<link rel="preload" as="image" href={thumbnail} />
65+
{/each}
66+
</svelte:head>
67+
6268
<div id="container" class="fixed inset-0">
6369
<div class="w-full h-full py-8 backdrop-blur-xs flex flex-col">
6470
<div class="">
@@ -128,19 +134,12 @@ onMount(() => {
128134
<!-- 画像を中央に配置 -->
129135
<div class="h-full">
130136
{#if search.selected !== null}
131-
{#key search.world}
132-
{#each blocks as block, idx}
133-
{@const stage = idx + 1}
134-
<img
135-
src={block.thumbnail}
136-
alt=""
137-
class={[
138-
"h-full skeleton",
139-
stage !== search.selected && "hidden",
140-
]}
141-
/>
142-
{/each}
143-
{/key}
137+
{@const block = blocks.find(
138+
(b, idx) => /* stage = idx + 1 */ idx + 1 === search.selected,
139+
)}
140+
{#if block}
141+
<img src={block.thumbnail} alt="" class="h-full skeleton" />
142+
{/if}
144143
{/if}
145144
</div>
146145
<!-- テキストを画像の右側に配置 -->

0 commit comments

Comments
 (0)