@@ -184,16 +184,23 @@ export const Router: FC<RouterProps> = ({ ssrContext, suspense }) => {
184
184
clearTimeout ( loading ) ;
185
185
loadingBar . remove ( ) ;
186
186
} else {
187
- const fadeOutTime = 1.0 ;
188
- loadingBar . style . transition = `opacity ${ fadeOutTime } s ease-in-out, width ${ fadeOutTime } s ease-in-out` ;
189
- setTimeout ( ( ) => {
187
+ const moveOutTime = 0.7 ;
188
+ const fadeOutTime = 0.3 ;
189
+ const t1 = setTimeout ( ( ) => {
190
190
loadingBar . style . opacity = "0" ;
191
+ } , moveOutTime * 1000 ) ;
192
+ const t2 = setTimeout ( ( ) => {
193
+ global . __loading_bar_cleanup = null ;
194
+ loadingBar . remove ( ) ;
195
+ } , ( moveOutTime + fadeOutTime ) * 1000 ) ;
196
+ global . __loading_bar_cleanup = ( ) => {
197
+ clearTimeout ( t1 ) ;
198
+ clearTimeout ( t2 ) ;
199
+ } ;
200
+ loadingBar . style . transition = `opacity ${ fadeOutTime } s ease-out, width ${ moveOutTime } s ease-in-out` ;
201
+ setTimeout ( ( ) => {
191
202
loadingBar . style . width = "100%" ;
192
203
} , 0 ) ;
193
- global . __loading_bar_remove_timer = setTimeout ( ( ) => {
194
- global . __loading_bar_remove_timer = null ;
195
- loadingBar . remove ( ) ;
196
- } , fadeOutTime * 1000 ) ;
197
204
}
198
205
} , 0 ) ;
199
206
if ( e . url ) {
@@ -310,9 +317,9 @@ function loadSSRModulesFromTag(): RouteModule[] {
310
317
}
311
318
312
319
function getLoadingBar ( ) : HTMLDivElement {
313
- if ( typeof global . __loading_bar_remove_timer === "number " ) {
314
- clearTimeout ( global . __loading_bar_remove_timer ) ;
315
- global . __loading_bar_remove_timer = null ;
320
+ if ( typeof global . __loading_bar_cleanup === "function " ) {
321
+ global . __loading_bar_cleanup ( ) ;
322
+ global . __loading_bar_cleanup = null ;
316
323
}
317
324
let bar = ( document . getElementById ( "loading-bar" ) as HTMLDivElement | null ) ;
318
325
if ( ! bar ) {
@@ -324,11 +331,12 @@ function getLoadingBar(): HTMLDivElement {
324
331
position : "fixed" ,
325
332
top : "0" ,
326
333
left : "0" ,
334
+ zIndex : "9999" ,
327
335
width : "0" ,
328
336
height : "1px" ,
329
337
opacity : "0" ,
330
338
background : "rgba(128, 128, 128, 0.9)" ,
331
- transition : "opacity 0.6s ease-in-out , width 3s ease-in-out " ,
339
+ transition : "opacity 0.6s ease-in, width 3s ease-in" ,
332
340
} ) ;
333
341
return bar ;
334
342
}
0 commit comments