diff --git a/packages/nuka/src/Carousel/Carousel.tsx b/packages/nuka/src/Carousel/Carousel.tsx index 18ab637b..0fb78989 100644 --- a/packages/nuka/src/Carousel/Carousel.tsx +++ b/packages/nuka/src/Carousel/Carousel.tsx @@ -82,12 +82,18 @@ export const Carousel = forwardRef( const handleScrollAction = useCallback( (slideDirection: SlideDirection) => { + const proposedSlideIndex = + currentSlideIndex + + (slideDirection === SlideDirection.Forward ? 1 : -1); + const totalSlides = pageStartIndices.length - 1; setCurrentScrollIndex( pageStartIndices[ - currentSlideIndex + - (slideDirection === SlideDirection.Forward ? 1 : -1) + proposedSlideIndex < 0 + ? totalSlides + proposedSlideIndex + : proposedSlideIndex % totalSlides ] ); + setCurrentSlideIndex(proposedSlideIndex); }, [pageStartIndices, currentSlideIndex] ); diff --git a/tsconfig.json b/tsconfig.json index f4a5d279..d2c79d9d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,7 @@ "DOM", "ES2023" ], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ - "jsx": "react", /* Specify what JSX code is generated. */ + "jsx": "react-jsx", /* Specify what JSX code is generated. */ /* Modules */ "module": "commonjs", /* Specify what module code is generated. */