Compare commits

..

No commits in common. "436a4371da29eb51b632c032f05b2580a6305a5a" and "01adf70585ba9d9967b2d5bd2f7198dfa4de358f" have entirely different histories.

2 changed files with 7 additions and 37 deletions

View file

@ -38,11 +38,10 @@
let resizeTimer = null
// Active la transition seulement après le premier paint à la bonne position.
// Double rAF : le premier laisse passer un paint avec le bon translateX,
// le second active is-animated — évite l'animation parasite au chargement.
// Sans ça, un chargement sur /expertise slide depuis l'accueil.
$effect(() => {
if (slides.all.length > 0 && !isReady) {
requestAnimationFrame(() => requestAnimationFrame(() => { isReady = true }))
requestAnimationFrame(() => { isReady = true })
}
})

View file

@ -11,31 +11,10 @@
let sectionEl = $state(null)
// --- Derived ---
const isActive = $derived(slides.active?.id === 'portfolio')
const projects = $derived(data?.projects ?? [])
const isActive = $derived(slides.active?.id === 'portfolio')
const projects = $derived(data?.projects ?? [])
const currentProject = $derived(projects[currentIndex] ?? null)
// Capture du hash synchrone avant que tout effect puisse le modifier
const initialHash = window.location.hash.slice(1)
// --- Ancres ---
function setAnchor(index) {
const slug = projects[index]?.slug
if (!slug) return
history.replaceState(null, '', '#' + slug)
}
function clearAnchor() {
history.replaceState(null, '', window.location.pathname + window.location.search)
}
// Initialisation depuis l'ancre URL — une seule fois quand projects est prêt
$effect(() => {
if (projects.length === 0 || !initialHash) return
const idx = projects.findIndex(p => p.slug === initialHash)
if (idx > 0) currentIndex = idx
})
// --- Scroll nav composable ---
const nav = createScrollNav({
isActive: () => isActive,
@ -45,7 +24,6 @@
: Math.max(currentIndex - 1, 0)
if (next === currentIndex) return false
currentIndex = next
setAnchor(next)
},
})
@ -62,17 +40,10 @@
})
// --- 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) {
wasActive = true
} else if (wasActive) {
if (!isActive) {
nav.reset()
currentIndex = 0
clearAnchor()
wasActive = false
}
})
</script>
@ -126,7 +97,7 @@
<button
class="portfolio-nav-item"
class:active={i === currentIndex}
onclick={() => { currentIndex = i; setAnchor(i) }}
onclick={() => { currentIndex = i }}
>
<span class="portfolio-nav-number">{String(i + 1).padStart(2, '0')}</span>
<img src={project.thumbnail} alt={project.title} />
@ -236,7 +207,7 @@
}
.portfolio-nav-item.active {
transform: scale(1.25) translateX(-50%);
transform: scale(1.25);
opacity: 1;
}