[英]Javascript setInterval/setTimeout not working when browser tab not focused
So I'm modifying a Highcharts piechart trying to execute the following: 因此,我正在修改Highcharts饼图,以尝试执行以下操作:
function updateAngle( lastAngle ) {
if ($("#container").highcharts() != null && $("#container").highcharts() != undefined) {
var currentAngle = lastAngle;
var destinationAngle = getAngle();
if (currentAngle != destinationAngle) {
currentAngle += 1;
if (currentAngle > destinationAngle) {
currentAngle = destinationAngle;
}
$("#container").highcharts().get('Series').update({
endAngle: currentAngle
});
setTimeout(updateAngle, 1, currentAngle);
}
}
}
After each interation I'm adding 1 to the previous angle, now I've read that setInterval/setTimeout doesn't work with browsers when tabbed out due to it not requesting animation. 每次交互后,我都将1加到前一个角度,现在我读到setInterval / setTimeout在跳出时不支持浏览器,因为它不请求动画。 I've read that ".queue" is a function that can work for me, but I'm unsure how to convert my setTimeout method to using .queue.
我已经读过“ .queue”是一个可以为我工作的函数,但是我不确定如何将setTimeout方法转换为使用.queue。
Timeouts are clamped to firing no more often than once per second (1000 ms) in inactive tabs, but they still fire. 在不活动的标签页中,超时的触发频率不超过每秒触发一次(1000 ms),但仍会触发。 You won't have any issue with your code.
您的代码不会有任何问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.