2021-10-12 18:01:38 +03:00
|
|
|
import Component from '@glimmer/component';
|
2022-02-09 13:49:38 +03:00
|
|
|
import {task, timeout} from 'ember-concurrency';
|
2021-10-12 18:01:38 +03:00
|
|
|
import {tracked} from '@glimmer/tracking';
|
2017-01-18 02:44:08 +03:00
|
|
|
|
2021-10-12 18:01:38 +03:00
|
|
|
export default class GhLoadingSpinnerComponent extends Component {
|
|
|
|
@tracked showSpinner = false;
|
2017-01-18 02:44:08 +03:00
|
|
|
|
|
|
|
// ms until the loader is displayed,
|
|
|
|
// prevents unnecessary flash of spinner
|
2021-10-12 18:01:38 +03:00
|
|
|
slowLoadTimeout = 200;
|
2017-01-18 02:44:08 +03:00
|
|
|
|
2021-10-12 18:01:38 +03:00
|
|
|
constructor() {
|
|
|
|
super(...arguments);
|
2019-03-06 16:53:54 +03:00
|
|
|
this.startSpinnerTimeout.perform();
|
2021-10-12 18:01:38 +03:00
|
|
|
}
|
2018-01-11 20:43:23 +03:00
|
|
|
|
2021-10-12 18:01:38 +03:00
|
|
|
@task
|
|
|
|
*startSpinnerTimeout() {
|
2019-03-06 16:53:54 +03:00
|
|
|
yield timeout(this.slowLoadTimeout);
|
2021-10-12 18:01:38 +03:00
|
|
|
this.showSpinner = true;
|
|
|
|
}
|
|
|
|
}
|