]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Remove duplicate code, clearer parameter names (#7756)
authorJukka Kurkela <jukka.kurkela@gmail.com>
Fri, 4 Sep 2020 20:46:44 +0000 (23:46 +0300)
committerGitHub <noreply@github.com>
Fri, 4 Sep 2020 20:46:44 +0000 (16:46 -0400)
src/core/core.controller.js

index 1bd8d39de8164737cf4c283cc2a6fd194b62e5e8..58b810b3f7e6b0f957d4c91c2665d7a74d38f0b2 100644 (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});
                }
        }