sachinchoolur / lightGallery

A customizable, modular, responsive, lightbox gallery plugin.
https://www.lightgalleryjs.com/
Other
6.55k stars 1.29k forks source link

Preload doesn't work if the gallery was initialized with not enough images #1670

Open pweerd opened 1 week ago

pweerd commented 1 week ago

Description

In the situation that you initialize the gallery without images and doing a refresh() afterwards, the preload functionality is not working. This is caused by a bug in the function normalizeSettings(). This function sets the preload setting to 0 if there were no images.

Of course a reset() afterwards doesn't help, because the setting is already overwritten.

It seems better to do the Math.min check during the preload itself.

Steps to reproduce

1) Initialize the gallery with a nonzero preload, but no images. 2) Refresh the gallery with some images. Now the preload doesn't work.

Sample HTML markup

Environment

Additional context