From 12bbaef4ab9d7bacae281d6db7e094d85f62e503 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Thu, 8 Feb 2018 14:54:57 +0200 Subject: [PATCH] Unbind image events after the image is loaded --- client/js/renderPreview.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/client/js/renderPreview.js b/client/js/renderPreview.js index 5cc8ae80..0e72f050 100644 --- a/client/js/renderPreview.js +++ b/client/js/renderPreview.js @@ -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);