fix(img): use setTimeout fallback on older versions of chrome (#21358)

This commit is contained in:
Evgeniy
2020-06-10 19:03:37 +03:00
committed by GitHub
parent cf3035778c
commit 0bf9449ee1

View File

@ -53,7 +53,11 @@ export class Img implements ComponentInterface {
if (this.src === undefined) { if (this.src === undefined) {
return; return;
} }
if ('IntersectionObserver' in window) { if (
typeof (window as any) !== 'undefined' &&
'IntersectionObserver' in window &&
'IntersectionObserverEntry' in window &&
'isIntersecting' in window.IntersectionObserverEntry.prototype) {
this.removeIO(); this.removeIO();
this.io = new IntersectionObserver(data => { this.io = new IntersectionObserver(data => {
// because there will only ever be one instance // because there will only ever be one instance