我遇到了 setInterval 和 jquery animate 的问题。这是我的代码:
function slides1() {
...
$("table#agah1").animate({
"left": first1
}, "slow");
$("table#agah2").animate({
"left": first2
}, "slow");
}
$(function () {
cyc = setInterval("slides1()", 3000);
});
当切换到另一个浏览器选项卡并在一段时间后返回时,动画会毫不拖延地继续执行,直到我离开该选项卡的时间,然后才能正确操作。我添加了这些也没有任何运气:
$(window).focus(function () {
jQuery.fx.off = false;
cyc = setInterval("slides1()", 3000);
});
$(window).blur(function () {
jQuery.fx.off = true;
window.clearInterval(cyc);
});