2020-01-17 23:37:52 +03:00
|
|
|
// On page initialization loader is already visible, so initial value is 1
|
|
|
|
let stack = 1;
|
|
|
|
|
|
|
|
export function show(): void {
|
2020-05-24 02:08:24 +03:00
|
|
|
if (++stack >= 0) {
|
|
|
|
const loader = document.getElementById('loader');
|
2020-01-17 23:37:52 +03:00
|
|
|
|
2020-05-24 02:08:24 +03:00
|
|
|
if (!loader) {
|
|
|
|
throw new Error('Can not find loader element');
|
|
|
|
}
|
2020-01-17 23:37:52 +03:00
|
|
|
|
2020-05-24 02:08:24 +03:00
|
|
|
loader.classList.add('is-active');
|
|
|
|
}
|
2020-01-17 23:37:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
export function hide(): void {
|
2020-05-24 02:08:24 +03:00
|
|
|
if (--stack <= 0) {
|
|
|
|
stack = 0;
|
|
|
|
const loader = document.getElementById('loader');
|
2020-01-17 23:37:52 +03:00
|
|
|
|
2020-05-24 02:08:24 +03:00
|
|
|
if (!loader) {
|
|
|
|
throw new Error('Can not find loader element');
|
|
|
|
}
|
2020-01-17 23:37:52 +03:00
|
|
|
|
2020-05-24 02:08:24 +03:00
|
|
|
loader.classList.remove('is-active', 'is-first-launch');
|
|
|
|
}
|
2020-01-17 23:37:52 +03:00
|
|
|
}
|