Create your blog and photo album with postbit
Create your blog and photo album

Create new post

Content:

Upload a picture:
Tags (keywords separated by comma)

Save Cancel
The JavaScript Blog js:   Followers: 3 ; Following: 3

Explore The JavaScript Blog's photo albums:
Photos from posts (7)
Javascript tools (2)

requestAnimationFrame API


It's said that requestAnimationFrame is better than setTimeout, with better CPU Efficiency, lower power consumption, lower background interference and better callback management times.

Online performance comparison:
http://ie.microsoft.com/testdrive/Graphics/RequestAnimationFrame/Default.html

OLD METHOD (window.setTimeout):
function draw() {
var now = new Date().getTime();
updateModels(now - last);
last = now;
paintScene(canvas);
window.setTimeout(draw, 10);
});
draw();


NEW METHOD (requestAnimationFrame):
function draw(future) {

updateModels(future - last);
last = future;
paintScene(canvas);
requestAnimationFrame(draw, canvas);
};
draw();

Code from: http://www.htmlfivewow.com/slide48

Warning - This is an experimental technology, check syntax for multiple browsers:
https://developer.mozilla.org/en/DOM/window.requestAnimationFrame

Post by The JavaScript Blog (2012-06-21 14:49)

Post your comment:

Name: Email: Site:




| Explore users | New posts | Create your blog | Create your photo album |
| About Postbit | Our blog | Terms of use | Contact Postbit |


Copyright © 2017 - postbit.com