admin管理员组文章数量:1315779
From MDN, I have this:
Be sure to always use the first argument (or some other method for getting the current time) to calculate how much the animation will progress in a frame, otherwise the animation will run faster on high refresh rate screens.
With this, Can I assume that with a 144hz monitor, for instance, I could have requestAnimationFrame
running faster than 60 fps?
From MDN, I have this:
Be sure to always use the first argument (or some other method for getting the current time) to calculate how much the animation will progress in a frame, otherwise the animation will run faster on high refresh rate screens.
With this, Can I assume that with a 144hz monitor, for instance, I could have requestAnimationFrame
running faster than 60 fps?
- Can you clarify on what the "elapsed technique" is? Not sure how you can "control" (increase) refresh rate at native code level with sandboxed script. – Daniel Cheung Commented Nov 22, 2020 at 15:03
-
Sry, forget about this elapsed technique, it does not apply to
requestAnimationFrame
. – João Paulo Commented Nov 22, 2020 at 15:07 - 4 From the same MDN page, "The number of callbacks is usually 60 times per second, but will generally match the display refresh rate in most web browsers as per W3C remendation." So yes. – Daniel Cheung Commented Nov 22, 2020 at 15:11
- Nice, didn't see this one! Thank you. – João Paulo Commented Nov 22, 2020 at 15:12
- 3 Just remember JS is browser dependent. Make to to test on different browsers. I also won't be surprised it's OS dependent as well, since browsers rely on the desktop's window management program as well to give them reliable information about the displays. – Daniel Cheung Commented Nov 22, 2020 at 15:13
1 Answer
Reset to default 9Exactly true.
Here is a simple example to measure:
let i = 0;
const start = Date.now();
const stop = start + 5000;
function raf() {
requestAnimationFrame(() => {
const now = Date.now();
if (now < stop){
i++;
raf();
}else{
const elapsedSeconds = (now - start) / 1000;
console.log('Frame rate is: %f fps', i / elapsedSeconds);
}
});
}
console.log('Testing frame rate...')
raf();
On my machine, it shows 143.7401178670024. And I am using 144HZ monitor.
本文标签: javascriptrequestAnimationFrame with higher rate than 60 fpsStack Overflow
版权声明:本文标题:javascript - requestAnimationFrame with higher rate than 60 fps - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741992080a2409308.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论