mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 03:32:21 +08:00
@ -47,19 +47,23 @@ export class Img implements ComponentInterface {
|
|||||||
// of the element we are observing
|
// of the element we are observing
|
||||||
// we can just use data[0]
|
// we can just use data[0]
|
||||||
if (data[0].isIntersecting) {
|
if (data[0].isIntersecting) {
|
||||||
this.loadSrc = this.src;
|
this.load();
|
||||||
this.removeIO();
|
this.removeIO();
|
||||||
this.ionImgDidLoad.emit();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.io.observe(this.el);
|
this.io.observe(this.el);
|
||||||
} else {
|
} else {
|
||||||
// fall back to setTimeout for Safari and IE
|
// 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() {
|
private removeIO() {
|
||||||
if (this.io) {
|
if (this.io) {
|
||||||
this.io.disconnect();
|
this.io.disconnect();
|
||||||
|
Reference in New Issue
Block a user