create template packages
All checks were successful
Deploy / Deploy to Production (push) Successful in 5m17s
All checks were successful
Deploy / Deploy to Production (push) Successful in 5m17s
This commit is contained in:
parent
f73b8cb90b
commit
aba8b4f37e
20 changed files with 414 additions and 526 deletions
59
assets/js/bottom-bar.js
Normal file
59
assets/js/bottom-bar.js
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
|
||||
|
||||
export function progressBar(){
|
||||
const bar = document.getElementById('progressBar');
|
||||
if (!bar) return;
|
||||
|
||||
window.addEventListener('scroll', () => {
|
||||
const scrollTop = window.scrollY;
|
||||
const docHeight = document.documentElement.scrollHeight - window.innerHeight;
|
||||
const progress = docHeight > 0 ? (scrollTop / docHeight) * 100 : 0;
|
||||
bar.style.width = `${progress}vw`;
|
||||
}, { passive: true });
|
||||
}
|
||||
|
||||
|
||||
export function scrollBack(){
|
||||
const bottomBar = document.getElementById('bottom-bar');
|
||||
const navInvestigation = document.getElementById('nav-investigation');
|
||||
const header = document.getElementById('site-header');
|
||||
const footerEl = document.getElementById('support-bar') || document.getElementById('site-footer');
|
||||
|
||||
let lastY = window.scrollY;
|
||||
let peakY = window.scrollY;
|
||||
let visible = false;
|
||||
|
||||
window.addEventListener('scroll', () => {
|
||||
const currentY = window.scrollY;
|
||||
|
||||
// header : basé uniquement sur la position absolue
|
||||
if (navInvestigation && header) {
|
||||
header.classList.toggle('has-nav-investigation', currentY >= 160);
|
||||
}
|
||||
|
||||
// zone footer : bottom-bar masquée et verrouillée
|
||||
const inFooterZone = footerEl && (currentY + window.innerHeight >= footerEl.offsetTop);
|
||||
|
||||
if (inFooterZone) {
|
||||
if (visible) {
|
||||
visible = false;
|
||||
if (bottomBar) bottomBar.classList.remove('is-visible');
|
||||
}
|
||||
} else if (currentY > lastY) {
|
||||
// scroll bas
|
||||
peakY = currentY;
|
||||
if (!visible && currentY > 280) {
|
||||
visible = true;
|
||||
if (bottomBar) bottomBar.classList.add('is-visible');
|
||||
}
|
||||
} else {
|
||||
// scroll haut : hide après 200px remontés
|
||||
if (visible && peakY - currentY >= 200) {
|
||||
visible = false;
|
||||
if (bottomBar) bottomBar.classList.remove('is-visible');
|
||||
}
|
||||
}
|
||||
|
||||
lastY = currentY;
|
||||
}, { passive: true });
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue