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

    在下一次 VSYNC 时调用指定回调函数。

    requestAnimationFrame 通常用于希望通过在每一帧内修改属性来实现动画效果的场景。 注意 requestAnimationFrame 只会在下一帧生效;如果希望使其持续生效,需要嵌套调用 requestAnimationFrame

    语法

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

    参数

    callback

    在下一次 VSYNC 时,需要调用的回调函数。回调函数具有一个参数 timeStamp,是开始执行回调函数的时刻。

    返回值

    一个整数类型的 id,用于取消这个 requestAnimationFrame 的回调。

    示例

    在控制台中打印帧率:

    兼容性

    LCD tables only load in the browser

    除非另有说明,本项目采用知识共享署名 4.0 国际许可协议进行许可,代码示例采用 Apache License 2.0 许可协议进行许可。