mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-01-28 07:10:15 +08:00
Update imageFeed.js
Fix: Add allImages variable to allow for next/previous navigation in image popup
This commit is contained in:
parent
53c444eb6b
commit
2eb7d06759
@ -66,12 +66,14 @@ app.registerExtension({
|
|||||||
const newHeight = startHeight + startY - event.clientY;
|
const newHeight = startHeight + startY - event.clientY;
|
||||||
imageList.style.height = newHeight + "px";
|
imageList.style.height = newHeight + "px";
|
||||||
}
|
}
|
||||||
|
var allImages = []
|
||||||
|
|
||||||
function loadImages(detail) {
|
function loadImages(detail) {
|
||||||
const allImages = detail.output.images.filter(
|
const images = detail.output.images.filter(
|
||||||
(img) => img.type === "output" && img.filename !== "_output_images_will_be_put_here"
|
(img) => img.type === "output" && img.filename !== "_output_images_will_be_put_here"
|
||||||
);
|
);
|
||||||
for (const src of allImages) {
|
allImages.push(...images);
|
||||||
|
for (const src of images) {
|
||||||
const imgContainer = document.createElement("div");
|
const imgContainer = document.createElement("div");
|
||||||
imgContainer.style.cssText = "height: 120px; width: 120px; position: relative;";
|
imgContainer.style.cssText = "height: 120px; width: 120px; position: relative;";
|
||||||
|
|
||||||
@ -84,11 +86,14 @@ app.registerExtension({
|
|||||||
const confirmDelete = confirm("Are you sure you want to delete this image?");
|
const confirmDelete = confirm("Are you sure you want to delete this image?");
|
||||||
if (confirmDelete) {
|
if (confirmDelete) {
|
||||||
await api.deleteImage(src.filename);
|
await api.deleteImage(src.filename);
|
||||||
|
let newAllImages = allImages.filter(image => image.filename !== src.filename);
|
||||||
|
allImages = newAllImages;
|
||||||
imgContainer.remove();
|
imgContainer.remove();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const img = document.createElement("img");
|
const img = document.createElement("img");
|
||||||
|
img.setAttribute("filename", src.filename);
|
||||||
img.style.cssText = "height: 120px; width: 120px; object-fit: cover;";
|
img.style.cssText = "height: 120px; width: 120px; object-fit: cover;";
|
||||||
img.src = `/view?filename=${encodeURIComponent(src.filename)}&type=${src.type}&subfolder=${encodeURIComponent(src.subfolder)}`;
|
img.src = `/view?filename=${encodeURIComponent(src.filename)}&type=${src.type}&subfolder=${encodeURIComponent(src.subfolder)}`;
|
||||||
img.addEventListener("click", () => {
|
img.addEventListener("click", () => {
|
||||||
@ -208,6 +213,7 @@ app.registerExtension({
|
|||||||
right: "5px",
|
right: "5px",
|
||||||
});
|
});
|
||||||
clearButton.onclick = () => {
|
clearButton.onclick = () => {
|
||||||
|
allImages = []
|
||||||
imageList.replaceChildren(menu, resizeHandle);
|
imageList.replaceChildren(menu, resizeHandle);
|
||||||
};
|
};
|
||||||
const deleteAllButton = makeButton("🗑️ Delete", {
|
const deleteAllButton = makeButton("🗑️ Delete", {
|
||||||
@ -216,6 +222,7 @@ app.registerExtension({
|
|||||||
});
|
});
|
||||||
deleteAllButton.onclick = () => {
|
deleteAllButton.onclick = () => {
|
||||||
api.deleteAllImages();
|
api.deleteAllImages();
|
||||||
|
allImages = []
|
||||||
imageList.replaceChildren(menu, resizeHandle);
|
imageList.replaceChildren(menu, resizeHandle);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user