mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-02-18 21:20:39 +01:00
Update loader being removed correctly on manually forced transition duration (#3384)
--------- Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
This commit is contained in:
parent
0c121ee95a
commit
578c3dda73
@ -27,24 +27,45 @@ export async function hideLoader() {
|
||||
}
|
||||
|
||||
return new Promise((resolve) => {
|
||||
// Spinner blurs/fades out
|
||||
$('#load-spinner').on('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function () {
|
||||
const spinner = $('#load-spinner');
|
||||
if (!spinner.length) {
|
||||
console.warn('Spinner element not found, skipping animation');
|
||||
cleanup();
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if transitions are enabled
|
||||
const transitionDuration = spinner[0] ? getComputedStyle(spinner[0]).transitionDuration : '0s';
|
||||
const hasTransitions = parseFloat(transitionDuration) > 0;
|
||||
|
||||
if (hasTransitions) {
|
||||
Promise.race([
|
||||
new Promise((r) => setTimeout(r, 500)), // Fallback timeout
|
||||
new Promise((r) => spinner.one('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', r)),
|
||||
]).finally(cleanup);
|
||||
} else {
|
||||
cleanup();
|
||||
}
|
||||
|
||||
function cleanup() {
|
||||
$('#loader').remove();
|
||||
// Yoink preloader entirely; it only exists to cover up unstyled content while loading JS
|
||||
// If it's present, we remove it once and then it's gone.
|
||||
yoinkPreloader();
|
||||
|
||||
loaderPopup.complete(POPUP_RESULT.AFFIRMATIVE).then(() => {
|
||||
loaderPopup = null;
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
loaderPopup.complete(POPUP_RESULT.AFFIRMATIVE)
|
||||
.catch((err) => console.error('Error completing loaderPopup:', err))
|
||||
.finally(() => {
|
||||
loaderPopup = null;
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
|
||||
$('#load-spinner')
|
||||
.css({
|
||||
'filter': 'blur(15px)',
|
||||
'opacity': '0',
|
||||
});
|
||||
// Apply the styles
|
||||
spinner.css({
|
||||
'filter': 'blur(15px)',
|
||||
'opacity': '0',
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user