本文介绍了如何测试(automatedly)该浏览器重绘后发生的操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
根据的意见,以下技术的执行操作异步但对于一个重绘等待:
According to the comments of this blog post, the following technique executes an operation asynchronously but waits for a repaint:
function nextTick(callback) {
var img = new Image;
img.onerror = callback;
img.src = 'data:image/png,' + Math.random();
}
而这一个不等待重绘:
whereas this one does not wait for a repaint:
var mc = new MessageChannel;
function nextTick(callback) {
mc.port1.onmessage = callback;
mc.port2.postMessage(0);
}
我怎么能验证这一点,编程,在多个平台上运行的自动化测试的方式/浏览器可以检查?
How could I verify this, programmatically, in a way that automated tests running on multiple platforms/browsers could check?
推荐答案
您可能希望在博客中使用 requestAnimationFrame
,而不是解决办法的。
You may want to use requestAnimationFrame
instead of the workaround in the blog post.
了解更多关于它在保罗爱尔兰的博客
Read more about it at Paul Irish's blog http://paulirish.com/2011/requestanimationframe-for-smart-animating/
这篇关于如何测试(automatedly)该浏览器重绘后发生的操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!