我知道 :animated
选择器,但目前正在遇到(可能是其中之一)旧版 IE 的性能问题(请看图)。我觉得这可能是我测试任何页面动画的方式。
目前我正在一个区间内循环,核心测试是 $('*').is(':animated')
。这 $('*')
是我担心的...但是因为我不知道下面正在动画的 divs 等到底是什么我的插件,我不知道还能怎么做!
var testAnimationInterval = setInterval(function () {
if ( ! $('*').is(':animated') ) { // all done animating
clearInterval(testAnimationInterval);
animationsFinished(); // callback function
}
}, 300);
function animationsFinished() {
// do whatever
}
有没有人找到更好/不同的方法来做到这一点?尤其是在性能方面?
最佳答案
所有 jQuery 动画定时器都存储在数组 $.timers
中.一种选择是检查 $.timers
属性的 length
是否大于零:
if ($.timers.length > 0) {
// something is animating
}
关于javascript - 检测页面上是否有任何动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14218363/