We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent bea008d commit 9287b96Copy full SHA for 9287b96
dotcom-rendering/src/components/ScrollableCarousel.tsx
@@ -362,9 +362,12 @@ export const ScrollableCarousel = ({
362
const carouselElement = carouselRef.current;
363
if (!carouselElement) return;
364
const cardWidth = carouselElement.querySelector('li')?.offsetWidth ?? 0;
365
- setCardCount(
366
- Math.ceil((carouselElement.scrollLeft + cardWidth / 2) / cardWidth),
+ const count = Math.ceil(
+ (carouselElement.scrollLeft + cardWidth / 2) / cardWidth,
367
);
368
+ if (count !== cardCount) {
369
+ setCardCount(count);
370
+ }
371
};
372
373
/**
0 commit comments