mirror of
https://github.com/thelounge/thelounge
synced 2024-11-26 14:00:21 +00:00
Unbind image events after the image is loaded
This commit is contained in:
parent
f6051d3f6b
commit
12bbaef4ab
1 changed files with 6 additions and 2 deletions
|
@ -26,11 +26,15 @@ function renderPreview(preview, msg) {
|
|||
|
||||
// If there is an image in preview, wait for it to load before appending it to DOM
|
||||
// This is done to prevent problems keeping scroll to the bottom while images load
|
||||
image.on("load", () => appendPreview(preview, msg, template));
|
||||
image.on("load.preview", () => {
|
||||
image.off(".preview");
|
||||
|
||||
appendPreview(preview, msg, template);
|
||||
});
|
||||
|
||||
// If the image fails to load, remove it from DOM and still render the preview
|
||||
if (preview.type === "link") {
|
||||
image.on("abort error", () => {
|
||||
image.on("abort.preview error.preview", () => {
|
||||
image.parent().remove();
|
||||
|
||||
appendPreview(preview, msg, template);
|
||||
|
|
Loading…
Reference in a new issue