From b606dc4a036611019dd7a227e5bed24e7bbd4c10 Mon Sep 17 00:00:00 2001 From: kudinDmitriyUp Date: Fri, 22 May 2026 19:48:17 +0000 Subject: [PATCH] fix: Correct framer-motion import to motion/react --- src/components/sections/hero/HeroOverlay.tsx | 43 +++++++++++++++++--- 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/src/components/sections/hero/HeroOverlay.tsx b/src/components/sections/hero/HeroOverlay.tsx index e43ec5f..c887275 100644 --- a/src/components/sections/hero/HeroOverlay.tsx +++ b/src/components/sections/hero/HeroOverlay.tsx @@ -3,7 +3,8 @@ import HeroBackgroundSlot from "@/components/ui/HeroBackgroundSlot"; import TextAnimation from "@/components/ui/TextAnimation"; import ImageOrVideo from "@/components/ui/ImageOrVideo"; import AvatarGroup from "@/components/ui/AvatarGroup"; -import { useState, useEffect } from "react"; +import { useState, useEffect, useRef } from "react"; +import { motion } from "motion/react"; type HeroOverlayProps = { tag: string; @@ -27,15 +28,36 @@ const HeroOverlay = ({ avatarsLabel, }: HeroOverlayProps) => { const [currentImageIndex, setCurrentImageIndex] = useState(0); + const [progress, setProgress] = useState(0); + const intervalRef = useRef(null); + const imageDuration = 5000; // 5 seconds + + const startProgress = () => { + setProgress(0); + if (intervalRef.current) { + clearInterval(intervalRef.current); + } + intervalRef.current = setInterval(() => { + setProgress((prevProgress) => { + if (prevProgress >= 100) { + setCurrentImageIndex((prevIndex) => (prevIndex + 1) % imageSrcs.length); + return 0; + } + return prevProgress + (100 / (imageDuration / 100)); // Increment based on duration + }); + }, 100); // Update every 100ms + }; useEffect(() => { if (imageSrcs && imageSrcs.length > 1) { - const interval = setInterval(() => { - setCurrentImageIndex((prevIndex) => (prevIndex + 1) % imageSrcs.length); - }, 5000); // Change image every 5 seconds - return () => clearInterval(interval); + startProgress(); } - }, [imageSrcs]); + return () => { + if (intervalRef.current) { + clearInterval(intervalRef.current); + } + }; + }, [imageSrcs, currentImageIndex]); const currentImageSrc = imageSrcs ? imageSrcs[currentImageIndex] : undefined; @@ -63,6 +85,15 @@ const HeroOverlay = ({ aria-hidden="true" /> +
+ +
+
-- 2.49.1