Skip to content

Instantly share code, notes, and snippets.

@LostKobrakai
Last active April 13, 2023 08:34
Show Gist options
  • Save LostKobrakai/48cda87ecb7e704344e20ed2d667998f to your computer and use it in GitHub Desktop.
Save LostKobrakai/48cda87ecb7e704344e20ed2d667998f to your computer and use it in GitHub Desktop.
// Courtesy of @chrismccord
let pageLoadingDone = new Promise(resolve => {
window.addEventListener("phx:page-loading-stop", _info => {
topbar.hide()
resolve()
}, {once: true})
})
window.addEventListener("phx:page-loading-start", _info => {
if(navigation.navigate){
navigation.addEventListener("navigate", e => e.intercept({handler: () => pageLoadingDone}), {once: true})
navigation.navigate(location.href)
}
topbar.show(200)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment