import { domAnimation, LazyMotion, m, useAnimation, useReducedMotion } from 'framer-motion' import Image from 'next/image' import { useState, useEffect } from 'react' import ImageType from '../../interfaces/image' import { getAnimationProps } from '../Transitions' import styles from './index.module.css' const animationVariants = { initial: { opacity: 0 }, enter: { opacity: 1 }, exit: { opacity: 0 } } export default function ProjectImage({ image, alt, sizes, className }: { image: ImageType alt: string sizes: string className?: string }) { const [loaded, setLoaded] = useState(false) const animationControls = useAnimation() const shouldReduceMotion = useReducedMotion() const animationProps = getAnimationProps(shouldReduceMotion) useEffect(() => { if (loaded && animationControls) { animationControls.start('enter') } }, [loaded, animationControls]) return image ? ( {alt} setLoaded(true)} /> ) : null }