Fix project scroll snap
Build and Deploy / build-deploy (push) Successful in 37s

This commit is contained in:
2026-08-09 19:20:31 +01:00
parent d01c44ea78
commit bd9068b882
2 changed files with 2 additions and 43 deletions
+1 -4
View File
@@ -21,10 +21,7 @@
html {
overflow-y: overlay;
}
html.snap-active {
scroll-snap-type: y mandatory;
scroll-snap-type: y proximity;
}
body {
+1 -39
View File
@@ -1,7 +1,7 @@
"use client";
import { useScroll } from "motion/react";
import { useEffect, useMemo, useRef } from "react";
import { useMemo, useRef } from "react";
import type { Project } from "@/content/projects";
import { DescriptionBackdrop, type DescriptionBand } from "./description-backdrop";
import { type Anchors, anchorsFor, peakProgressFor } from "./lifecycle";
@@ -153,44 +153,6 @@ const computeLayout = (projects: readonly Project[]): Layout => {
export const ProjectsStage = ({ projects }: ProjectsStageProps) => {
const sectionRef = useRef<HTMLDivElement>(null);
useEffect(() => {
const el = sectionRef.current;
if (!el) return;
const state = { topPassed: false, bottomActive: false };
const sync = () => {
document.documentElement.classList.toggle(
"snap-active",
state.topPassed && state.bottomActive,
);
};
const topObserver = new IntersectionObserver(
([entry]) => {
state.topPassed = entry.isIntersecting;
sync();
},
{ rootMargin: "0px 0px -100% 0px" },
);
const bottomObserver = new IntersectionObserver(
([entry]) => {
state.bottomActive = entry.isIntersecting;
sync();
},
{ rootMargin: "-100% 0px 0px 0px" },
);
topObserver.observe(el);
bottomObserver.observe(el);
return () => {
topObserver.disconnect();
bottomObserver.disconnect();
document.documentElement.classList.remove("snap-active");
};
}, []);
const { layers, anchors, sectionVh, snaps, bands, totalVh } = useMemo(
() => computeLayout(projects),
[projects],