mirror of
https://github.com/vladmandic/automatic
synced 2026-09-02 11:00:46 +02:00
fix Image Viewer opening when used in multiple tabs
This commit is contained in:
@@ -123,12 +123,15 @@ function galleryClickEventHandler(event) {
|
||||
}
|
||||
|
||||
function initImageViewer() {
|
||||
const galleryPreview = gradioApp().querySelector('.gradio-gallery > div.preview');
|
||||
if (galleryPreview) {
|
||||
const fullImgPreview = galleryPreview.querySelectorAll('img');
|
||||
if (fullImgPreview.length > 0) {
|
||||
galleryPreview.addEventListener('click', galleryClickEventHandler, true);
|
||||
fullImgPreview.forEach(setupImageForLightbox);
|
||||
// Each tab has its own gradio-gallery
|
||||
const galleryPreviews = gradioApp().querySelectorAll('.gradio-gallery > div.preview');
|
||||
if (galleryPreviews.length > 0) {
|
||||
for (const galleryPreview of galleryPreviews) {
|
||||
const fullImgPreview = galleryPreview.querySelectorAll('img');
|
||||
if (fullImgPreview.length > 0) {
|
||||
galleryPreview.addEventListener('click', galleryClickEventHandler, true);
|
||||
fullImgPreview.forEach(setupImageForLightbox);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (imageViewerInitialized) return;
|
||||
|
||||
Reference in New Issue
Block a user