Skip to content

Commit f8ab64e

Browse files
committed
Always delay by 20ms
1 parent f87e7a4 commit f8ab64e

File tree

1 file changed

+5
-19
lines changed

1 file changed

+5
-19
lines changed

packages/react-dom/src/client/ReactDOMDefaultTransitionIndicator.js

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
* @flow
88
*/
99

10-
const defaultTransitionIndicatorDelay = 100;
11-
1210
export function defaultOnDefaultTransitionIndicator(): void | (() => void) {
1311
if (typeof navigation !== 'object') {
1412
// If the Navigation API is not available, then this is a noop.
@@ -18,10 +16,6 @@ export function defaultOnDefaultTransitionIndicator(): void | (() => void) {
1816
let isCancelled = false;
1917
let pendingResolve: null | (() => void) = null;
2018

21-
const scheduledAt = performance.now();
22-
// Delay the start a bit in case this is a fast Transition.
23-
setTimeout(startFakeNavigation, defaultTransitionIndicatorDelay);
24-
2519
function handleNavigate(event: NavigateEvent) {
2620
if (event.canIntercept && event.info === 'react-transition') {
2721
event.intercept({
@@ -35,7 +29,6 @@ export function defaultOnDefaultTransitionIndicator(): void | (() => void) {
3529
}
3630

3731
function handleNavigateComplete() {
38-
const wasRunning = pendingResolve !== null;
3932
if (pendingResolve !== null) {
4033
// If this was not our navigation completing, we were probably cancelled.
4134
// We'll start a new one below.
@@ -45,18 +38,8 @@ export function defaultOnDefaultTransitionIndicator(): void | (() => void) {
4538
if (!isCancelled) {
4639
// Some other navigation completed but we should still be running.
4740
// Start another fake one to keep the loading indicator going.
48-
if (wasRunning) {
49-
// Restart sync to make it not janky if it was already running
50-
startFakeNavigation();
51-
} else {
52-
// Since it hasn't started yet, we want to delay it up to a bit.
53-
// There needs to be an async gap to work around https://issues.chromium.org/u/1/issues/419746417.
54-
const fakeNavigationDelay = Math.max(
55-
0,
56-
defaultTransitionIndicatorDelay - (performance.now() - scheduledAt),
57-
);
58-
setTimeout(startFakeNavigation, fakeNavigationDelay);
59-
}
41+
// There needs to be an async gap to work around https://issues.chromium.org/u/1/issues/419746417.
42+
setTimeout(startFakeNavigation, 20);
6043
}
6144
}
6245

@@ -88,6 +71,9 @@ export function defaultOnDefaultTransitionIndicator(): void | (() => void) {
8871
}
8972
}
9073

74+
// Delay the start a bit in case this is a fast Transition.
75+
setTimeout(startFakeNavigation, 100);
76+
9177
return function () {
9278
isCancelled = true;
9379
// $FlowFixMe

0 commit comments

Comments
 (0)