"use client" import { useGSAP } from '@gsap/react' import gsap from 'gsap' import Image from 'next/image' import React, { useRef, useState } from 'react' const Hero = () => { const lettersRef = useRef([]) const odysseyRef = useRef(null) const outerDivRef = useRef(null) const innerDivRef = useRef(null) const [currentImageIndex, setCurrentImageIndex] = useState(0) const images = ["/astro1.jpg", "/astro2.jpeg", "/astro3.jpeg", "/astro5.jpg",] useGSAP(() => { const tl = gsap.timeline() const changeSlide = () => { tl.to(innerDivRef.current, { x: "-100%", duration: 1, ease: "power2.inOut", delay: 5, onComplete: () => { setCurrentImageIndex((prev) => (prev + 1) % images.length) gsap.set(innerDivRef.current, {x: "100%"}) } }) tl.to(innerDivRef.current, { x: "0%", duration: 1, ease: "power2.inOut" }) } const interval = setInterval(changeSlide, 2000); changeSlide() tl.to(lettersRef.current, { x: 0, opacity: 1, stagger: 0.1, duration: 1 }).to(odysseyRef.current, { x: 0, opacity: 1, duration: 1 }).to(outerDivRef.current, { y: 0, opacity: 1, scale: 1, duration: 1.2 }) }, []) return (
{'OCEAN'.split("").map((letter, index) => ( (lettersRef.current[index] = el)} className='inline-block opacity-0 translate-x-[200px]'> {letter} ))}

ODYSSEY

THE BEST

IN THE WORLD

) } export default Hero