diff --git a/src/components/carousel/defaultProps.ts b/src/components/carousel/defaultProps.ts index a01b090..dc11e6b 100644 --- a/src/components/carousel/defaultProps.ts +++ b/src/components/carousel/defaultProps.ts @@ -22,5 +22,5 @@ export const defaultProps: Required = { triggerClickOn: Number.MIN_SAFE_INTEGER, hideArrows: false, onLeftArrowClick: () => null, - onRightArrowClick: () => null + onRightArrowClick: () => null, }; diff --git a/src/components/carousel/index.tsx b/src/components/carousel/index.tsx index 2243a7f..afa9655 100644 --- a/src/components/carousel/index.tsx +++ b/src/components/carousel/index.tsx @@ -55,7 +55,7 @@ export const Carousel: FunctionComponent = (userProps: CarouselPr const [page, setPage] = useState(0); const isPaginating = useRef(false); const slideButtonRef = useRef(null); - const autoSwipeTimer = useRef(); + const autoSwipeTimer = useRef(0); const isNavigation = typeof props.navigation === 'function'; if (props.dynamic) { @@ -93,10 +93,8 @@ export const Carousel: FunctionComponent = (userProps: CarouselPr typeof props.autoSwipe === 'number' && props.autoSwipe > props.transition ) { - autoSwipeTimer.current = setTimeout(() => { - if (slideButtonRef.current) { - slideButtonRef.current!.click(); - } + autoSwipeTimer.current = window.setTimeout(() => { + slide(SlideDirection.Right); }, props.autoSwipe); } }; @@ -254,18 +252,18 @@ export const Carousel: FunctionComponent = (userProps: CarouselPr }; const onLeftArrowClick = () => { - slide(SlideDirection.Left) + slide(SlideDirection.Left); if (props.onLeftArrowClick) { props.onLeftArrowClick(); } - } + }; const onRightArrowClick = () => { - slide(SlideDirection.Right) + slide(SlideDirection.Right); if (props.onRightArrowClick) { props.onRightArrowClick(); } - } + }; return (