mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 01:04:32 +02:00
gallery bypass thumb cache and safer delete ops
Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
+8
-1
@@ -32,6 +32,12 @@ function clip_gallery_urls(gallery) {
|
||||
);
|
||||
}
|
||||
|
||||
function isVisible(el) {
|
||||
const rect = el.getBoundingClientRect();
|
||||
if (rect.width === 0 && rect.height === 0) return false;
|
||||
return rect.top >= 0 && rect.left >= 0 && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && rect.right <= (window.innerWidth || document.documentElement.clientWidth);
|
||||
}
|
||||
|
||||
function all_gallery_buttons() {
|
||||
let allGalleryButtons = gradioApp().querySelectorAll('[style="display: block;"].tabitem div[id$=_gallery].gradio-gallery .thumbnails > .thumbnail-item.thumbnail-small');
|
||||
if (allGalleryButtons.length === 0) allGalleryButtons = gradioApp().querySelectorAll('.gradio-gallery .thumbnails > .thumbnail-item.thumbnail-small');
|
||||
@@ -66,6 +72,7 @@ function selected_gallery_files() {
|
||||
let allCurrentButtons = gradioApp().querySelectorAll('[style="display: block;"].tabitem div[id$=_gallery].gradio-gallery .thumbnail-item.thumbnail-small');
|
||||
if (allCurrentButtons.length === 0) allCurrentButtons = gradioApp().querySelectorAll('.gradio-gallery .thumbnails > .thumbnail-item.thumbnail-small');
|
||||
allImages = Array.from(allCurrentButtons).map((v) => v.querySelector('img')?.src);
|
||||
allImages = allImages.filter((el) => isVisible(el));
|
||||
} catch { /**/ }
|
||||
const selectedIndex = selected_gallery_index();
|
||||
return [allImages, selectedIndex];
|
||||
@@ -178,7 +185,7 @@ function switch_to_caption(...args) {
|
||||
|
||||
function get_tab_index(tabId) {
|
||||
let res = 0;
|
||||
gradioApp().getElementById(tabId).querySelector('div').querySelectorAll('button')
|
||||
gradioApp().getElementById(tabId)?.querySelector('div').querySelectorAll('button')
|
||||
.forEach((button, i) => {
|
||||
if (button.className.indexOf('selected') !== -1) res = i;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user