Open mwegithub opened 2 years ago
I don't think you need data-nanogallery2-lightbox attribute in the containing div of these images.
Galleries are grouped within a div that has the data-nanogallery2 attribute, but standalone images each take their own lightbox definition (as you have for them).
Maybe removing that attribute from the DIV will help?
Standalone Viewer does not open the clicked image, but the first.
I'm using the latest 3.0.5 release. I have created a basic HTML file with 3 images to try out the standalone feature of nanogallery2. I already know that the regular use of it works very nicely.
The problem is that, independent on which image I click, the standalone Viewer first opens that image, but then switches to the first image. You can only see this while stepping the debugger, because it is so fast. I tested this in FF and Chrome/Edge on Windows 11.
I have tracked down the problem to the click handler (line 1621) always being called twice, but the second time within the context of the outer gallery div instead of the clicked img. In the first call, the
LightboxStandaloneDisplay()
function correctly identifies the clicked thumbnail and calls LightboxOpen( displayIdx ) with a valid displayIdx (line 3105). The second time,displayIdx
remains undefined and the call toLightboxOpen
falls back to opening the first image.I have no idea why the click event handler is called twice. But by adding
at the start of
LightboxOpen(idx)
and changing the other call toLightboxOpen(0);
in line 8437, the problem is fixed. Clicking a thumbnail now opens the correct image, despite the click handler being called twice.I don't know if this is something I did wrong in my HTML (see above) because I'm new to nanogallery2. But maybe this is indeed a bug of sorts. Since I'm new to this library, I did not want to open a pull request, because I think it's likely that I did something stupid in my HTML.