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

Function waitForIdle

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

Source from the content-addressed store, hash-verified

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

Callers 1

prefetch.tsFile · 0.85

Calls 1

fnFunction · 0.85

Tested by

no test coverage detected