fix(img): fire didLoad in safari (#16571)

fixes #16557
This commit is contained in:
Manu MA
2018-12-03 19:22:37 +01:00
committed by GitHub
parent 0c36f0501b
commit 2ce986f39f

View File

@ -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();