Added minimal polyfill for IntersectionObserver
This commit is contained in:
parent
b6c4968c6c
commit
49a6d8b7fa
@ -9,17 +9,30 @@ export class AnimeNotifier {
|
|||||||
|
|
||||||
constructor(app: Application) {
|
constructor(app: Application) {
|
||||||
this.app = app
|
this.app = app
|
||||||
this.visibilityObserver = new IntersectionObserver(
|
|
||||||
entries => {
|
if("IntersectionObserver" in window) {
|
||||||
for(let entry of entries) {
|
// Enable lazy load
|
||||||
if(entry.intersectionRatio > 0) {
|
this.visibilityObserver = new IntersectionObserver(
|
||||||
entry.target["became visible"]()
|
entries => {
|
||||||
this.visibilityObserver.unobserve(entry.target)
|
for(let entry of entries) {
|
||||||
|
if(entry.intersectionRatio > 0) {
|
||||||
|
entry.target["became visible"]()
|
||||||
|
this.visibilityObserver.unobserve(entry.target)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
{}
|
||||||
{}
|
)
|
||||||
)
|
} else {
|
||||||
|
// Disable lazy load feature
|
||||||
|
this.visibilityObserver = {
|
||||||
|
disconnect: () => {},
|
||||||
|
observe: (elem: HTMLElement) => {
|
||||||
|
elem["became visible"]()
|
||||||
|
},
|
||||||
|
unobserve: (elem: HTMLElement) => {}
|
||||||
|
} as IntersectionObserver
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onReadyStateChange() {
|
onReadyStateChange() {
|
||||||
|
Loading…
Reference in New Issue
Block a user