portfolio : preload all project media on slide activation. related to #55
All checks were successful
Deploy / Deploy to Production (push) Successful in 21s
All checks were successful
Deploy / Deploy to Production (push) Successful in 21s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
fe348f1e48
commit
f3ce36b99c
1 changed files with 16 additions and 0 deletions
|
|
@ -128,12 +128,28 @@
|
|||
}
|
||||
})
|
||||
|
||||
// --- Préchargement de tous les médias au premier passage ---
|
||||
let preloaded = false
|
||||
|
||||
function preloadAll() {
|
||||
for (const project of projects) {
|
||||
if (project.mockup) new Image().src = project.mockup
|
||||
if (project.mockupWebp) new Image().src = project.mockupWebp
|
||||
if (project.galleryBackgroundImage) new Image().src = project.galleryBackgroundImage
|
||||
for (const img of (project.imagesGallery ?? [])) {
|
||||
if (img.src) new Image().src = img.src
|
||||
if (img.webp) new Image().src = img.webp
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- Effect: reset when slide deactivated ---
|
||||
// wasActive évite que clearAnchor() s'exécute au montage initial
|
||||
// (isActive est false avant l'initialisation des slides)
|
||||
let wasActive = false
|
||||
$effect(() => {
|
||||
if (isActive) {
|
||||
if (!preloaded) { preloaded = true; preloadAll() }
|
||||
wasActive = true
|
||||
} else if (wasActive) {
|
||||
nav.reset()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue