diff --git a/themes/intotheeast/templates/trip.html.twig b/themes/intotheeast/templates/trip.html.twig index 7a9ceaf..231d9d7 100644 --- a/themes/intotheeast/templates/trip.html.twig +++ b/themes/intotheeast/templates/trip.html.twig @@ -559,8 +559,28 @@ function parseGpxFiles(urls, callback) { }); } })(); + +/* ── Back to top ─────────────────────────────────────────── */ +document.addEventListener('DOMContentLoaded', function () { + var btn = document.getElementById('trip-totop'); + if (!btn) return; + var threshold = window.innerHeight * 0.8; + var shown = false; + btn.addEventListener('click', function () { + window.scrollTo({ top: 0, behavior: 'smooth' }); + }); + window.addEventListener('scroll', function () { + var shouldShow = window.scrollY > threshold; + if (shouldShow !== shown) { + shown = shouldShow; + btn.classList.toggle('is-visible', shown); + } + }, { passive: true }); +}); + +