image viewer refocus on close

Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
Vladimir Mandic
2025-10-06 17:59:38 -04:00
parent 18f6ebb3f1
commit d012ad5556
3 changed files with 11 additions and 1 deletions
+9
View File
@@ -15,11 +15,20 @@ function cycleImageFit() {
log('cycleImageFit', current, next);
}
function isInViewport(element) {
const rect = element.getBoundingClientRect();
return rect.top >= 0 && rect.left >= 0 && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && rect.right <= (window.innerWidth || document.documentElement.clientWidth);
}
function closeModal(evt, force = false) {
if (force) gradioApp().getElementById('lightboxModal').style.display = 'none';
if (previewDrag) return;
if (evt?.button !== 0) return;
gradioApp().getElementById('lightboxModal').style.display = 'none';
let thumbnails = Array.from(gradioApp().querySelectorAll('.thumbnails .thumbnail-item'));
thumbnails = thumbnails.filter((el) => el.checkVisibility());
if (thumbnails.length === 0) return;
thumbnails[0].focus();
}
function modalImageSwitch(offset) {