Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

122
Vistas
Why does window.requestAnimationFrame run the step function only once?

When opening the following HTML file in a browser, the timestamp is only logged once, why isn't the step function called a bunch of times per second as I would except?

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Test</title>
</head>
<body>
<script>
    function step(timestamp) { console.log(timestamp) }
    window.requestAnimationFrame(step)
</script>
</body>
</html>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It only ever runs once. For it to repeat we must call requestAnimationFrame inside step for it to continue https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame

Before:

function step(timestamp) {
  console.log(timestamp)
}
window.requestAnimationFrame(step)

After:

let i = 0;

function step(timestamp) {
  console.log(timestamp);
  i++;

  if (i < 10) {
    window.requestAnimationFrame(step);
  }
}
window.requestAnimationFrame(step)

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda