diff --git a/client/src/components/simple-carousel.tsx b/client/src/components/simple-carousel.tsx index 82acf33..690f6b1 100644 --- a/client/src/components/simple-carousel.tsx +++ b/client/src/components/simple-carousel.tsx @@ -1,4 +1,4 @@ -import { useState, useRef } from "react"; +import { useState, useRef, useEffect } from "react"; import { type Video } from "@shared/schema"; import VideoCard from "./video-card"; import { ChevronLeft, ChevronRight } from "lucide-react"; @@ -53,6 +53,25 @@ export default function SimpleCarousel({ category, onVideoClick }: SimpleCarouse setIsScrolling(false); }; + // Initialize scroll position in the middle so we can scroll both ways + useEffect(() => { + if (scrollContainerRef.current && category.videos.length > 0) { + // Wait for content to load, then scroll to middle + setTimeout(() => { + if (scrollContainerRef.current) { + const containerWidth = scrollContainerRef.current.scrollWidth; + const viewportWidth = scrollContainerRef.current.clientWidth; + const middlePosition = (containerWidth - viewportWidth) / 2; + + scrollContainerRef.current.scrollTo({ + left: middlePosition, + behavior: 'auto' + }); + } + }, 100); + } + }, [category.videos.length]); + return (