From 8d7b729744cf872c94a8c26d741fe8001efb65c4 Mon Sep 17 00:00:00 2001 From: Maaxxs <61059039+MaaxxsDev@users.noreply.github.com> Date: Tue, 22 Sep 2026 02:26:59 +0200 Subject: [PATCH] Custom scroll bar: gold progress rail on the right instead of the browser scrollbar - Thin rail that fills with gold while scrolling, click jumps to that position, drag scrolls along - Hidden when the page fits on the screen, browser scrollbar hidden (stays without JavaScript) Co-Authored-By: Claude Opus 5 --- assets/css/style.css | 43 +++++++++++++++++++++ assets/js/scroll-progress.js | 72 ++++++++++++++++++++++++++++++++++++ includes/footer.php | 2 + 3 files changed, 117 insertions(+) create mode 100644 assets/js/scroll-progress.js diff --git a/assets/css/style.css b/assets/css/style.css index 262ec1c..981b768 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -5643,3 +5643,46 @@ a.calendar-agenda-entry:hover { text-decoration: none; filter: brightness(1.2); .sidebar-link { padding: 0.38rem 0.75rem; font-size: 0.9rem; } .sidebar-link .icon { width: 17px; height: 17px; } } + +/* ---- Eigene Scroll-Leiste (assets/js/scroll-progress.js) ---- + Browser-Balken aus, stattdessen eine schmale Schiene rechts, die sich golden fuellt. */ +html.has-scroll-progress { scrollbar-width: none; } +html.has-scroll-progress::-webkit-scrollbar { display: none; } + +.scroll-progress { + position: fixed; + top: 0.75rem; + right: 4px; + bottom: 0.75rem; + width: 4px; + z-index: 900; + border-radius: 999px; + background: rgba(255, 255, 255, 0.06); + cursor: pointer; + touch-action: none; + transition: width 0.18s ease, background 0.18s ease, opacity 0.25s ease; +} +/* Etwas breitere Trefferflaeche zum Anklicken, ohne die Leiste dicker aussehen zu lassen */ +.scroll-progress::before { content: ''; position: absolute; inset: -6px -4px; } +.scroll-progress:hover, .scroll-progress.is-dragging { width: 8px; background: rgba(255, 255, 255, 0.1); } +.scroll-progress.is-hidden { opacity: 0; pointer-events: none; } + +.scroll-progress-fill { + position: absolute; + inset: 0; + border-radius: inherit; + background: linear-gradient(180deg, #f7e3a1 0%, var(--gold) 55%, #b8891f 100%); + box-shadow: 0 0 8px rgba(201, 162, 39, 0.55); + transform: scaleY(0); + transform-origin: top; + will-change: transform; +} +/* Unten angekommen: kurz aufleuchten */ +.scroll-progress.is-end .scroll-progress-fill { box-shadow: 0 0 12px rgba(247, 227, 161, 0.8); } + +@media (max-width: 860px) { + .scroll-progress { width: 3px; right: 2px; } +} +@media print { + .scroll-progress { display: none; } +} diff --git a/assets/js/scroll-progress.js b/assets/js/scroll-progress.js new file mode 100644 index 0000000..df4fc11 --- /dev/null +++ b/assets/js/scroll-progress.js @@ -0,0 +1,72 @@ +/** + * Eigene Scroll-Leiste statt des Browser-Scrollbalkens: eine schmale Schiene am rechten Rand, + * die sich beim Runterscrollen golden fuellt. Klicken springt an die Stelle, Ziehen scrollt mit. + * Der Browser-Balken ist per CSS ausgeblendet (html.has-scroll-progress) - erst wenn dieses Skript + * laeuft, sonst bliebe ohne JavaScript gar keine Leiste uebrig. + */ +(function () { + 'use strict'; + + var root = document.documentElement; + var rail = document.createElement('div'); + rail.className = 'scroll-progress'; + rail.setAttribute('aria-hidden', 'true'); + rail.innerHTML = '
'; + document.body.appendChild(rail); + root.classList.add('has-scroll-progress'); + + var fill = rail.firstChild; + var ticking = false; + + function maxScroll() { + return Math.max(0, root.scrollHeight - window.innerHeight); + } + + function update() { + ticking = false; + var max = maxScroll(); + // Passt die Seite ganz auf den Bildschirm, braucht es keine Leiste + rail.classList.toggle('is-hidden', max < 4); + var progress = max > 0 ? Math.min(1, Math.max(0, window.scrollY / max)) : 0; + fill.style.transform = 'scaleY(' + progress + ')'; + rail.classList.toggle('is-end', progress > 0.995); + } + + function schedule() { + if (!ticking) { + ticking = true; + window.requestAnimationFrame(update); + } + } + + window.addEventListener('scroll', schedule, { passive: true }); + window.addEventListener('resize', schedule); + // Nachladende Bilder/Inhalte aendern die Seitenhoehe + if (window.ResizeObserver) { + new ResizeObserver(schedule).observe(document.body); + } + update(); + + // Klicken und Ziehen: Position auf der Schiene -> Stelle auf der Seite + function scrollToPointer(clientY, smooth) { + var rect = rail.getBoundingClientRect(); + var ratio = Math.min(1, Math.max(0, (clientY - rect.top) / rect.height)); + window.scrollTo({ top: ratio * maxScroll(), behavior: smooth ? 'smooth' : 'auto' }); + } + + rail.addEventListener('pointerdown', function (event) { + event.preventDefault(); + rail.setPointerCapture(event.pointerId); + rail.classList.add('is-dragging'); + scrollToPointer(event.clientY, true); + }); + rail.addEventListener('pointermove', function (event) { + if (rail.classList.contains('is-dragging')) scrollToPointer(event.clientY, false); + }); + function stop(event) { + rail.classList.remove('is-dragging'); + if (rail.hasPointerCapture && rail.hasPointerCapture(event.pointerId)) rail.releasePointerCapture(event.pointerId); + } + rail.addEventListener('pointerup', stop); + rail.addEventListener('pointercancel', stop); +})(); diff --git a/includes/footer.php b/includes/footer.php index 0ff48bb..1a532da 100644 --- a/includes/footer.php +++ b/includes/footer.php @@ -7,5 +7,7 @@ + +