Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timer does not reset when the carousel image is changed through indicators #525

Closed
roboGOD opened this issue Nov 16, 2020 · 3 comments · Fixed by #561
Closed

Timer does not reset when the carousel image is changed through indicators #525

roboGOD opened this issue Nov 16, 2020 · 3 comments · Fixed by #561

Comments

@roboGOD
Copy link

roboGOD commented Nov 16, 2020

Issue

Timer does not reset when the carousel image is changed through indicators in case stopOnHover is false.

Steps to reproduce

  1. Create a basic carousel with autoPlay as true and stopOnHover as false.
  2. Change the image through the indicators.

Actual: If the image is about to change with autoPlay and we change the image through the indicators, the timer does not reset and sometimes the image automatically changes immediately after it is changed through the indicators. So, the user is not able to see the image and has to change again.

Expected: The timer should reset when the image is changed through the indicators.

Screengrab

carousel_issue_1

Links

Code Sandbox

@Vitali883
Copy link

Same issue. Fixed?

@roboGOD
Copy link
Author

roboGOD commented Jan 24, 2021

Same issue. Fixed?

I fixed it by manually calling the resetAutoPlay function in onChange callback using the ref of the Carousel. Sample code below.

  1. Create a ref:

const carouselRef = React.useRef(null);

  1. Pass the ref in the Carousel and call the resetAutoPlay function in onChange:
    <Carousel
      ref={carouselRef}
      stopOnHover={false}
      autoPlay
      onChange={() => {
        if (carouselRef.current) {
          carouselRef.current.resetAutoPlay();
        }
      }}
    >
       ...
    </Carousel>

@Vitali883
Copy link

Thank you! Works for me!

renancleyson-dev added a commit to renancleyson-dev/react-responsive-carousel that referenced this issue Feb 15, 2021
renancleyson-dev added a commit to renancleyson-dev/react-responsive-carousel that referenced this issue Feb 16, 2021
renancleyson-dev added a commit to renancleyson-dev/react-responsive-carousel that referenced this issue Feb 16, 2021
leandrowd added a commit that referenced this issue Mar 18, 2021
…set-auto-play

#525: Fix indicator click not resetting autoplay
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants