diff --git a/test/fixtures/controller.polarArea/polar-area-animation-rotate.js b/test/fixtures/controller.polarArea/polar-area-animation-rotate.js index 3c01b4c83..9f17d3fd7 100644 --- a/test/fixtures/controller.polarArea/polar-area-animation-rotate.js +++ b/test/fixtures/controller.polarArea/polar-area-animation-rotate.js @@ -31,7 +31,7 @@ module.exports = { animation: { animateRotate: true, animateScale: false, - duration: 800, + duration: 8000, easing: 'linear' }, responsive: false, @@ -57,19 +57,29 @@ module.exports = { }, run: function(chart) { const animator = Chart.animator; - const start = animator._getAnims(chart).items[0]._start; - animator._running = false; - return new Promise((resolve) => setTimeout(() => { - for (let i = 0; i < 16; i++) { - animator._update(start + i * 50); - let x = i % 4 * 128; - let y = Math.floor(i / 4) * 128; - ctx.drawImage(chart.canvas, x, y, 128, 128); - } - Chart.helpers.clearCanvas(chart.canvas); - chart.ctx.drawImage(canvas, 0, 0); - resolve(); - }, 100)); + const anims = animator._getAnims(chart); + // disable animator + const backup = animator._refresh; + animator._refresh = function() { }; + + return new Promise((resolve) => { + window.requestAnimationFrame(() => { + + const start = anims.items[0]._start; + for (let i = 0; i < 16; i++) { + animator._update(start + i * 500); + let x = i % 4 * 128; + let y = Math.floor(i / 4) * 128; + ctx.drawImage(chart.canvas, x, y, 128, 128); + } + + Chart.helpers.clearCanvas(chart.canvas); + chart.ctx.drawImage(canvas, 0, 0); + + animator._refresh = backup; + resolve(); + }); + }); } } }; diff --git a/test/fixtures/controller.polarArea/polar-area-animation-scale.js b/test/fixtures/controller.polarArea/polar-area-animation-scale.js index 4e7c2aad7..e4a1fe717 100644 --- a/test/fixtures/controller.polarArea/polar-area-animation-scale.js +++ b/test/fixtures/controller.polarArea/polar-area-animation-scale.js @@ -31,7 +31,7 @@ module.exports = { animation: { animateRotate: false, animateScale: true, - duration: 800, + duration: 8000, easing: 'linear' }, responsive: false, @@ -57,19 +57,28 @@ module.exports = { }, run: function(chart) { const animator = Chart.animator; - const start = animator._getAnims(chart).items[0]._start; - animator._running = false; - return new Promise((resolve) => setTimeout(() => { - for (let i = 0; i < 16; i++) { - animator._update(start + i * 50); - let x = i % 4 * 128; - let y = Math.floor(i / 4) * 128; - ctx.drawImage(chart.canvas, x, y, 128, 128); - } - Chart.helpers.clearCanvas(chart.canvas); - chart.ctx.drawImage(canvas, 0, 0); - resolve(); - }, 100)); + const anims = animator._getAnims(chart); + // disable animator + const backup = animator._refresh; + animator._refresh = function() { }; + + return new Promise((resolve) => { + window.requestAnimationFrame(() => { + + const start = anims.items[0]._start; + for (let i = 0; i < 16; i++) { + animator._update(start + i * 500); + let x = i % 4 * 128; + let y = Math.floor(i / 4) * 128; + ctx.drawImage(chart.canvas, x, y, 128, 128); + } + Chart.helpers.clearCanvas(chart.canvas); + chart.ctx.drawImage(canvas, 0, 0); + + animator._refresh = backup; + resolve(); + }); + }); } } };