update gradio

This commit is contained in:
Vladimir Mandic
2023-05-18 10:41:24 -04:00
parent df1fae7248
commit 8b682183e3
3 changed files with 25 additions and 13 deletions
+22 -11
View File
@@ -1,7 +1,27 @@
/* global gradioApp, onUiUpdate */
// attaches listeners to the txt2img and img2img galleries to update displayed generation param text when the image changes
let txt2img_gallery; let img2img_gallery; let
modal;
function attachGalleryListeners(tab_name) {
const gallery = gradioApp().querySelector(`#${tab_name}_gallery`);
gallery?.addEventListener('click', () => setTimeout(() => {
gradioApp()
.getElementById(`${tab_name}_generation_info_button`)
?.click();
}, 500));
gallery?.addEventListener('keydown', (e) => {
if (e.keyCode == 37 || e.keyCode == 39) { // left or right arrow
gradioApp()
.getElementById(`${tab_name}_generation_info_button`)
.click();
}
});
return gallery;
}
let txt2img_gallery;
let img2img_gallery;
let modal;
onUiUpdate(() => {
if (!txt2img_gallery) txt2img_gallery = attachGalleryListeners('txt2img');
if (!img2img_gallery) img2img_gallery = attachGalleryListeners('img2img');
@@ -19,12 +39,3 @@ let modalObserver = new MutationObserver((mutations) => {
});
});
function attachGalleryListeners(tab_name) {
gallery = gradioApp().querySelector(`#${tab_name}_gallery`);
gallery?.addEventListener('click', () => gradioApp().getElementById(`${tab_name}_generation_info_button`).click());
gallery?.addEventListener('keydown', (e) => {
if (e.keyCode == 37 || e.keyCode == 39) // left or right arrow
{ gradioApp().getElementById(`${tab_name}_generation_info_button`).click(); }
});
return gallery;
}