SillyTavern/public/scripts/loader.js

29 lines
940 B
JavaScript
Raw Normal View History

2023-10-31 21:16:33 +01:00
const ELEMENT_ID = 'loader';
export function showLoader() {
const container = $('<div></div>').attr('id', ELEMENT_ID);
2023-12-02 20:11:06 +01:00
const loader = $('<div></div>').attr('id', 'load-spinner').addClass('fa-solid fa-gear fa-spin fa-3x');
2023-10-31 21:16:33 +01:00
container.append(loader);
$('body').append(container);
2023-11-01 04:40:21 +01:00
2023-10-31 21:16:33 +01:00
}
export function hideLoader() {
2023-11-01 04:40:21 +01:00
//Sets up a 2-step animation. Spinner blurs/fades out, and then the loader shadow does the same.
2023-12-02 19:04:51 +01:00
$('#load-spinner').on('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function () {
2023-11-01 04:40:21 +01:00
//console.log('FADING BLUR SCREEN')
$(`#${ELEMENT_ID}`)
.animate({ opacity: 0 }, 300, function () {
//console.log('REMOVING LOADER')
2023-12-02 20:11:06 +01:00
$(`#${ELEMENT_ID}`).remove();
});
});
2023-11-01 04:40:21 +01:00
//console.log('BLURRING SPINNER')
2023-12-02 19:04:51 +01:00
$('#load-spinner')
2023-11-01 04:40:21 +01:00
.css({
'filter': 'blur(15px)',
'opacity': '0',
2023-12-02 20:11:06 +01:00
});
2023-12-03 13:23:20 +01:00
}