MCPcopy Create free account
hub / github.com/bvaughn/react-virtualized / requestAnimationTimeout

Function requestAnimationTimeout

lib/utils/requestAnimationTimeout.ts:16–39  ·  view source on GitHub ↗
(
  callback: () => void,
  delay: number
)

Source from the content-addressed store, hash-verified

14 * Credit: Joe Lambert (https://gist.github.com/joelambert/1002116#file-requesttimeout-js)
15 */
16export const requestAnimationTimeout = (
17 callback: () => void,
18 delay: number
19): AnimationTimeoutId => {
20 let start: number;
21 // wait for end of processing current event handler, because event handler may be long
22 Promise.resolve().then(() => {
23 start = Date.now();
24 });
25
26 const timeout = () => {
27 if (Date.now() - start >= delay) {
28 callback.call(undefined);
29 } else {
30 frame.id = raf(timeout);
31 }
32 };
33
34 const frame: AnimationTimeoutId = {
35 id: raf(timeout)
36 };
37
38 return frame;
39};

Callers 3

debounceResetIsScrollingFunction · 0.90
debounceScrollEndedFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected