Last active
September 4, 2017 20:40
-
-
Save TylerJPresley/75244e50f81259cf52a06aa6186abe23 to your computer and use it in GitHub Desktop.
Very basic loader functionality // Aurelia (CLI/RequireJS)
This file contains hidden or 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
<template> | |
<router-view></router-view> | |
<div id="page-loading" show.bind="_router.isNavigating"> | |
<div id="page-loading-inner"> | |
<!-- Loading animation or text --> | |
</div> | |
</div> | |
</template> |
This file contains hidden or 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
/** | |
* Loader Class | |
* @class | |
*/ | |
export class Loader { | |
/** | |
* Adds the class the shows the loader on the page | |
*/ | |
show() { | |
this.loader = document.getElementById('page-loading'); | |
if (this.loader.classList.contains('aurelia-hide')) { | |
this.loader.classList.remove('aurelia-hide'); | |
this.loader.classList.add('aurelia-show'); | |
} | |
} | |
/** | |
* Removes the class the shows the loader on the page | |
*/ | |
hide() { | |
this.loader = document.getElementById('page-loading'); | |
if (this.loader.classList.contains('aurelia-show')) { | |
this.loader.classList.remove('aurelia-show'); | |
this.loader.classList.add('aurelia-hide'); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment