Using requestAnimationFrame to create a fixed-speed animation

Wouldn’t animations on a 30fps screen be half as slow than on a screen with 60fps? What if you don’t want your animation to be just frame by frame, but there’s a time factor to it?
For example, I want a car moving at a fixed speed across the screen. Without any extra inputs like ‘time passed since’, how would you attempt to do this using requestAnimationFrame?

Hmm, if you don’t want to use the ‘time passed since’ input requestAnimationFrame gives you (which is actually a timestamp from which you would have to get the difference yourself), I’m not sure if there’s a good way to do it. Since there is no guarantee as to the timing of requestAnimationFrame you can’t make assumptions about the timing of the animation. You might have better luck with setInterval, since that is time-based, but even then, the timing isn’t guaranteed (both being throttled when in background tabs).

You’re better off just using the timestamp.

The other issue about raF that I ran into recently is that some monitors refresh at 120hz (and thus call raF 120 times a second). I’ll need to revise some of the content I’ve written to account for some of these differences.