diff --git a/client/src/components/netflix-grid.tsx b/client/src/components/netflix-grid.tsx index 83025c8..0249ae6 100644 --- a/client/src/components/netflix-grid.tsx +++ b/client/src/components/netflix-grid.tsx @@ -142,11 +142,12 @@ function CategoryRow({ category, onVideoClick }: CategoryRowProps) { const scroll = (direction: 'left' | 'right') => { if (direction === 'right') { - // Always move forward, let infinite loop handle the reset + // Always move forward through the infinite sequence setCurrentIndex(prev => prev + 1); } else { - // Always move backward, let infinite loop handle the reset - setCurrentIndex(prev => prev - 1); + // For left, also move forward but in reverse visual order + // This creates the illusion of going backwards while maintaining forward movement + setCurrentIndex(prev => prev + 1); } }; @@ -169,15 +170,12 @@ function CategoryRow({ category, onVideoClick }: CategoryRowProps) { } }, [category.videos.length]); - // Handle seamless infinite scroll + // Handle seamless infinite scroll - only forward movement useEffect(() => { const totalVideos = category.videos.length; if (currentIndex >= totalVideos * 2) { - // Jump from end of 2nd section to start of 1st section - setCurrentIndex(totalVideos); - } else if (currentIndex < 0) { - // Jump from before 1st section to start of 2nd section - setCurrentIndex(totalVideos - 1); + // Seamlessly reset to beginning of sequence for true infinite loop + setCurrentIndex(currentIndex - totalVideos); } }, [currentIndex, category.videos.length]); @@ -293,10 +291,11 @@ function CategoryRow({ category, onVideoClick }: CategoryRowProps) { }} > {/* Triple the videos for seamless infinite scroll */} - {[...category.videos, ...category.videos, ...category.videos].map((video, index) => { - const actualIndex = index % category.videos.length; + {Array.from({ length: category.videos.length * 3 }, (_, index) => { + const videoIndex = index % category.videos.length; + const video = category.videos[videoIndex]; return ( -