MCPcopy Create free account
hub / github.com/adobe/react-spectrum / waitForIdle

Function waitForIdle

packages/dev/s2-docs/src/prefetch.ts:48–58  ·  view source on GitHub ↗
(fn)

Source from the content-addressed store, hash-verified

46}
47
48function waitForIdle(fn) {
49 // Wait for view transition to finish before pre-fetching.
50 // Otherwise try to wait for idle time so we don't interrupt interactions/animations.
51 if ('activeViewTransition' in document && document.activeViewTransition) {
52 (document.activeViewTransition as ViewTransition).finished.then(() => fn());
53 } else if (typeof requestIdleCallback === 'function') {
54 requestIdleCallback(fn);
55 } else {
56 setTimeout(fn, 0);
57 }
58}
59
60let observer =
61 typeof IntersectionObserver !== 'undefined'

Callers 1

prefetch.tsFile · 0.85

Calls 1

fnFunction · 0.85

Tested by

no test coverage detected