Improve scrolling responsiveness and smoothness in video grid
Update the CategoryRow component in netflix-grid.tsx to calculate scroll amount based on container width and apply smooth scrolling behavior for a better user experience. 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
c5cc537586
commit
94b1392a0f
@ -138,10 +138,12 @@ function CategoryRow({ category, onVideoClick }: CategoryRowProps) {
|
||||
if (scrollRef.current) {
|
||||
// Responsive scroll amount - extra small cards for Netflix style
|
||||
const isMobile = window.innerWidth < 768;
|
||||
const scrollAmount = isMobile ? 150 : 220; // Mobile: 144px + gap, Desktop: 208px + gap
|
||||
const containerWidth = scrollRef.current.clientWidth;
|
||||
// Scroll by container width for smoother experience
|
||||
const scrollAmount = isMobile ? containerWidth * 0.8 : containerWidth * 0.75;
|
||||
const currentScroll = scrollRef.current.scrollLeft;
|
||||
const targetScroll = direction === 'left'
|
||||
? currentScroll - scrollAmount
|
||||
? Math.max(0, currentScroll - scrollAmount)
|
||||
: currentScroll + scrollAmount;
|
||||
|
||||
scrollRef.current.scrollTo({
|
||||
@ -183,8 +185,13 @@ function CategoryRow({ category, onVideoClick }: CategoryRowProps) {
|
||||
{/* Scrollable video row */}
|
||||
<div
|
||||
ref={scrollRef}
|
||||
className="flex space-x-2 md:space-x-3 overflow-x-auto scrollbar-hide pb-4"
|
||||
style={{ scrollbarWidth: 'none', msOverflowStyle: 'none' }}
|
||||
className="flex space-x-2 md:space-x-3 overflow-x-auto scrollbar-hide pb-4 scroll-smooth"
|
||||
style={{
|
||||
scrollbarWidth: 'none',
|
||||
msOverflowStyle: 'none',
|
||||
scrollBehavior: 'smooth',
|
||||
WebkitOverflowScrolling: 'touch'
|
||||
}}
|
||||
>
|
||||
{category.videos.map((video, index) => (
|
||||
<div key={video.id} className="flex-shrink-0 w-36 md:w-52 relative group">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user