From 4fa2c408f02c723bd7389a705d9aebd42429f8da Mon Sep 17 00:00:00 2001 From: Jukka Kurkela Date: Fri, 4 Sep 2020 23:46:44 +0300 Subject: [PATCH] Remove duplicate code, clearer parameter names (#7756) --- src/core/core.controller.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/core/core.controller.js b/src/core/core.controller.js index 1bd8d39de..58b810b3f 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -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}); } } -- 2.47.2