"use client"; import { useRef, useState, useEffect, useCallback } from "react"; const specs = [ { label: "Surface Area", value: "180m²" }, { label: "Energy Use", value: "15 kWh/m²" }, { label: "Solar Panels", value: "40 m²" }, { label: "Carbon Balance", value: "-20%" }, ]; export function EditorialSection() { const videoRef = useRef(null); const [scrollProgress, setScrollProgress] = useState(0); const rafRef = useRef(null); const updateParallax = useCallback(() => { if (!videoRef.current) return; const rect = videoRef.current.getBoundingClientRect(); const windowHeight = window.innerHeight; // Calculate when video enters and exits viewport const videoTop = rect.top; const videoBottom = rect.bottom; // Progress from 0 (entering viewport) to 1 (exiting viewport) if (videoBottom > 0 && videoTop < windowHeight) { const progress = 1 - (videoTop + rect.height / 2) / (windowHeight + rect.height); setScrollProgress(Math.max(0, Math.min(1, progress))); } }, []); useEffect(() => { const handleScroll = () => { if (rafRef.current) { cancelAnimationFrame(rafRef.current); } rafRef.current = requestAnimationFrame(updateParallax); }; window.addEventListener("scroll", handleScroll, { passive: true }); updateParallax(); return () => { window.removeEventListener("scroll", handleScroll); if (rafRef.current) { cancelAnimationFrame(rafRef.current); } }; }, [updateParallax]); // Parallax effect: video moves up as you scroll down const parallaxY = (scrollProgress - 0.5) * 30; // -15px to +15px range return (
{/* Newsletter Banner */} {/* Decorative Icons */}
{/* Full-width Video with Parallax */}
{/* Specs Grid */}
{specs.map((spec) => (

{spec.label}

{spec.value}

))}
); }