akiran / react-slick

React carousel component
http://react-slick.neostack.com/
MIT License
11.77k stars 2.1k forks source link

afterChange doesn't fire with lazyLoading: 'ondemand' #1645

Open theexplay opened 5 years ago

theexplay commented 5 years ago

CodeSandBox: https://codesandbox.io/s/react-typescript-sq6ih

When i'm using lazyLoading option with 'ondemand' value, afterChange function doesn't fire. It's easy to reproduce by fast clicking on the "next arrow". But if all images already loaded bug will not reproduce (for example if u will press prev arrow).

Steps to reproduce:

  1. After render page, just press on next arrow fast
  2. You will see, that beforeChange fires every time, but afterChange sometimes doesn't fire
  3. Watch on the console

Even if u already scrolled to last slide, afterChange could still doesn't fire, looks like a bug..

ezgif-1-0509b3f58284

p.s. sry for my eng.

theexplay commented 4 years ago

any news?

AndreyYurashevich commented 4 years ago

Same issue for me.

Seems like it's caused by the "load" event handlers for lazy-loaded images set in checkImagesLoad. The handlers call onWindowResized which in turn clears timeout handle this.animationEndCallback which is responsible for triggering afterChange.

GuyPaddock commented 3 years ago

Also see https://github.com/akiran/react-slick/issues/1262 and its associated PR.