This commit is contained in:
pythongosssss
2024-03-24 16:24:03 +00:00
2 changed files with 12 additions and 0 deletions
+10
View File
@@ -107,6 +107,16 @@ export class Lightbox {
this.img.src = img;
this.img.style.opacity = 1;
}
async updateWithNewImage(img, feedDirection) {
// No-op if lightbox is not open
if (this.el.style.display === "none" || this.el.style.opacity === "0") return;
// Ensure currently shown image does not change
const [method, shift] = feedDirection === "newest first" ? ["unshift", 1] : ["push", 0];
this.images[method](img);
await this.update(shift);
}
}
export const lightbox = new Lightbox();
+2
View File
@@ -438,6 +438,8 @@ app.registerExtension({
),
])
);
// If lightbox is open, update it with new image
lightbox.updateWithNewImage(href, feedDirection.value);
}
}
});