commit afbf3af3f197db75f8546fcb6d53f6bcccbdb5db
parent fa8dd4214750f792c4315bc70fbcb4e7717590a5
Author: Joris Hartog <jorishartog@hotmail.com>
Date: Thu, 3 Sep 2026 13:20:13 +0200
Fix homepage scroll responsiveness
Diffstat:
| M | www/index.html | | | 63 | +-------------------------------------------------------------- |
1 file changed, 1 insertion(+), 62 deletions(-)
diff --git a/www/index.html b/www/index.html
@@ -724,7 +724,7 @@
.community-panel .button { width: 100%; }
}
@media (min-width: 821px) {
- html { scroll-snap-type: y mandatory; }
+ html { scroll-snap-type: y proximity; }
.hero, main > section { scroll-snap-align: start; scroll-snap-stop: always; }
.section-icon {
position: absolute;
@@ -978,66 +978,5 @@
</div>
</section>
</main>
- <script>
- (() => {
- const desktopMotion = window.matchMedia('(min-width: 821px) and (prefers-reduced-motion: no-preference)');
- const screens = [...document.querySelectorAll('.hero, main > section')];
- const headerOffset = 64;
- const gestureThreshold = 32;
- const gestureDebounceMs = 160;
- const scrollDurationMs = 800;
- let accumulatedDelta = 0;
- let gestureReset;
- let gestureConsumed = false;
- let scrollLocked = false;
- let scrollTargetIndex = null;
- let unlockTimer;
-
- const closestScreenIndex = () => screens.reduce((closest, screen, index) => {
- const distance = Math.abs(screen.getBoundingClientRect().top - headerOffset);
- return distance < closest.distance ? { index, distance } : closest;
- }, { index: 0, distance: Infinity }).index;
-
- const scheduleUnlock = (targetIndex) => {
- window.clearTimeout(unlockTimer);
- scrollLocked = true;
- scrollTargetIndex = targetIndex;
- unlockTimer = window.setTimeout(() => {
- scrollLocked = false;
- scrollTargetIndex = null;
- }, scrollDurationMs);
- };
-
- window.addEventListener('wheel', (event) => {
- if (!desktopMotion.matches || event.ctrlKey || Math.abs(event.deltaX) > Math.abs(event.deltaY)) return;
-
- event.preventDefault();
- window.clearTimeout(gestureReset);
- gestureReset = window.setTimeout(() => {
- accumulatedDelta = 0;
- gestureConsumed = false;
- }, gestureDebounceMs);
-
- if (gestureConsumed) return;
-
- accumulatedDelta += event.deltaY;
-
- if (Math.abs(accumulatedDelta) < gestureThreshold) return;
-
- const direction = Math.sign(accumulatedDelta);
- accumulatedDelta = 0;
- gestureConsumed = true;
- const currentIndex = scrollLocked && scrollTargetIndex !== null
- ? scrollTargetIndex
- : closestScreenIndex();
- const nextIndex = Math.max(0, Math.min(screens.length - 1, currentIndex + direction));
-
- if (nextIndex === currentIndex) return;
-
- scheduleUnlock(nextIndex);
- screens[nextIndex].scrollIntoView({ behavior: 'smooth', block: 'start' });
- }, { passive: false });
- })();
- </script>
</body>
</html>