如果检测到任何页面上正在动画 [英] Detecting if Anything on the Page is being Animated
问题描述
我知道关于:动画
选择,但目前正在到(可能是什么数之一)老年IE的(去图)性能问题。我觉得所有可能会我测试了道路的的任何的网页动画
I know about the :animated
selector, but currently am running into (what might be one of a few) performance issue for older IE's (go figure). I feel like it might potentially be the way I'm testing for ANY Page Animation.
目前,我通过循环的间隔,与核心测试正在 $('*')是(':动画')
。这 $('*')
是我很担心......但因为我不知道什么exaclty的div的/ etc正正在下面的动画我的插件,我不知道怎么回事办呢!
Currently I'm looping through an interval, with the core test being $('*').is(':animated')
. This $('*')
is what i'm worried about... but since I don't know exaclty what the divs / etc are that are being animated below my plugin, I'm not sure how else to do it!
var testAnimationInterval = setInterval(function () {
if ( ! $('*').is(':animated') ) { // all done animating
clearInterval(testAnimationInterval);
animationsFinished(); // callback function
}
}, 300);
function animationsFinished() {
// do whatever
}
有没有人找到这样做的更好/不同的方式?特别是当它涉及到性能?
Has anyone found a better / different way of doing this? Especially when it comes to performance?
推荐答案
所有的jQuery动画定时器存储阵列的 $。定时器
。一种选择是只是为了检查
属性是否大于零: $的长度
计时器
All jQuery animation timers are stored in the array $.timers
. One option is just to check whether length
of $.timers
property is more than zero:
if ($.timers.length > 0) {
// something is animating
}
这篇关于如果检测到任何页面上正在动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!