Improve video category scrolling by allowing speed adjustments

Refactors the category row scrolling logic in `netflix-grid.tsx` to allow toggling scroll speed when already scrolling and ensures auto-scroll starts/stops correctly on hover/leave events.

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
This commit is contained in:
sebastjanartic 2025-08-29 16:46:47 +00:00
parent 71ca86f99e
commit c996600e19

View File

@ -226,15 +226,20 @@ function CategoryRow({ category, onVideoClick }: CategoryRowProps) {
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
scroll('left');
// If already scrolling, toggle speed, otherwise start scrolling
if (isScrolling) {
toggleSpeed('left');
} else {
startAutoScroll('left');
}
}}
onMouseEnter={(e) => {
e.stopPropagation();
// startAutoScroll('left');
startAutoScroll('left');
}}
onMouseLeave={(e) => {
e.stopPropagation();
// stopAutoScroll();
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-80 hover:!opacity-100"
data-testid="button-scroll-left"
@ -247,15 +252,20 @@ function CategoryRow({ category, onVideoClick }: CategoryRowProps) {
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
scroll('right');
// If already scrolling, toggle speed, otherwise start scrolling
if (isScrolling) {
toggleSpeed('right');
} else {
startAutoScroll('right');
}
}}
onMouseEnter={(e) => {
e.stopPropagation();
// startAutoScroll('right');
startAutoScroll('right');
}}
onMouseLeave={(e) => {
e.stopPropagation();
// stopAutoScroll();
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-80 hover:!opacity-100"
data-testid="button-scroll-right"