requestAnimationFrame iOS中的UIWebView未定义? [英] requestAnimationFrame undefined in iOS UIWebView?
本文介绍了requestAnimationFrame iOS中的UIWebView未定义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
requestAnimationFrame
似乎是未定义
在的UIWebView
。有没有做同样的事情或做我必须使用另一个函数的setTimeout
?
requestAnimationFrame
seems to be undefined
in UIWebView
. Is there another function that does the same thing or do I have to use setTimeout
?
推荐答案
它看起来像这不是当前的WebKit版本都支持,所以你必须使用一个超时。 本网站提供了如何创建一个跨平台解决方案的例子:
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);
};
})();
这篇关于requestAnimationFrame iOS中的UIWebView未定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文