| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | return new Promise((resolve) => { |
| 30 | | - // Spinner blurs/fades out |
| 30 | + const spinner = $('#load-spinner'); |
| 31 | | - $('#load-spinner').on('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function () { |
| 31 | + if (!spinner.length) { |
| 32 | + console.warn('Spinner element not found, skipping animation'); |
| 33 | + cleanup(); |
| 34 | + return; |
| 35 | + } |
| 36 | + |
| 37 | + // Check if transitions are enabled |
| 38 | + const transitionDuration = spinner[0] ? getComputedStyle(spinner[0]).transitionDuration : '0s'; |
| 39 | + const hasTransitions = parseFloat(transitionDuration) > 0; |
| 40 | + |
| 41 | + if (hasTransitions) { |
| 42 | + Promise.race([ |
| 43 | + new Promise((r) => setTimeout(r, 500)), // Fallback timeout |
| 44 | + new Promise((r) => spinner.one('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', r)), |
| 45 | + ]).finally(cleanup); |
| 46 | + } else { |
| 47 | + cleanup(); |
| 48 | + } |
| 49 | + |
| 50 | + function cleanup() { |
| 32 | 51 | $('#loader').remove(); |
| 33 | 52 | // Yoink preloader entirely; it only exists to cover up unstyled content while loading JS |
| 34 | 53 | // If it's present, we remove it once and then it's gone. |
| 35 | 54 | yoinkPreloader(); |
| 36 | 55 | |
| 37 | 56 | loaderPopup.complete(POPUP_RESULT.AFFIRMATIVE).then(() => { |
| 57 | + .catch((err) => console.error('Error completing loaderPopup:', err)) |
| 58 | + .finally(() => { |
| 38 | 59 | loaderPopup = null; |
| 39 | 60 | resolve(); |
| 40 | 61 | }); |
| 41 | 62 | }); |
| 42 | 63 | |
| 43 | | - $('#load-spinner') |
| 64 | + // Apply the styles |
| 44 | 65 | spinner.css({ |
| 45 | 66 | 'filter': 'blur(15px)', |
| 46 | 67 | 'opacity': '0', |
| 47 | 68 | }); |