Improve video carousel scrolling with automatic hover activation

Update the `CategoryRow` component in `netflix-grid.tsx` to implement continuous auto-scrolling of the video carousel when the user hovers over the scroll buttons. This includes clearing existing intervals and setting a new interval for automatic scrolling every 800ms, enhancing the user experience by making the carousel more interactive.

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
This commit is contained in:
sebastjanartic 2025-08-29 14:59:10 +00:00
parent 2661fbb169
commit ed3142e721

View File

@ -151,8 +151,15 @@ function CategoryRow({ category, onVideoClick }: CategoryRowProps) {
}; };
const startAutoScroll = (direction: 'left' | 'right') => { const startAutoScroll = (direction: 'left' | 'right') => {
// Just do single scroll on hover start // Clear any existing interval
scroll(direction); if (scrollIntervalRef.current) {
clearInterval(scrollIntervalRef.current);
}
// Start continuous scrolling
scrollIntervalRef.current = setInterval(() => {
scroll(direction);
}, 800); // Auto scroll every 800ms
}; };
// Initialize in middle section for true infinite scroll // Initialize in middle section for true infinite scroll
@ -203,9 +210,11 @@ function CategoryRow({ category, onVideoClick }: CategoryRowProps) {
}} }}
onMouseEnter={(e) => { onMouseEnter={(e) => {
e.stopPropagation(); e.stopPropagation();
startAutoScroll('left');
}} }}
onMouseLeave={(e) => { onMouseLeave={(e) => {
e.stopPropagation(); e.stopPropagation();
stopAutoScroll();
}} }}
className="flex absolute left-2 top-[45%] -translate-y-1/2 w-12 h-12 z-30 bg-black/80 hover:bg-black/95 rounded-full items-center justify-center transition-all duration-300 cursor-pointer border border-white/30 shadow-lg opacity-0 group-hover:opacity-100 hover:!opacity-100" className="flex absolute left-2 top-[45%] -translate-y-1/2 w-12 h-12 z-30 bg-black/80 hover:bg-black/95 rounded-full items-center justify-center transition-all duration-300 cursor-pointer border border-white/30 shadow-lg opacity-0 group-hover:opacity-100 hover:!opacity-100"
data-testid="button-scroll-left" data-testid="button-scroll-left"
@ -222,9 +231,11 @@ function CategoryRow({ category, onVideoClick }: CategoryRowProps) {
}} }}
onMouseEnter={(e) => { onMouseEnter={(e) => {
e.stopPropagation(); e.stopPropagation();
startAutoScroll('right');
}} }}
onMouseLeave={(e) => { onMouseLeave={(e) => {
e.stopPropagation(); e.stopPropagation();
stopAutoScroll();
}} }}
className="flex absolute right-2 top-[45%] -translate-y-1/2 w-12 h-12 z-30 bg-black/80 hover:bg-black/95 rounded-full items-center justify-center transition-all duration-300 cursor-pointer border border-white/30 shadow-lg opacity-0 group-hover:opacity-100 hover:!opacity-100" className="flex absolute right-2 top-[45%] -translate-y-1/2 w-12 h-12 z-30 bg-black/80 hover:bg-black/95 rounded-full items-center justify-center transition-all duration-300 cursor-pointer border border-white/30 shadow-lg opacity-0 group-hover:opacity-100 hover:!opacity-100"
data-testid="button-scroll-right" data-testid="button-scroll-right"