mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2025-08-08 23:44:39 +02:00
Add back/forward buttons to switch between images in tasks
This commit is contained in:
@ -398,7 +398,30 @@ function showImages(reqBody, res, outputContainer, livePreview) {
|
||||
if ('seed' in result && !imageElem.hasAttribute('data-seed')) {
|
||||
const imageExpandBtn = imageItemElem.querySelector('.imgExpandBtn')
|
||||
imageExpandBtn.addEventListener('click', function() {
|
||||
imageModal(imageElem.src)
|
||||
function previousImage(img) {
|
||||
const allImages = Array.from(outputContainer.parentNode.querySelectorAll('.imgItem img'))
|
||||
const index = allImages.indexOf(img)
|
||||
return allImages.slice(0, index).reverse()[0]
|
||||
}
|
||||
|
||||
function nextImage(img) {
|
||||
const allImages = Array.from(outputContainer.parentNode.querySelectorAll('.imgItem img'))
|
||||
const index = allImages.indexOf(img)
|
||||
return allImages.slice(index + 1)[0]
|
||||
}
|
||||
|
||||
function imageModalParameter(img) {
|
||||
const previousImg = previousImage(img)
|
||||
const nextImg = nextImage(img)
|
||||
|
||||
return {
|
||||
src: img.src,
|
||||
previous: previousImg ? () => imageModalParameter(previousImg) : undefined,
|
||||
next: nextImg ? () => imageModalParameter(nextImg) : undefined,
|
||||
}
|
||||
}
|
||||
|
||||
imageModal(imageModalParameter(imageElem))
|
||||
})
|
||||
|
||||
const req = Object.assign({}, reqBody, {
|
||||
|
Reference in New Issue
Block a user