fix modalImageViewer preview/result flicker (#16426)

This commit is contained in:
w-e-w 2024-10-20 09:51:59 +09:00 committed by GitHub
parent d0b27dc906
commit c2bc187ce7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -13,6 +13,7 @@ function showModal(event) {
if (modalImage.style.display === 'none') { if (modalImage.style.display === 'none') {
lb.style.setProperty('background-image', 'url(' + source.src + ')'); lb.style.setProperty('background-image', 'url(' + source.src + ')');
} }
updateModalImage();
lb.style.display = "flex"; lb.style.display = "flex";
lb.focus(); lb.focus();
@ -31,9 +32,8 @@ function negmod(n, m) {
return ((n % m) + m) % m; return ((n % m) + m) % m;
} }
function updateOnBackgroundChange() { function updateModalImage() {
const modalImage = gradioApp().getElementById("modalImage"); const modalImage = gradioApp().getElementById("modalImage");
if (modalImage && modalImage.offsetParent) {
let currentButton = selected_gallery_button(); let currentButton = selected_gallery_button();
let preview = gradioApp().querySelectorAll('.livePreview > img'); let preview = gradioApp().querySelectorAll('.livePreview > img');
if (opts.js_live_preview_in_modal_lightbox && preview.length > 0) { if (opts.js_live_preview_in_modal_lightbox && preview.length > 0) {
@ -47,6 +47,12 @@ function updateOnBackgroundChange() {
} }
} }
} }
function updateOnBackgroundChange() {
const modalImage = gradioApp().getElementById("modalImage");
if (modalImage && modalImage.offsetParent) {
updateModalImage();
}
} }
function modalImageSwitch(offset) { function modalImageSwitch(offset) {