diff --git a/src/views/Portfolio.svelte b/src/views/Portfolio.svelte index e6d7ef6..b8b8967 100644 --- a/src/views/Portfolio.svelte +++ b/src/views/Portfolio.svelte @@ -11,6 +11,8 @@ // --- State --- let currentIndex = $state(0) let sectionEl = $state(null) + let mockupEl = $state(null) + let mockupReady = $state(false) // --- Derived --- const isActive = $derived(slides.active?.id === 'portfolio') @@ -128,6 +130,21 @@ } }) + // --- Mockup priority: render gallery only after mockup is loaded --- + $effect(() => { + mockupReady = false + if (!mockupEl) return + const img = mockupEl.querySelector('img') + if (!img) return + if (img.complete && img.naturalWidth > 0) { + mockupReady = true + return + } + const onLoad = () => { mockupReady = true } + img.addEventListener('load', onLoad, { once: true }) + return () => img.removeEventListener('load', onLoad) + }) + // --- Effect: reset when slide deactivated --- // wasActive évite que clearAnchor() s'exécute au montage initial // (isActive est false avant l'initialisation des slides) @@ -147,9 +164,11 @@ {#key currentIndex} - + {#if mockupReady} + + {/if} {/key}
{#if currentProject} {#key currentIndex} - - + + {#if mockupReady} + + {/if} - -
+ +