import { easeInOut, motion, useMotionTemplate, useScroll, useTransform, } from "framer-motion"; import { useEffect, useRef, useState } from "react"; import { cn } from "../../lib/utils"; interface SectionProps { text: string; image: OutputMetadata[]; left?: boolean; } const Section = ({ text, image, left }: SectionProps) => { const ref = useRef(null); const wrapperRef = useRef(null); const [width, setWidth] = useState(0); useEffect(() => { const resizeObserver = new ResizeObserver(() => { if (wrapperRef.current) { setWidth(wrapperRef.current.clientWidth); } }); if (wrapperRef.current) { resizeObserver.observe(wrapperRef.current); } return () => resizeObserver.disconnect(); }, []); const { scrollYProgress } = useScroll({ target: ref, }); const transform = useTransform(scrollYProgress, [0, 1], [-50, 50], { ease: easeInOut, }); const translateY = useMotionTemplate`${transform}px`; return (

{text}

`${i.src} ${i.width}w`).join(", ")} sizes={`${width}px`} loading="lazy" className="h-[80%]" />
); }; export default Section;