mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2024-06-07 21:20:49 +00:00
chore: add ImageViewer Navigation Index label
This commit is contained in:
parent
ddb28b33a3
commit
5f2568320f
@ -23,6 +23,19 @@ function showModal(event) {
|
||||
gradioApp().getElementById("modal_save").style.display = "none";
|
||||
}
|
||||
event.stopPropagation();
|
||||
|
||||
setTimeout(() => {
|
||||
updateModalNavigationIndex(selected_gallery_index(), all_gallery_buttons().length);
|
||||
}, 10);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param idx {number}
|
||||
* @param length {number}
|
||||
*/
|
||||
function updateModalNavigationIndex(idx, length) {
|
||||
const modalTitle = gradioApp().getElementById("lightboxModal").querySelector('.modalTitle');
|
||||
modalTitle.textContent = `${idx + 1}/${length}`;
|
||||
}
|
||||
|
||||
function negmod(n, m) {
|
||||
@ -51,17 +64,11 @@ function modalImageSwitch(offset) {
|
||||
var galleryButtons = all_gallery_buttons();
|
||||
|
||||
if (galleryButtons.length > 1) {
|
||||
var currentButton = selected_gallery_button();
|
||||
|
||||
var result = -1;
|
||||
galleryButtons.forEach(function(v, i) {
|
||||
if (v == currentButton) {
|
||||
result = i;
|
||||
}
|
||||
});
|
||||
var result = selected_gallery_index();
|
||||
|
||||
if (result != -1) {
|
||||
var nextButton = galleryButtons[negmod((result + offset), galleryButtons.length)];
|
||||
let idx = negmod((result + offset), galleryButtons.length);
|
||||
var nextButton = galleryButtons[idx];
|
||||
nextButton.click();
|
||||
const modalImage = gradioApp().getElementById("modalImage");
|
||||
const modal = gradioApp().getElementById("lightboxModal");
|
||||
@ -69,6 +76,7 @@ function modalImageSwitch(offset) {
|
||||
if (modalImage.style.display === 'none') {
|
||||
modal.style.setProperty('background-image', `url(${modalImage.src})`);
|
||||
}
|
||||
updateModalNavigationIndex(idx, galleryButtons.length);
|
||||
setTimeout(function() {
|
||||
modal.focus();
|
||||
}, 10);
|
||||
@ -216,6 +224,10 @@ document.addEventListener("DOMContentLoaded", function() {
|
||||
modalSave.title = "Save Image(s)";
|
||||
modalControls.appendChild(modalSave);
|
||||
|
||||
const modalTitle = document.createElement("span");
|
||||
modalTitle.className = "modalTitle";
|
||||
modalControls.appendChild(modalTitle);
|
||||
|
||||
const modalClose = document.createElement('span');
|
||||
modalClose.className = 'modalClose cursor';
|
||||
modalClose.innerHTML = '×';
|
||||
|
13
style.css
13
style.css
@ -673,6 +673,7 @@ table.popup-table .link{
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
flex-direction: column;
|
||||
font-family: var(--font);
|
||||
}
|
||||
|
||||
.modalControls {
|
||||
@ -706,6 +707,18 @@ table.popup-table .link{
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.modalControls .modalTitle {
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
width: 100% !important;
|
||||
white-space: nowrap;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.modalControls .modalTitle:hover {
|
||||
color: white;
|
||||
}
|
||||
|
||||
#lightboxModal > img {
|
||||
display: block;
|
||||
margin: auto;
|
||||
|
Loading…
Reference in New Issue
Block a user