Skip to content

Instantly share code, notes, and snippets.

@TylerJPresley
Last active September 4, 2017 20:40
Show Gist options
  • Save TylerJPresley/75244e50f81259cf52a06aa6186abe23 to your computer and use it in GitHub Desktop.
Save TylerJPresley/75244e50f81259cf52a06aa6186abe23 to your computer and use it in GitHub Desktop.
Very basic loader functionality // Aurelia (CLI/RequireJS)
<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>
/**
* 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