Added avatar loading

This commit is contained in:
2017-06-19 17:45:27 +02:00
parent 10edd306f1
commit eea81b3eca
6 changed files with 61 additions and 30 deletions

View File

@ -7,9 +7,41 @@ export class AnimeNotifier {
this.app = app
}
onReadyStateChange() {
if(document.readyState !== "interactive") {
return
}
this.run()
}
run() {
this.app.content = this.app.find("content")
this.app.loading = this.app.find("loading")
this.app.run()
}
onContentLoaded() {
this.updateAvatars()
}
updateAvatars() {
let images = document.querySelectorAll('.user-image')
for(let i = 0; i < images.length; ++i) {
let img = images[i] as HTMLImageElement
if(img.naturalWidth === 0) {
img.onload = function() {
this.classList.add("user-image-found")
}
img.onerror = function() {
this.classList.add("user-image-not-found")
}
} else {
img.classList.add("user-image-found")
}
}
}
}