W3C home > Mailing lists > Public > public-web-perf@w3.org > November 2012

[RequestAnimationFrame] don't loop getElementById

From: Fred . <eldmannen@gmail.com>
Date: Mon, 12 Nov 2012 14:43:58 +0100
Message-ID: <CAJgfmqWwCm4i0YfpbukVQsyat37w5r4JY==1gqw4WfAubFuUJg@mail.gmail.com>
To: public-web-perf@w3.org
function animate(time) {
  document.getElementById("animated").style.left =
    (time - animationStartTime) % 2000 / 4 + "px";
  requestId = window.requestAnimationFrame(animate);
}

document.getElementById("animated") should be declared outside the
animate() function.
Received on Monday, 12 November 2012 13:44:25 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 12 November 2012 13:44:25 GMT