'use client'; import React, { useState, useEffect, useRef } from 'react'; import Image from 'next/image'; interface AnimatedImageProps { src: string; alt: string; width?: number; height?: number; className?: string; priority?: boolean; } export default function AnimatedImage({ src, alt, width = 800, height = 600, className = '', priority = false, }: AnimatedImageProps) { const [isLoaded, setIsLoaded] = useState(false); const [isInView, setIsInView] = useState(false); const containerRef = useRef(null); useEffect(() => { const observer = new IntersectionObserver( (entries) => { entries.forEach((entry) => { if (entry.isIntersecting) { setIsInView(true); observer.disconnect(); } }); }, { threshold: 0.1 }, ); if (containerRef.current) { observer.observe(containerRef.current); } return () => observer.disconnect(); }, []); return (
{alt} setIsLoaded(true)} priority={priority} /> {/* Subtle reflection overlay */}
); }