btn back to top
All checks were successful
Deploy / Deploy to Production (push) Successful in 13s

This commit is contained in:
Julie Blanc 2026-02-23 18:12:04 +01:00
parent bdb60646d0
commit c59f4d93dd
11 changed files with 160 additions and 120 deletions

24
assets/js/back-to-top.js Normal file
View file

@ -0,0 +1,24 @@
export function backToTop(){
const btn = document.getElementById('btn--back-to-top');
if (!btn) return;
let lastY = window.scrollY;
let peakY = window.scrollY;
window.addEventListener('scroll', () => {
const currentY = window.scrollY;
if (currentY > lastY) {
peakY = currentY;
btn.classList.remove('is-visible');
} else {
if (currentY <= 800) {
btn.classList.remove('is-visible');
} else if (peakY - currentY >= 200 && peakY > 600) {
btn.classList.add('is-visible');
}
}
lastY = currentY;
}, { passive: true });
}

View file

@ -1,5 +1,6 @@
import { headerToggle, headerScrollVisibility } from './header.js';
import { copyLink } from './share.js';
import { backToTop } from './back-to-top.js';
import { themeToggle } from './themeToggle.js';
import { playVideo } from './hero-video.js';
import { initDropdowns } from './dropdown.js';
@ -14,6 +15,7 @@ window.onload = async function () {
headerToggle();
themeToggle();
backToTop();
copyLink();
playVideo();