"use client"; import Image from "next/image"; import { useEffect, useRef, useState } from "react"; const stages = [ { tab: "Roots In UP", title: "Roots in Uttar Pradesh", sub: "Homes, festivals and the culture we carry within.", img: "/img/home_10_.jpg" }, { tab: "Cities", title: "New Cities, New Beginnings", sub: "Arriving in North Texas with hope and ambition.", img: "/img/home_9_.jpg" }, { tab: "The Journey", title: "The Journey Together", sub: "A WhatsApp message becomes a parivaar.", img: "/img/home_14_.jpg" }, { tab: "Dallas", title: "Rooted in Dallas", sub: "Thousands of families, dozens of events.", img: "/img/home_6_.jpg" }, { tab: "UP Parivar", title: "One UP Parivar", sub: "A trusted network fostering belonging.", img: "/img/home_5_.jpg" }, { tab: "Future", title: "A Borderless Future", sub: "Connection and cultural pride, worldwide.", img: "/img/home_2_.jpg" }, ]; export default function JourneyBanner() { const [active, setActive] = useState(0); const sectionRef = useRef(null); useEffect(() => { let frame = 0; const onScroll = () => { if (frame) return; frame = requestAnimationFrame(() => { frame = 0; const el = sectionRef.current; if (!el) return; const rect = el.getBoundingClientRect(); const total = rect.height - window.innerHeight; const scrolled = Math.min(Math.max(-rect.top, 0), total); const progress = total > 0 ? scrolled / total : 0; const idx = Math.min(stages.length - 1, Math.floor(progress * stages.length)); setActive(idx); }); }; onScroll(); window.addEventListener("scroll", onScroll, { passive: true }); window.addEventListener("resize", onScroll); return () => { window.removeEventListener("scroll", onScroll); window.removeEventListener("resize", onScroll); if (frame) cancelAnimationFrame(frame); }; }, []); const current = stages[active]; return (
{stages.map((s, i) => (
{s.title}
))}
◉ Our Journey

{current.title}

{current.sub}

{stages.map((s, i) => (

{s.tab}

Melas, garba nights.

))}
); }