diff --git a/client/src/components/netflix-grid.tsx b/client/src/components/netflix-grid.tsx index e6f45e1..aaa8086 100644 --- a/client/src/components/netflix-grid.tsx +++ b/client/src/components/netflix-grid.tsx @@ -179,6 +179,16 @@ function CategoryRow({ category, onVideoClick, hideScrollButtons = false }: Cate const [isScrolling, setIsScrolling] = useState(false); const scrollIntervalRef = useRef(); const [clickedVideoId, setClickedVideoId] = useState(null); + const [canScrollLeft, setCanScrollLeft] = useState(false); + const [canScrollRight, setCanScrollRight] = useState(true); + + const checkScrollButtons = () => { + if (scrollRef.current) { + const { scrollLeft, scrollWidth, clientWidth } = scrollRef.current; + setCanScrollLeft(scrollLeft > 0); + setCanScrollRight(scrollLeft < scrollWidth - clientWidth - 1); + } + }; const scroll = (direction: 'left' | 'right') => { if (scrollRef.current) { @@ -195,6 +205,9 @@ function CategoryRow({ category, onVideoClick, hideScrollButtons = false }: Cate left: targetScroll, behavior: 'smooth' }); + + // Check scroll buttons after animation completes + setTimeout(checkScrollButtons, 300); } }; @@ -221,12 +234,18 @@ function CategoryRow({ category, onVideoClick, hideScrollButtons = false }: Cate }; useEffect(() => { + checkScrollButtons(); + return () => { if (scrollIntervalRef.current) { clearInterval(scrollIntervalRef.current); } }; - }, []); + }, [category.videos]); + + const handleScroll = () => { + checkScrollButtons(); + }; return (
{/* Left scroll button - small circular on videos */} - {!hideScrollButtons && ( + {!hideScrollButtons && canScrollLeft && (