From de28ffe5ea0e587f8c66a1231541cfa761fce086 Mon Sep 17 00:00:00 2001 From: sebastjanartic <45803536-sebastjanartic@users.noreply.replit.com> Date: Fri, 29 Aug 2025 16:48:03 +0000 Subject: [PATCH] Enable seamless infinite scrolling for video carousels Implement infinite scrolling logic in `netflix-grid.tsx` to allow seamless horizontal navigation by wrapping the carousel content when it reaches its boundaries. 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/KcsXLXG --- client/src/components/netflix-grid.tsx | 28 ++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/client/src/components/netflix-grid.tsx b/client/src/components/netflix-grid.tsx index 1ca3000..21b9067 100644 --- a/client/src/components/netflix-grid.tsx +++ b/client/src/components/netflix-grid.tsx @@ -167,7 +167,19 @@ function CategoryRow({ category, onVideoClick }: CategoryRowProps) { // Use the NEW speed that was just set const currentSpeed = newSpeed === 'fast' ? 3.5 : 2.0; const speed = direction === 'right' ? -currentSpeed : currentSpeed; - return prev + speed; + 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; }); }, interval); } @@ -187,7 +199,19 @@ function CategoryRow({ category, onVideoClick }: CategoryRowProps) { // Faster speed for better movement const baseSpeed = 2.0; // Faster speed on hover const speed = direction === 'right' ? -baseSpeed : baseSpeed; - return prev + speed; + 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; }); }, 16); // Fixed interval - speed controlled by pixel movement only };