1
所以我修改Highcharts餅圖試圖執行以下操作:的JavaScript的setInterval/setTimeout的不工作時,瀏覽器選項卡不集中
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);
}
}
}
每個互爲作用我加入1至先前的角度之後,現在我讀過setInterval/setTimeout,因爲它沒有請求動畫,所以在標籤輸出時不能與瀏覽器一起工作。我讀過「.queue」是一個可以爲我工作的函數,但我不確定如何將setTimeout方法轉換爲使用.queue。
但是,每1000毫秒一次就是減速,因爲這顯示的數據可能在重新聚焦後不再需要顯示。 – user1977351
在標籤之間切換時,可以調用clearInterval()來重置setInterval。重點時,創建新的setInterval()。 –