From 9810ae826da4410372be26661fc08f47a1a8e6ab Mon Sep 17 00:00:00 2001 From: Sam Grund Date: Wed, 27 Nov 2024 15:02:05 -0500 Subject: [PATCH] chore: comment for magic numbers --- src/components/Carousel/CarouselDots.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/Carousel/CarouselDots.tsx b/src/components/Carousel/CarouselDots.tsx index ef8d5683..1fe5f8c1 100644 --- a/src/components/Carousel/CarouselDots.tsx +++ b/src/components/Carousel/CarouselDots.tsx @@ -44,7 +44,8 @@ const CarouselDots = forwardRef( const scrollToDot = useCallback((index: number) => { if (scrollableContainerRef.current) { - scrollableContainerRef.current.scrollTo({ + scrollableContainerRef.current.scrollTo?.({ + // 8 + 12 = width of dot plus gap left: index * (8 + 12) - scrollableContainerRef.current.offsetWidth / 2 + 10, // Center dot in container behavior: 'smooth', });