From 9fc075e6075a19946c9d47dfca62d62d1cdbecee Mon Sep 17 00:00:00 2001 From: anapnoe <124302297+anapnoe@users.noreply.github.com> Date: Mon, 1 May 2023 16:57:45 +0300 Subject: [PATCH] fix Batches have memory of last position #98 --- javascript/imageviewer.js | 14 +++++++++----- javascript/ui.js | 10 +++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/javascript/imageviewer.js b/javascript/imageviewer.js index 655eae71..5ba0d275 100644 --- a/javascript/imageviewer.js +++ b/javascript/imageviewer.js @@ -362,10 +362,13 @@ function createGallerySpotlight() { //console.log("clicked"); slide = 0; gallery = []; - - gradioApp().querySelectorAll("#"+selectedTabItemId+' .grid-wrap img').forEach(function (elem, i){ + + + gradioApp().querySelectorAll("#"+selectedTabItemId+' .thumbnails img').forEach(function (elem, i){ elem.setAttribute("gal-id", i); - if(fullImg_src == elem.src) slide = (i+1); + //if(fullImg_src == elem.src) slide = parseInt(i+1); + if(elem.parentElement.className.indexOf("selected") != -1) slide = parseInt(i+1); + //console.log(slide); gallery[i] = { src: elem.src, title: "Seed:" + elem.src, @@ -407,7 +410,7 @@ function createGallerySpotlight() { }, onclose: function(index){ - gradioApp().querySelector("#"+selectedTabItemId+' .thumbnail-item:nth-child('+(slide+1)+')').click(); + gradioApp().querySelector("#"+selectedTabItemId+' .thumbnails .thumbnail-item:nth-child('+(slide+1)+')').click(); } }; @@ -432,13 +435,14 @@ function onUiHeaderTabUpdate(){ intervalUiUpdateIViewer = setInterval(onUiUpdateIViewer, 500); } + let fullImg_preview; function onUiUpdateIViewer(){ clearInterval(intervalUiUpdateIViewer); //update_performant_inputs(selectedTabItemId); //fullImg_preview = gradioApp().querySelector('#'+selectedTabItemId+' [id$="2img_results"] .modify-upload + img.w-full.object-contain'); - fullImg_preview = gradioApp().querySelector('#'+selectedTabItemId+' .preview img'); + fullImg_preview = gradioApp().querySelector('#'+selectedTabItemId+' .preview > img'); if(opts.js_modal_lightbox && fullImg_preview ) { fullImg_src = fullImg_preview.src; diff --git a/javascript/ui.js b/javascript/ui.js index 7efca55e..81580189 100644 --- a/javascript/ui.js +++ b/javascript/ui.js @@ -1,10 +1,11 @@ // various functions for interaction with ui.py not large enough to warrant putting them in separate files - function set_theme(theme){ - gradioURL = window.location.href + /* + gradioURL = window.location.href if (!gradioURL.includes('?__theme=')) { window.location.replace(gradioURL + '?__theme=' + theme); - } + } + */ } function all_gallery_buttons() { @@ -200,7 +201,6 @@ function modelmerger(){ return res } - function ask_for_style_name(_, prompt_text, negative_prompt_text) { name_ = prompt('Style name:') return [name_, prompt_text, negative_prompt_text] @@ -242,7 +242,7 @@ function recalculate_prompts_inpaint(){ return args_to_array(arguments); } -let selectedTabItemId = "tab_txt2img"; +let selectedTabItemId = "tab_txt2img"; opts = {} onUiUpdate(function(){ if(Object.keys(opts).length != 0) return;