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:
parent
2661fbb169
commit
ed3142e721
@ -151,8 +151,15 @@ function CategoryRow({ category, onVideoClick }: CategoryRowProps) {
|
||||
};
|
||||
|
||||
const startAutoScroll = (direction: 'left' | 'right') => {
|
||||
// Just do single scroll on hover start
|
||||
scroll(direction);
|
||||
// Clear any existing interval
|
||||
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
|
||||
@ -203,9 +210,11 @@ function CategoryRow({ category, onVideoClick }: CategoryRowProps) {
|
||||
}}
|
||||
onMouseEnter={(e) => {
|
||||
e.stopPropagation();
|
||||
startAutoScroll('left');
|
||||
}}
|
||||
onMouseLeave={(e) => {
|
||||
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"
|
||||
data-testid="button-scroll-left"
|
||||
@ -222,9 +231,11 @@ function CategoryRow({ category, onVideoClick }: CategoryRowProps) {
|
||||
}}
|
||||
onMouseEnter={(e) => {
|
||||
e.stopPropagation();
|
||||
startAutoScroll('right');
|
||||
}}
|
||||
onMouseLeave={(e) => {
|
||||
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"
|
||||
data-testid="button-scroll-right"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user