brainhubeu / react-carousel

A pure extendable React carousel, powered by Brainhub (craftsmen who ❤️ JS)
https://brainhub.eu/
MIT License
1.07k stars 164 forks source link

onChange not called by autoplay plugin #690

Closed rugheid closed 3 years ago

rugheid commented 3 years ago

Describe the bug When the slide changes because of autoplay, the onChange handler is not called. This way you can't correctly control the component while using autoplay.

To Reproduce Steps to reproduce the behavior:

  1. Use controlled carousel with autoplay plugin enabled.
  2. Put a console.log statement in the onChange handler.
  3. Notice that it doesn't fire when autoplay advances.

Expected behavior I would expect the onChange handler to be called when the carousel changes slide because of autoplay.

Screenshots /

Environment

System: OS: macOS 11.1 CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz Memory: 4.50 GB / 32.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 14.15.1 - ~/.nvm/versions/node/v14.15.1/bin/node Yarn: 1.22.10 - ~/.nvm/versions/node/v14.15.1/bin/yarn npm: 7.5.5 - ~/.nvm/versions/node/v14.15.1/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Browsers: Brave Browser: 88.1.19.86 Chrome: 90.0.4430.72 Firefox: 70.0.1 Safari: 14.0.2 npmPackages: @brainhubeu/react-carousel: ^2.0.3 => 2.0.3

I used Brave on my laptop.

Additional context /

RobertHebel commented 3 years ago

Thanks for your contribution 💪 . After merging it onChange is called by the autoplay plugin as well