Enable automatic scrolling of video rows on hover
Implement automatic left and right scrolling for video rows when the mouse hovers over designated areas, replacing the previous click-based navigation buttons with a more intuitive hover-activated system. 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/P3O2FU7
This commit is contained in:
parent
645ac19776
commit
8fea0f2c76
@ -133,6 +133,7 @@ interface CategoryRowProps {
|
|||||||
|
|
||||||
function CategoryRow({ category, onVideoClick }: CategoryRowProps) {
|
function CategoryRow({ category, onVideoClick }: CategoryRowProps) {
|
||||||
const scrollRef = useRef<HTMLDivElement>(null);
|
const scrollRef = useRef<HTMLDivElement>(null);
|
||||||
|
const scrollIntervalRef = useRef<NodeJS.Timeout | null>(null);
|
||||||
|
|
||||||
const scroll = (direction: 'left' | 'right') => {
|
const scroll = (direction: 'left' | 'right') => {
|
||||||
if (scrollRef.current) {
|
if (scrollRef.current) {
|
||||||
@ -153,39 +154,62 @@ function CategoryRow({ category, onVideoClick }: CategoryRowProps) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const startAutoScroll = (direction: 'left' | 'right') => {
|
||||||
|
if (scrollIntervalRef.current) {
|
||||||
|
clearInterval(scrollIntervalRef.current);
|
||||||
|
}
|
||||||
|
scrollIntervalRef.current = setInterval(() => {
|
||||||
|
if (scrollRef.current) {
|
||||||
|
const scrollAmount = direction === 'left' ? -3 : 3;
|
||||||
|
scrollRef.current.scrollLeft += scrollAmount;
|
||||||
|
}
|
||||||
|
}, 16); // ~60fps
|
||||||
|
};
|
||||||
|
|
||||||
|
const stopAutoScroll = () => {
|
||||||
|
if (scrollIntervalRef.current) {
|
||||||
|
clearInterval(scrollIntervalRef.current);
|
||||||
|
scrollIntervalRef.current = null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="relative group mb-8">
|
<div className="relative group mb-8">
|
||||||
<h2 className="text-2xl font-bold text-bunny-light mb-6 px-4">
|
<h2 className="text-2xl font-bold text-bunny-light mb-6 px-4">
|
||||||
{category.title}
|
{category.title}
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
<div className="relative px-0 md:px-16">
|
<div className="relative">
|
||||||
{/* Left scroll button - only on desktop */}
|
{/* Left scroll area with transparent background - only on desktop */}
|
||||||
<Button
|
<div
|
||||||
onClick={() => scroll('left')}
|
onMouseEnter={() => startAutoScroll('left')}
|
||||||
className="hidden md:flex absolute -left-2 top-1/2 -translate-y-1/2 z-30 bg-black/80 hover:bg-black/95 text-white border-none w-12 h-12 rounded-full opacity-0 group-hover:opacity-100 transition-all duration-300 items-center justify-center shadow-xl"
|
onMouseLeave={stopAutoScroll}
|
||||||
size="sm"
|
className="hidden md:block absolute left-0 top-0 w-16 h-full z-30 bg-black/20 opacity-0 group-hover:opacity-100 transition-all duration-300 cursor-pointer"
|
||||||
>
|
>
|
||||||
<ChevronLeft className="w-5 h-5" />
|
<div className="flex items-center justify-center h-full">
|
||||||
</Button>
|
<ChevronLeft className="w-8 h-8 text-white drop-shadow-lg" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{/* Right scroll button - only on desktop */}
|
{/* Right scroll area with transparent background - only on desktop */}
|
||||||
<Button
|
<div
|
||||||
onClick={() => scroll('right')}
|
onMouseEnter={() => startAutoScroll('right')}
|
||||||
className="hidden md:flex absolute -right-2 top-1/2 -translate-y-1/2 z-30 bg-black/80 hover:bg-black/95 text-white border-none w-12 h-12 rounded-full opacity-0 group-hover:opacity-100 transition-all duration-300 items-center justify-center shadow-xl"
|
onMouseLeave={stopAutoScroll}
|
||||||
size="sm"
|
className="hidden md:block absolute right-0 top-0 w-16 h-full z-30 bg-black/20 opacity-0 group-hover:opacity-100 transition-all duration-300 cursor-pointer"
|
||||||
>
|
>
|
||||||
<ChevronRight className="w-5 h-5" />
|
<div className="flex items-center justify-center h-full">
|
||||||
</Button>
|
<ChevronRight className="w-8 h-8 text-white drop-shadow-lg" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{/* Mobile touch areas for left/right navigation */}
|
{/* Mobile touch areas for left/right navigation */}
|
||||||
<div className="md:hidden absolute left-0 top-0 w-1/3 h-full z-20" onClick={() => scroll('left')} />
|
<div className="md:hidden absolute left-0 top-0 w-1/3 h-full z-20" onClick={() => scroll('left')} />
|
||||||
<div className="md:hidden absolute right-0 top-0 w-1/3 h-full z-20" onClick={() => scroll('right')} />
|
<div className="md:hidden absolute right-0 top-0 w-1/3 h-full z-20" onClick={() => scroll('right')} />
|
||||||
|
|
||||||
{/* Scrollable video row */}
|
{/* Scrollable video row - edge to edge */}
|
||||||
<div
|
<div
|
||||||
ref={scrollRef}
|
ref={scrollRef}
|
||||||
className="flex space-x-2 md:space-x-3 overflow-x-auto scrollbar-hide pb-4 scroll-smooth"
|
className="flex space-x-2 md:space-x-3 overflow-x-auto scrollbar-hide pb-4 scroll-smooth px-4 md:px-0"
|
||||||
style={{
|
style={{
|
||||||
scrollbarWidth: 'none',
|
scrollbarWidth: 'none',
|
||||||
msOverflowStyle: 'none',
|
msOverflowStyle: 'none',
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user