diff --git a/attached_assets/image_1756487569961.png b/attached_assets/image_1756487569961.png new file mode 100644 index 0000000..1d92294 Binary files /dev/null and b/attached_assets/image_1756487569961.png differ diff --git a/client/src/components/netflix-grid.tsx b/client/src/components/netflix-grid.tsx index 3cbae89..cc11649 100644 --- a/client/src/components/netflix-grid.tsx +++ b/client/src/components/netflix-grid.tsx @@ -164,25 +164,15 @@ function CategoryRow({ category, onVideoClick }: CategoryRowProps) { const interval = 16; // Fixed interval - speed controlled by pixel movement only scrollIntervalRef.current = setInterval(() => { - setTranslateX(prev => { - // Use the NEW speed that was just set - const currentSpeed = newSpeed === 'fast' ? 3.5 : 2.0; - const speed = direction === 'right' ? -currentSpeed : currentSpeed; - const newX = prev + speed; - const totalWidth = category.videos.length * videoWidth; - - // TRUE INFINITE SCROLL - wrap around seamlessly - if (direction === 'right' && newX <= -totalWidth) { - // When moved one full cycle to the right, wrap back to start - return newX + totalWidth; - } else if (direction === 'left' && newX >= totalWidth) { - // When moved one full cycle to the left, wrap back to end - return newX - totalWidth; - } - - return newX; + if (!scrollContainerRef.current) return; + + const currentSpeed = newSpeed === 'fast' ? 5 : 2; + const scrollAmount = direction === 'right' ? currentSpeed : -currentSpeed; + scrollContainerRef.current.scrollBy({ + left: scrollAmount, + behavior: 'auto' }); - }, interval); + }, 16); } }; @@ -196,33 +186,20 @@ function CategoryRow({ category, onVideoClick }: CategoryRowProps) { // Start continuous smooth scrolling with variable speed scrollIntervalRef.current = setInterval(() => { - setTranslateX(prev => { - // Faster speed for better movement - const baseSpeed = 2.0; // Faster speed on hover - const speed = direction === 'right' ? -baseSpeed : baseSpeed; - const newX = prev + speed; - const totalWidth = category.videos.length * videoWidth; - - // TRUE INFINITE SCROLL - wrap around seamlessly - if (direction === 'right' && newX <= -totalWidth) { - // When moved one full cycle to the right, wrap back to start - return newX + totalWidth; - } else if (direction === 'left' && newX >= totalWidth) { - // When moved one full cycle to the left, wrap back to end - return newX - totalWidth; - } - - return newX; + if (!scrollContainerRef.current) return; + + const baseSpeed = 3; // Faster speed on hover + const scrollAmount = direction === 'right' ? baseSpeed : -baseSpeed; + scrollContainerRef.current.scrollBy({ + left: scrollAmount, + behavior: 'auto' }); - }, 16); // Fixed interval - speed controlled by pixel movement only + }, 16); }; // Initialize with first video on the left side useEffect(() => { - if (category.videos.length > 0) { - // Start at position 0 - setTranslateX(0); - } + // No need to set initial position for scroll - browser handles it }, [category.videos.length]); // Always show both buttons