@@ -55,7 +55,7 @@ export const Carousel: FunctionComponent<CarouselProps> = (userProps: CarouselPr
5555 const [ page , setPage ] = useState < number > ( 0 ) ;
5656 const isPaginating = useRef ( false ) ;
5757 const slideButtonRef = useRef < HTMLDivElement > ( null ) ;
58- const autoSwipeTimer = useRef < number > ( ) ;
58+ const autoSwipeTimer = useRef < number > ( 0 ) ;
5959 const isNavigation = typeof props . navigation === 'function' ;
6060
6161 if ( props . dynamic ) {
@@ -93,10 +93,13 @@ export const Carousel: FunctionComponent<CarouselProps> = (userProps: CarouselPr
9393 typeof props . autoSwipe === 'number' &&
9494 props . autoSwipe > props . transition
9595 ) {
96- autoSwipeTimer . current = setTimeout ( ( ) => {
97- if ( slideButtonRef . current ) {
98- slideButtonRef . current ! . click ( ) ;
96+ autoSwipeTimer . current = window . setTimeout ( ( ) => {
97+ if ( showArrow . right ) {
98+ slide ( SlideDirection . Right ) ;
99+ } else {
100+ slide ( SlideDirection . Left ) ;
99101 }
102+ autoSwipe ( ) ;
100103 } , props . autoSwipe ) ;
101104 }
102105 } ;
@@ -254,18 +257,18 @@ export const Carousel: FunctionComponent<CarouselProps> = (userProps: CarouselPr
254257 } ;
255258
256259 const onLeftArrowClick = ( ) => {
257- slide ( SlideDirection . Left )
260+ slide ( SlideDirection . Left ) ;
258261 if ( props . onLeftArrowClick ) {
259262 props . onLeftArrowClick ( ) ;
260263 }
261- }
264+ } ;
262265
263266 const onRightArrowClick = ( ) => {
264- slide ( SlideDirection . Right )
267+ slide ( SlideDirection . Right ) ;
265268 if ( props . onRightArrowClick ) {
266269 props . onRightArrowClick ( ) ;
267270 }
268- }
271+ } ;
269272
270273 return (
271274 < div
0 commit comments