来自 MDN , 我有这个:
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.
有了这个,我可以假设使用 144hz 显示器,例如,我可以有
requestAnimationFrame
运行速度超过 60 fps?
最佳答案
完全正确。
这是一个简单的测量示例:
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();
在我的机器上,它显示 143.7401178670024。我正在使用 144HZ 显示器。
关于javascript - 速率高于 60 fps 的 requestAnimationFrame,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64955584/