From 2ce986f39f42a90449852b92b08900e5ec741293 Mon Sep 17 00:00:00 2001 From: Manu MA Date: Mon, 3 Dec 2018 19:22:37 +0100 Subject: [PATCH] fix(img): fire didLoad in safari (#16571) fixes #16557 --- core/src/components/img/img.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/src/components/img/img.tsx b/core/src/components/img/img.tsx index 9c2b928d60..6df82ede18 100644 --- a/core/src/components/img/img.tsx +++ b/core/src/components/img/img.tsx @@ -47,19 +47,23 @@ export class Img implements ComponentInterface { // of the element we are observing // we can just use data[0] if (data[0].isIntersecting) { - this.loadSrc = this.src; + this.load(); this.removeIO(); - this.ionImgDidLoad.emit(); } }); this.io.observe(this.el); } else { // fall back to setTimeout for Safari and IE - setTimeout(() => this.loadSrc = this.src, 200); + setTimeout(() => this.load(), 200); } } + private load() { + this.loadSrc = this.src; + this.ionImgDidLoad.emit(); + } + private removeIO() { if (this.io) { this.io.disconnect();