Skip to content

Commit

Permalink
Update doughnut animation fixture (#8457)
Browse files Browse the repository at this point in the history
  • Loading branch information
kurkle authored Feb 18, 2021
1 parent e6742e3 commit e8f9542
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions test/fixtures/controller.doughnut/doughnut-animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = {
},
options: {
animation: {
duration: 800,
duration: 8000,
easing: 'linear'
},
responsive: false,
Expand All @@ -54,19 +54,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();
});
});
}
}
};

0 comments on commit e8f9542

Please sign in to comment.