sachinchoolur / lightslider

JQuery lightSlider is a lightweight responsive Content slider with carousel thumbnails navigation
http://sachinchoolur.github.io/lightslider/
MIT License
2.04k stars 1.53k forks source link

refresh() doesn't work with autoWidth+loop #454

Open haferburg opened 4 years ago

haferburg commented 4 years ago

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.