File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed
Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -14,17 +14,14 @@ const idlePhaseTracker = createPhaseTracker((callback: (idlePhase: IdlePhase) =>
1414 nextTask ( ( ) => {
1515 shouldRequestAnimationFrame = true
1616
17- let start : number | undefined
17+ const start = Date . now ( )
18+ const deadline = start + 16
1819 callback ( {
19- get start ( ) {
20- start = start ?? Date . now ( )
21- return start
22- } ,
20+ start,
2321 deadline : {
2422 didTimeout : false ,
2523 timeRemaining ( ) : DOMHighResTimeStamp {
26- start = start ?? Date . now ( )
27- return Math . max ( start + 16 - Date . now ( ) , 0 )
24+ return Math . max ( deadline - Date . now ( ) , 0 )
2825 } ,
2926 } ,
3027 } )
@@ -142,7 +139,10 @@ export function getIdlePhase(): IdlePhase | undefined {
142139 const deadline = idlePhaseTracker . getPhase ( ) ?. deadline
143140 const idlePhaseStart = idlePhaseTracker . getPhase ( ) ?. start
144141 const animationFramePhaseStart = animationFrameTracker . getPhase ( ) ?. start
145- const start = animationFramePhaseStart ?? idlePhaseStart
142+ const start =
143+ typeof requestIdleCallback === 'undefined'
144+ ? idlePhaseStart
145+ : animationFramePhaseStart ?? idlePhaseStart
146146
147147 return start === undefined || deadline === undefined ? undefined : { start, deadline }
148148}
You can’t perform that action at this time.
0 commit comments