IMPR: Show spinner on page unload

This commit is contained in:
Tony Air 2023-08-04 00:02:42 +02:00
parent 99e5e666d1
commit 2342f7347a

View File

@ -58,6 +58,13 @@ const MainUI = ((window) => {
// const ui = this
console.log(`${NAME}: loaded`)
}
static unloaded () {
console.log(`${NAME}: unloaded`)
SpinnerUI.show()
BODY.classList.remove('loaded')
}
}
const documentInit = () => {
@ -66,12 +73,6 @@ const MainUI = ((window) => {
BODY.classList.add('loaded')
SpinnerUI.hide()
window.addEventListener('beforeunload', () => {
console.log(`${NAME} before unload`)
SpinnerUI.show()
BODY.classList.remove('loaded')
})
console.groupEnd('init')
console.timeEnd('init')
@ -90,6 +91,10 @@ const MainUI = ((window) => {
MainUI.loaded()
})
window.addEventListener('beforeunload', () => {
MainUI.unloaded()
})
window.MainUI = MainUI
return MainUI