From 22f92f18cf8a347d25467705aa079529ac2d491c Mon Sep 17 00:00:00 2001 From: Sharmee Date: Thu, 20 Feb 2025 14:10:36 +0530 Subject: [PATCH] Hide notification element untill the image is loaded --- libs/blocks/aside/aside.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libs/blocks/aside/aside.js b/libs/blocks/aside/aside.js index 11bfc7291f..c5d5bab189 100644 --- a/libs/blocks/aside/aside.js +++ b/libs/blocks/aside/aside.js @@ -195,7 +195,16 @@ function decorateLayout(el) { if (iconVariant) loadIconography(); iconArea.classList.add(iconClass); const image = iconArea.querySelector('img'); - iconArea.style.aspectRatio = image.width / image.height; + if (image) { + if (image.complete) { + el.style.visibility = 'visible'; + } else { + el.style.visibility = 'hidden'; + image.addEventListener('load', () => { + el.style.visibility = 'visible'; + }); + } + } } const foregroundImage = foreground.querySelector(':scope > div:not(.text) img')?.closest('div'); const bgImage = el.querySelector(':scope > div:not(.text):not(.foreground) img')?.closest('div');