For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt, and this page is available as Markdown at /next/api/lynx-api/lynx/lynx-request-animation-frame.md.
Lynx
  • English
  • requestAnimationFrame()

    Invoke the specified callback function at the next VSYNC.

    requestAnimationFrame is typically used in scenarios where you want to achieve animation effects by modifying element attributes in each frame. Note that requestAnimationFrame will only take effect in the next frame; if you want it to continue to take effect, you need to nest requestAnimationFrame.

    Syntax

    requestAnimationFrame: (callback: (timeStamp: number) => void) => number;

    Parameters

    callback

    The callback function that needs to be called at the next VSYNC. The callback function has one parameter timeStamp, which is the moment when the callback function starts to execute.

    Return Value

    An integer type id, used to cancel this requestAnimationFrame callback.

    Examples

    Print the frame rate in the console:

    Compatibility

    LCD tables only load in the browser

    Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.