lightslider icon indicating copy to clipboard operation
lightslider copied to clipboard

refresh() doesn't work with autoWidth+loop

Open haferburg opened this issue 4 years ago • 0 comments

I'm adding and removing multiple images to the slider dynamically. I use {autoWidth: true, loop: true}, everything else is default. Here's a simple version.

https://jsfiddle.net/49fwb36s/

What I'm seeing in FF 75 is that after I add the items and call refresh(), sometimes all images disappear, and when I inspect the DOM I can see that the left and right clones are missing. Dragging sometimes makes the items reappear, but without the clones, dragging doesn't work properly.

I've also tried to add an on('load', ...) handler for each img, and then call refresh only after all images have been loaded. Still doesn't work.

Here's another version that uses imageLoaded to refresh after all images have been loaded. https://jsfiddle.net/4mabnqLs/

I'm wondering if this has anything to do with https://github.com/sachinchoolur/lightslider/issues/146#issuecomment-268467493.

The only workaround I've found is to call refresh() after 1200 ms.

haferburg avatar Apr 28 '20 20:04 haferburg