diff --git a/surfsense_web/components/ui/hero-carousel.tsx b/surfsense_web/components/ui/hero-carousel.tsx index b6ae85cb3..7f55b6857 100644 --- a/surfsense_web/components/ui/hero-carousel.tsx +++ b/surfsense_web/components/ui/hero-carousel.tsx @@ -1,6 +1,7 @@ "use client"; import { AnimatePresence, motion } from "motion/react"; +import { ChevronLeft, ChevronRight } from "lucide-react"; import { useCallback, useEffect, useRef, useState } from "react"; import { ExpandedGifOverlay, useExpandedGif } from "@/components/ui/expanded-gif-overlay"; @@ -164,7 +165,6 @@ function HeroCarouselCard({ function HeroCarousel() { const [activeIndex, setActiveIndex] = useState(0); - const [isPaused, setIsPaused] = useState(false); const [isGifExpanded, setIsGifExpanded] = useState(false); const [containerWidth, setContainerWidth] = useState(0); const [cardHeight, setCardHeight] = useState(420); @@ -180,6 +180,14 @@ function HeroCarousel() { [activeIndex] ); + const goToPrev = useCallback(() => { + goTo(activeIndex <= 0 ? carouselItems.length - 1 : activeIndex - 1); + }, [activeIndex, goTo]); + + const goToNext = useCallback(() => { + goTo(activeIndex >= carouselItems.length - 1 ? 0 : activeIndex + 1); + }, [activeIndex, goTo]); + useEffect(() => { const el = containerRef.current; if (!el) return; @@ -200,15 +208,6 @@ function HeroCarousel() { return () => observer.disconnect(); }, [activeIndex, containerWidth]); - useEffect(() => { - if (isPaused || isGifExpanded) return; - const timer = setTimeout(() => { - directionRef.current = "forward"; - setActiveIndex((prev) => (prev >= carouselItems.length - 1 ? 0 : prev + 1)); - }, 8000); - return () => clearTimeout(timer); - }, [activeIndex, isPaused, isGifExpanded]); - const cardWidth = containerWidth < 640 ? containerWidth * 0.85 @@ -254,14 +253,7 @@ function HeroCarousel() { return (
-
setIsPaused(true)} - onMouseLeave={() => setIsPaused(false)} - onTouchStart={() => setIsPaused(true)} - onTouchEnd={() => setIsPaused(false)} - > +
-
- {carouselItems.map((_, i) => ( - + +
+ {carouselItems.map((_, i) => ( +
+ +
);