This commit is contained in:
+1
-4
@@ -21,10 +21,7 @@
|
||||
|
||||
html {
|
||||
overflow-y: overlay;
|
||||
}
|
||||
|
||||
html.snap-active {
|
||||
scroll-snap-type: y mandatory;
|
||||
scroll-snap-type: y proximity;
|
||||
}
|
||||
|
||||
body {
|
||||
|
||||
@@ -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],
|
||||
|
||||
Reference in New Issue
Block a user