From cf560a4003b1136c68cd5cd797b57522c4ac9a2b Mon Sep 17 00:00:00 2001 From: sebastjanartic <45803536-sebastjanartic@users.noreply.replit.com> Date: Fri, 29 Aug 2025 14:56:19 +0000 Subject: [PATCH] Improve video carousel behavior for a smoother viewing experience Refactors the `CategoryRow` component in `netflix-grid.tsx` to implement infinite scrolling for the video carousel. This includes replacing the `getVisibleVideos` function with a `useEffect` hook to handle resetting the `currentIndex` when it exceeds the total number of videos, and updating the JSX to render a duplicated array of videos with a dynamic `translateX` transform for seamless looping. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 2eb1084e-b728-4449-9231-f1665924c8d5 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/8cc42625-c1f5-4e43-99bd-77f2c4dedee2/2eb1084e-b728-4449-9231-f1665924c8d5/QCN70f2 --- client/src/components/netflix-grid.tsx | 33 +++++++++++++------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/client/src/components/netflix-grid.tsx b/client/src/components/netflix-grid.tsx index bda81db..bda5228 100644 --- a/client/src/components/netflix-grid.tsx +++ b/client/src/components/netflix-grid.tsx @@ -157,20 +157,16 @@ function CategoryRow({ category, onVideoClick }: CategoryRowProps) { scroll(direction); }; - // Get visible videos based on current index - const getVisibleVideos = () => { + // Handle infinite scroll reset + useEffect(() => { const totalVideos = category.videos.length; - const visible = []; - - for (let i = 0; i < videosToShow; i++) { - const index = (currentIndex + i) % totalVideos; - visible.push({ - ...category.videos[index], - displayIndex: i - }); + if (currentIndex >= totalVideos) { + // Reset to beginning for infinite loop + setTimeout(() => { + setCurrentIndex(0); + }, 500); // After animation completes } - return visible; - }; + }, [currentIndex, category.videos.length]); // Always show both buttons useEffect(() => { @@ -271,11 +267,16 @@ function CategoryRow({ category, onVideoClick }: CategoryRowProps) { {/* Carousel video row */} -