Skip to content

requestAnimationFrameAsync

Gets the next request animation frame.

Import:

import { requestAnimationFrameAsync } from '@mnaoumov/typescript-lib/async';

Signature:

function requestAnimationFrameAsync(fallbackTimeoutInMilliseconds: number | undefined): Promise<void>

Parameters:

Parameter Type Description
fallbackTimeoutInMilliseconds number | undefined The fallback timeout in milliseconds to resolve the promise if requestAnimationFrame does not fire (e.g. the window is not active). Defaults to 100 milliseconds. Use 0 to disable the fallback.

Returns: Promise<void> — A promise that resolves when the next request animation frame is available (or when the fallback time is reached).