From e377b33f7b1f88616b8a0ecab11f87605ed9947c Mon Sep 17 00:00:00 2001 From: sebastjanartic <45803536-sebastjanartic@users.noreply.replit.com> Date: Fri, 29 Aug 2025 17:24:26 +0000 Subject: [PATCH] Improve carousel scrolling speed and responsiveness Update the SimpleCarousel component to allow immediate speed changes and initialize scrolling with a defined speed value. 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/yexZbDm --- client/src/components/simple-carousel.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/client/src/components/simple-carousel.tsx b/client/src/components/simple-carousel.tsx index bdbe916..bbf5c76 100644 --- a/client/src/components/simple-carousel.tsx +++ b/client/src/components/simple-carousel.tsx @@ -24,16 +24,16 @@ export default function SimpleCarousel({ category, onVideoClick }: SimpleCarouse const newSpeed = speed === 'normal' ? 'fast' : 'normal'; setSpeed(newSpeed); - // Restart with new speed + // Restart with new speed immediately if (scrollIntervalRef.current) { clearInterval(scrollIntervalRef.current); } + const speedValue = newSpeed === 'fast' ? 1.2 : 0.6; scrollIntervalRef.current = setInterval(() => { if (!scrollContainerRef.current) return; - const currentSpeed = newSpeed === 'fast' ? 1.2 : 0.6; - const scrollAmount = direction === 'right' ? currentSpeed : -currentSpeed; + const scrollAmount = direction === 'right' ? speedValue : -speedValue; scrollContainerRef.current.scrollBy({ left: scrollAmount, behavior: 'auto' @@ -54,11 +54,11 @@ export default function SimpleCarousel({ category, onVideoClick }: SimpleCarouse setCurrentDirection(direction); setSpeed('normal'); // Reset to normal speed when starting + const speedValue = 0.6; // Always start with normal speed scrollIntervalRef.current = setInterval(() => { if (!scrollContainerRef.current) return; - const currentSpeed = speed === 'fast' ? 1.2 : 0.6; - const scrollAmount = direction === 'right' ? currentSpeed : -currentSpeed; + const scrollAmount = direction === 'right' ? speedValue : -speedValue; scrollContainerRef.current.scrollBy({ left: scrollAmount, behavior: 'auto'