mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-02-16 16:32:34 +08:00
Update imageFeed.js
Add left and right keys to image preview for image drawer
This commit is contained in:
parent
9e21b14f69
commit
1e517f9e86
@ -156,19 +156,33 @@ app.registerExtension({
|
|||||||
popup.remove();
|
popup.remove();
|
||||||
});
|
});
|
||||||
nextButton.addEventListener("click", () => {
|
nextButton.addEventListener("click", () => {
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
prevButton.addEventListener("click", () => {
|
||||||
|
prev();
|
||||||
|
});
|
||||||
|
function next(){
|
||||||
currentIndex--;
|
currentIndex--;
|
||||||
if (currentIndex < 0) {
|
if (currentIndex < 0) {
|
||||||
currentIndex = allImages.length - 1;
|
currentIndex = allImages.length - 1;
|
||||||
}
|
}
|
||||||
popupImg.src = `/view?filename=${encodeURIComponent(allImages[currentIndex].filename)}&type=${allImages[currentIndex].type}&subfolder=${encodeURIComponent(allImages[currentIndex].subfolder)}`;
|
popupImg.src = `/view?filename=${encodeURIComponent(allImages[currentIndex].filename)}&type=${allImages[currentIndex].type}&subfolder=${encodeURIComponent(allImages[currentIndex].subfolder)}`;
|
||||||
});
|
}
|
||||||
prevButton.addEventListener("click", () => {
|
function prev(){
|
||||||
currentIndex++;
|
currentIndex++;
|
||||||
if (currentIndex >= allImages.length) {
|
if (currentIndex >= allImages.length) {
|
||||||
currentIndex = 0;
|
currentIndex = 0;
|
||||||
}
|
}
|
||||||
popupImg.src = `/view?filename=${encodeURIComponent(allImages[currentIndex].filename)}&type=${allImages[currentIndex].type}&subfolder=${encodeURIComponent(allImages[currentIndex].subfolder)}`;
|
popupImg.src = `/view?filename=${encodeURIComponent(allImages[currentIndex].filename)}&type=${allImages[currentIndex].type}&subfolder=${encodeURIComponent(allImages[currentIndex].subfolder)}`;
|
||||||
});
|
}
|
||||||
|
document.addEventListener('keydown', function(event) {
|
||||||
|
if (event.keyCode === 37) {
|
||||||
|
prev();
|
||||||
|
}
|
||||||
|
else if (event.keyCode === 39) {
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
});
|
||||||
popup.addEventListener("click", (event) => {
|
popup.addEventListener("click", (event) => {
|
||||||
if (event.target === popup) {
|
if (event.target === popup) {
|
||||||
popup.remove();
|
popup.remove();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user