Fix issue with modal image viewer with low live_preview_refresh_period (#16981)

This commit is contained in:
w-e-w 2025-05-03 03:09:38 +08:00 committed by GitHub
parent ebbc56b4ec
commit 82bf9a3730
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 5 additions and 1 deletions

View File

@ -88,6 +88,7 @@ module.exports = {
// imageviewer.js // imageviewer.js
modalPrevImage: "readonly", modalPrevImage: "readonly",
modalNextImage: "readonly", modalNextImage: "readonly",
updateModalImageIfVisible: "readonly",
// localStorage.js // localStorage.js
localSet: "readonly", localSet: "readonly",
localGet: "readonly", localGet: "readonly",

View File

@ -54,6 +54,7 @@ function updateOnBackgroundChange() {
updateModalImage(); updateModalImage();
} }
} }
const updateModalImageIfVisible = updateOnBackgroundChange;
function modalImageSwitch(offset) { function modalImageSwitch(offset) {
var galleryButtons = all_gallery_buttons(); var galleryButtons = all_gallery_buttons();
@ -164,6 +165,7 @@ function modalLivePreviewToggle(event) {
const modalToggleLivePreview = gradioApp().getElementById("modal_toggle_live_preview"); const modalToggleLivePreview = gradioApp().getElementById("modal_toggle_live_preview");
opts.js_live_preview_in_modal_lightbox = !opts.js_live_preview_in_modal_lightbox; opts.js_live_preview_in_modal_lightbox = !opts.js_live_preview_in_modal_lightbox;
modalToggleLivePreview.innerHTML = opts.js_live_preview_in_modal_lightbox ? "🗇" : "🗆"; modalToggleLivePreview.innerHTML = opts.js_live_preview_in_modal_lightbox ? "🗇" : "🗆";
updateModalImageIfVisible();
event.stopPropagation(); event.stopPropagation();
} }

View File

@ -190,7 +190,7 @@ function requestProgress(id_task, progressbarContainer, gallery, atEnd, onProgre
livePreview.className = 'livePreview'; livePreview.className = 'livePreview';
gallery.insertBefore(livePreview, gallery.firstElementChild); gallery.insertBefore(livePreview, gallery.firstElementChild);
} }
updateModalImageIfVisible();
livePreview.appendChild(img); livePreview.appendChild(img);
if (livePreview.childElementCount > 2) { if (livePreview.childElementCount > 2) {
livePreview.removeChild(livePreview.firstElementChild); livePreview.removeChild(livePreview.firstElementChild);

View File

@ -602,6 +602,7 @@ table.popup-table .link{
background: var(--background-fill-primary); background: var(--background-fill-primary);
width: 100%; width: 100%;
height: 100%; height: 100%;
pointer-events: none;
} }
.livePreview img{ .livePreview img{