mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2024-12-21 07:30:02 +08:00
allow re-open for multiple images gallery
This commit is contained in:
parent
c84eef8195
commit
b26efff8c4
@ -67,12 +67,13 @@ function check_gallery(id_gallery){
|
||||
if(galleryObservers[id_gallery]){
|
||||
galleryObservers[id_gallery].disconnect();
|
||||
}
|
||||
let prevSelectedIndex = selected_gallery_index();
|
||||
galleryObservers[id_gallery] = new MutationObserver(function (){
|
||||
let galleryButtons = gradioApp().querySelectorAll('#'+id_gallery+' .gallery-item')
|
||||
let galleryBtnSelected = gradioApp().querySelector('#'+id_gallery+' .gallery-item.\\!ring-2')
|
||||
if (galleryButtons.length === 1 && !galleryBtnSelected) {
|
||||
//automatically open when there is only 1 gallery btn, and was previously selected
|
||||
galleryButtons[0].click();
|
||||
if (prevSelectedIndex !== -1 && galleryButtons.length>prevSelectedIndex && !galleryBtnSelected) {
|
||||
//automatically re-open previously selected index (if exists)
|
||||
galleryButtons[prevSelectedIndex].click();
|
||||
}
|
||||
})
|
||||
galleryObservers[id_gallery].observe( gallery, { childList:true, subtree:false })
|
||||
|
Loading…
Reference in New Issue
Block a user