Reputation: 5177
requestAnimationFrame
seems to be undefined
in UIWebView
. Is there another function that does the same thing or do I have to use setTimeout
?
Upvotes: 4
Views: 2822
Reputation: 118701
It looks like this is not currently supported in all versions of WebKit, so you'll have to use a timeout. This site provides an example of how to create a cross-platform solution:
// via http://paulirish.com/2011/requestanimationframe-for-smart-animating/
window.requestAnimFrame = (function(){
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function(/* function */ callback, /* DOMElement */ element){
window.setTimeout(callback, 1000 / 60);
};
})();
Upvotes: 7