Last active
April 13, 2023 08:34
-
-
Save LostKobrakai/48cda87ecb7e704344e20ed2d667998f to your computer and use it in GitHub Desktop.
Phoenix LiveView browser loading spinner / https://twitter.com/_developit/status/1625612424576376840?s=12&t=r2wsZ3n1jFq2d8DsnGMu-Q
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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