Search⌘ K
AI Features

The Timestamp Argument

Explore how to use the timestamp argument provided by requestAnimationFrame in animation callbacks. Understand its role as a high precision timer that tracks when callbacks occur, which is essential for creating smoother, time-based JavaScript animations. This lesson lays the foundation for advanced animation techniques using precise timing.

We'll cover the following...

The last thing we are going to look at is the argument requestAnimationFrame passes in to the callback function. The following is the callback function signature I showed you earlier:

Javascript (babel-node)
function draw() {
.
.
.
requestAnimationFrame(draw);
}

That is still accurate and totally works. There is an optional argument representing the exact time the callback function is called (aka a timestamp) that I kinda did not cover, and a big thanks to ...