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'