Compare commits
No commits in common. "edc3e3db1d83cfcd6fc744ba79112dae944ea502" and "689ec3b138c7d75e0352cd612770508e29024278" have entirely different histories.
edc3e3db1d
...
689ec3b138
2 changed files with 3 additions and 17 deletions
|
|
@ -64,12 +64,6 @@
|
||||||
img.src = BG_URL
|
img.src = BG_URL
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sync body[data-template] with the active template so CSS selectors (e.g. footer hide)
|
|
||||||
// stay correct on SPA navigation — PHP only sets it on the initial page load.
|
|
||||||
$effect(() => {
|
|
||||||
if (activeTemplate) document.body.dataset.template = activeTemplate
|
|
||||||
})
|
|
||||||
|
|
||||||
// Active la transition seulement après le premier paint à la bonne position.
|
// Active la transition seulement après le premier paint à la bonne position.
|
||||||
// Double rAF : le premier laisse passer un paint avec le bon translateX,
|
// Double rAF : le premier laisse passer un paint avec le bon translateX,
|
||||||
// le second active is-animated — évite l'animation parasite au chargement.
|
// le second active is-animated — évite l'animation parasite au chargement.
|
||||||
|
|
|
||||||
|
|
@ -23,23 +23,15 @@
|
||||||
function onScroll() {
|
function onScroll() {
|
||||||
if (rafId) return
|
if (rafId) return
|
||||||
rafId = requestAnimationFrame(() => {
|
rafId = requestAnimationFrame(() => {
|
||||||
const scrollHeight = scrollableContainer.scrollHeight
|
const threshold = window.innerWidth > 800 ? 100 : 200
|
||||||
const clientHeight = scrollableContainer.clientHeight
|
const atBottom = scrollableContainer.scrollTop >= scrollableContainer.scrollHeight - scrollableContainer.clientHeight - threshold
|
||||||
const threshold = window.innerWidth > 800 ? 100 : 200
|
|
||||||
// Only show footer when content actually overflows AND user is near the bottom.
|
|
||||||
// Without the overflow guard, atBottom is true even when scrollHeight === clientHeight
|
|
||||||
// (0 >= 0 - threshold), causing the footer to appear on pages with no scroll.
|
|
||||||
const overflows = scrollHeight > clientHeight
|
|
||||||
const atBottom = overflows && scrollableContainer.scrollTop >= scrollHeight - clientHeight - threshold
|
|
||||||
isHidden = !atBottom
|
isHidden = !atBottom
|
||||||
rafId = null
|
rafId = null
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
scrollableContainer.addEventListener('scroll', onScroll)
|
scrollableContainer.addEventListener('scroll', onScroll)
|
||||||
// No immediate onScroll() call: footer starts hidden and only reveals when
|
onScroll()
|
||||||
// the user actively scrolls near the bottom. Calling it immediately caused
|
|
||||||
// the footer to flash on page load when content barely exceeded the threshold.
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
scrollableContainer.removeEventListener('scroll', onScroll)
|
scrollableContainer.removeEventListener('scroll', onScroll)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue