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

@ -16,6 +16,12 @@ export class Application {
this.fadeOutClass = "fade-out"
}
run() {
this.ajaxify()
this.markActiveLinks()
this.loading.classList.add(this.fadeOutClass)
}
find(id: string): HTMLElement {
return document.getElementById(id)
}
@ -48,14 +54,7 @@ export class Application {
this.currentURL = url
// function sleep(ms) {
// return new Promise(resolve => setTimeout(resolve, ms))
// }
// sleep(500).then(() => {
// })
// Start sending a network request
let request = this.get("/_" + url)
let onTransitionEnd = e => {
@ -81,6 +80,9 @@ export class Application {
// Fade animations
this.content.classList.remove(this.fadeOutClass)
this.loading.classList.add(this.fadeOutClass)
// Send DOMContentLoaded Event
this.emit("DOMContentLoaded")
})
}
@ -136,21 +138,15 @@ export class Application {
e.preventDefault()
e.stopPropagation()
if(!url || url === window.location.pathname)
if(!url || url === self.currentURL)
return
// Load requested page
self.load(url, true)
}
}
}
run() {
this.ajaxify()
this.markActiveLinks()
this.loading.classList.add(this.fadeOutClass)
}
scrollToTop() {
let parent = this.content
@ -158,4 +154,11 @@ export class Application {
parent.scrollTop = 0
}
}
emit(eventName: string) {
document.dispatchEvent(new Event(eventName, {
"bubbles": true,
"cancelable": true
}))
}
}