From 49b7c580efa05267417533efa007bf35b908976c Mon Sep 17 00:00:00 2001 From: sebastjanartic <45803536-sebastjanartic@users.noreply.replit.com> Date: Fri, 29 Aug 2025 15:47:56 +0000 Subject: [PATCH] Improve the video carousel for smoother continuous playback Adjust the infinite loop logic in the Netflix grid component to ensure seamless circular motion for the video carousel. 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/QCN70f2 --- client/src/components/netflix-grid.tsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/client/src/components/netflix-grid.tsx b/client/src/components/netflix-grid.tsx index 33c0665..842bc61 100644 --- a/client/src/components/netflix-grid.tsx +++ b/client/src/components/netflix-grid.tsx @@ -168,11 +168,11 @@ function CategoryRow({ category, onVideoClick }: CategoryRowProps) { const newX = prev + speed; const totalWidth = category.videos.length * videoWidth; - // Infinite loop - seamless reset - if (direction === 'right' && newX <= -totalWidth * 2) { - return -totalWidth; + // Infinite loop - seamless reset for continuous circular motion + if (direction === 'right' && newX <= -totalWidth) { + return newX + totalWidth; // Add one full cycle to continue seamlessly } else if (direction === 'left' && newX >= 0) { - return -totalWidth; + return newX - totalWidth; // Subtract one full cycle to continue seamlessly } return newX; @@ -198,11 +198,11 @@ function CategoryRow({ category, onVideoClick }: CategoryRowProps) { const newX = prev + speed; const totalWidth = category.videos.length * videoWidth; - // Infinite loop - seamless reset - if (direction === 'right' && newX <= -totalWidth * 2) { - return -totalWidth; // Reset to middle section + // Infinite loop - seamless reset for continuous circular motion + if (direction === 'right' && newX <= -totalWidth) { + return newX + totalWidth; // Add one full cycle to continue seamlessly } else if (direction === 'left' && newX >= 0) { - return -totalWidth; // Reset to middle section + return newX - totalWidth; // Subtract one full cycle to continue seamlessly } return newX;