Remove duplicate code, clearer parameter names (#7756)

This commit is contained in:
Jukka Kurkela
2020-09-04 23:46:44 +03:00
committed by GitHub
parent 18c003959d
commit 4fa2c408f0

View File

@@ -177,18 +177,18 @@ function compare2Level(l1, l2) {
};
}
function onAnimationsComplete(ctx) {
const chart = ctx.chart;
function onAnimationsComplete(context) {
const chart = context.chart;
const animationOptions = chart.options.animation;
chart._plugins.notify(chart, 'afterRender');
callCallback(animationOptions && animationOptions.onComplete, [ctx], chart);
callCallback(animationOptions && animationOptions.onComplete, [context], chart);
}
function onAnimationProgress(ctx) {
const chart = ctx.chart;
function onAnimationProgress(context) {
const chart = context.chart;
const animationOptions = chart.options.animation;
callCallback(animationOptions && animationOptions.onProgress, [ctx], chart);
callCallback(animationOptions && animationOptions.onProgress, [context], chart);
}
function isDomSupported() {
@@ -701,14 +701,9 @@ class Chart {
render() {
const me = this;
const animationOptions = me.options.animation;
if (me._plugins.notify(me, 'beforeRender') === false) {
return;
}
const onComplete = function() {
me._plugins.notify(me, 'afterRender');
callCallback(animationOptions && animationOptions.onComplete, [], me);
};
if (animator.has(me)) {
if (me.attached && !animator.running(me)) {
@@ -716,7 +711,7 @@ class Chart {
}
} else {
me.draw();
onComplete();
onAnimationsComplete({chart: me});
}
}