我有两个函数在这个小提琴中运行
$('.child0,.child1,.child2,.child3,.child4').hide();
fadeItIn();
setTimeout(fadeItInDoom, 500);
function fadeItIn() {
var child;
child = 4;
setTimeout(fadeIn, 3000);
function fadeIn() {
$("#child" + child).fadeIn(175);
--child;
if (child >= 0) {
// Continue fading in
setTimeout(fadeIn, 175);
} else {
// Start fading out
++child;
setTimeout(fadeOut, 175);
}
}
function fadeOut() {
$("#child" + child).fadeOut(175);
++child;
if (child <= 4) {
// Continue fading out
setTimeout(fadeOut, 175);
} else {
// Start over again
setTimeout(fadeIn, 3000 - 1575);
}
}
}
function fadeItInDoom() {
var doom;
doom = 4;
setTimeout(fadeInDoom, 3000);
function fadeInDoom() {
$("#doom" + doom).fadeIn(175);
--doom;
if (doom >= 0) {
// Continue fading in
setTimeout(fadeInDoom, 175);
} else {
// Start fading out
++doom;
setTimeout(fadeOutDoom, 175);
}
}
function fadeOutDoom() {
$("#doom" + doom).fadeOut(175);
++doom;
if (doom <= 4) {
// Continue fading out
setTimeout(fadeOutDoom, 175);
} else {
// Start over again
setTimeout(fadeInDoom, 3000 - 1575);
}
}
}
我希望fadeItInDoom 在fadeItIn 后500 毫秒内出现。This works, but the problem I am having is that when the tab becomes inactive, the timing of the second pulse animation gets off. 虽然这样做有点没有意义,因为当fadeItInDoom 函数进来时,setTimeout 已经过去了。我的假设是否正确?还是我没有得到的 setTimeout 发生了其他事情?