Fix carousel not scrolling

This commit is contained in:
Lim Chee Aun 2024-08-18 10:41:49 +08:00
parent 5e2d084854
commit 15e4012dd2

View file

@ -55,11 +55,11 @@ function MediaModal({
const scrollLeft = index * carouselRef.current.clientWidth; const scrollLeft = index * carouselRef.current.clientWidth;
const differentStatusID = prevStatusID.current !== statusID; const differentStatusID = prevStatusID.current !== statusID;
if (differentStatusID) prevStatusID.current = statusID; if (differentStatusID) prevStatusID.current = statusID;
carouselRef.current.focus();
carouselRef.current.scrollTo({ carouselRef.current.scrollTo({
left: scrollLeft * (isRTL() ? -1 : 1), left: scrollLeft * (isRTL() ? -1 : 1),
behavior: differentStatusID ? 'auto' : 'smooth', behavior: differentStatusID ? 'auto' : 'smooth',
}); });
carouselRef.current.focus();
}, [index, statusID]); }, [index, statusID]);
const [showControls, setShowControls] = useState(true); const [showControls, setShowControls] = useState(true);