diff --git a/client/src/components/netflix-grid.tsx b/client/src/components/netflix-grid.tsx index 8dcda35..00e4445 100644 --- a/client/src/components/netflix-grid.tsx +++ b/client/src/components/netflix-grid.tsx @@ -149,9 +149,19 @@ function CategoryRow({ category, onVideoClick }: CategoryRowProps) { let targetScroll; if (direction === 'left') { - targetScroll = Math.max(0, currentScroll - scrollAmount); + if (currentScroll <= 10) { + // Jump to end for infinite loop + targetScroll = maxScroll; + } else { + targetScroll = currentScroll - scrollAmount; + } } else { - targetScroll = Math.min(maxScroll, currentScroll + scrollAmount); + if (currentScroll >= maxScroll - 10) { + // Jump to beginning for infinite loop + targetScroll = 0; + } else { + targetScroll = currentScroll + scrollAmount; + } } container.scrollTo({ @@ -166,14 +176,9 @@ function CategoryRow({ category, onVideoClick }: CategoryRowProps) { }; const checkScrollPosition = () => { - if (!scrollRef.current) return; - - const container = scrollRef.current; - const currentScroll = container.scrollLeft; - const maxScroll = container.scrollWidth - container.clientWidth; - - setShowLeftButton(currentScroll > 10); // Show left if not at start - setShowRightButton(currentScroll < maxScroll - 10); // Show right if not at end + // Always show both buttons for infinite carousel + setShowLeftButton(true); + setShowRightButton(true); }; // Check scroll position on mount and when videos change @@ -208,7 +213,7 @@ function CategoryRow({ category, onVideoClick }: CategoryRowProps) { onMouseLeave={(e) => { e.stopPropagation(); }} - className={`${showLeftButton ? 'opacity-0 group-hover:opacity-100 hover:!opacity-100' : 'hidden'} flex absolute left-2 top-[45%] -translate-y-1/2 w-12 h-12 z-30 bg-black/80 hover:bg-black/95 rounded-full items-center justify-center transition-all duration-300 cursor-pointer border border-white/30 shadow-lg`} + className="flex absolute left-2 top-[45%] -translate-y-1/2 w-12 h-12 z-30 bg-black/80 hover:bg-black/95 rounded-full items-center justify-center transition-all duration-300 cursor-pointer border border-white/30 shadow-lg opacity-0 group-hover:opacity-100 hover:!opacity-100" data-testid="button-scroll-left" > @@ -227,7 +232,7 @@ function CategoryRow({ category, onVideoClick }: CategoryRowProps) { onMouseLeave={(e) => { e.stopPropagation(); }} - className={`${showRightButton ? 'opacity-0 group-hover:opacity-100 hover:!opacity-100' : 'hidden'} flex absolute right-2 top-[45%] -translate-y-1/2 w-12 h-12 z-30 bg-black/80 hover:bg-black/95 rounded-full items-center justify-center transition-all duration-300 cursor-pointer border border-white/30 shadow-lg`} + className="flex absolute right-2 top-[45%] -translate-y-1/2 w-12 h-12 z-30 bg-black/80 hover:bg-black/95 rounded-full items-center justify-center transition-all duration-300 cursor-pointer border border-white/30 shadow-lg opacity-0 group-hover:opacity-100 hover:!opacity-100" data-testid="button-scroll-right" >