mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-01-15 08:40:50 +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();
|
||||
});
|
||||
nextButton.addEventListener("click", () => {
|
||||
next();
|
||||
});
|
||||
prevButton.addEventListener("click", () => {
|
||||
prev();
|
||||
});
|
||||
function next(){
|
||||
currentIndex--;
|
||||
if (currentIndex < 0) {
|
||||
currentIndex = allImages.length - 1;
|
||||
}
|
||||
popupImg.src = `/view?filename=${encodeURIComponent(allImages[currentIndex].filename)}&type=${allImages[currentIndex].type}&subfolder=${encodeURIComponent(allImages[currentIndex].subfolder)}`;
|
||||
});
|
||||
prevButton.addEventListener("click", () => {
|
||||
}
|
||||
function prev(){
|
||||
currentIndex++;
|
||||
if (currentIndex >= allImages.length) {
|
||||
currentIndex = 0;
|
||||
}
|
||||
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) => {
|
||||
if (event.target === popup) {
|
||||
popup.remove();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user