requestAnimationFrame at a limited framerate

前端 未结 3 1179
梦毁少年i
梦毁少年i 2020-12-30 04:16

As I understand it, usage of the JS requestAnimationFrame API is intended for cases where the framerate isn\'t in need of being controlled, but I have a use cas

3条回答
  •  醉梦人生
    2020-12-30 05:13

    What you can do, though I don't really know if this is really any better is:

    • render to an invisible context with requestAnimationFrame
    • update a visible context with setInterval using a fixed fps

    Example:

    
    

    Demo: http://jsfiddle.net/54vWN/

提交回复
热议问题