26 lines
884 B
JavaScript
Raw Normal View History

2023-10-31 22:16:33 +02:00
const ELEMENT_ID = 'loader';
export function showLoader() {
const container = $('<div></div>').attr('id', ELEMENT_ID);
2023-12-02 21:11:06 +02:00
const loader = $('<div></div>').attr('id', 'load-spinner').addClass('fa-solid fa-gear fa-spin fa-3x');
2023-10-31 22:16:33 +02:00
container.append(loader);
$('body').append(container);
2024-04-08 00:18:21 +09:00
}
export async function hideLoader() {
2023-11-01 12:40:21 +09:00
//Sets up a 2-step animation. Spinner blurs/fades out, and then the loader shadow does the same.
2023-12-02 13:04:51 -05:00
$('#load-spinner').on('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function () {
2023-11-01 12:40:21 +09:00
$(`#${ELEMENT_ID}`)
2024-04-08 00:18:21 +09:00
//only fade out the spinner and replace with login screen
2023-11-01 12:40:21 +09:00
.animate({ opacity: 0 }, 300, function () {
2023-12-02 21:11:06 +02:00
$(`#${ELEMENT_ID}`).remove();
});
});
2023-11-01 12:40:21 +09:00
2023-12-02 13:04:51 -05:00
$('#load-spinner')
2023-11-01 12:40:21 +09:00
.css({
'filter': 'blur(15px)',
'opacity': '0',
2023-12-02 21:11:06 +02:00
});
2023-12-03 14:23:20 +02:00
}