]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Skip reset when animations are disabled (#8248)
authorJukka Kurkela <jukka.kurkela@gmail.com>
Tue, 29 Dec 2020 15:10:32 +0000 (17:10 +0200)
committerGitHub <noreply@github.com>
Tue, 29 Dec 2020 15:10:32 +0000 (10:10 -0500)
* Skip reset when animations are disabled
* Review update

src/core/core.controller.js
src/core/core.datasetController.js

index 6b9f95e316a891698ea249352f52fbb8d433bf5f..54ddd2f8d018520290cb8e5eb9de561e37666aa7 100644 (file)
@@ -453,7 +453,7 @@ class Chart {
 
                me.config.update(me.options);
                me.options = me.config.options;
-               me._animationsDisabled = !me.options.animation;
+               const animsDisabled = me._animationsDisabled = !me.options.animation;
 
                me.ensureScalesHaveIDs();
                me.buildOrUpdateScales();
@@ -476,10 +476,14 @@ class Chart {
 
                me._updateLayout();
 
-               // Can only reset the new controllers after the scales have been updated
-               each(newControllers, (controller) => {
-                       controller.reset();
-               });
+               // Only reset the controllers if we have animations
+               if (!animsDisabled) {
+                       // Can only reset the new controllers after the scales have been updated
+                       // Reset is done to get the starting point for the initial animation
+                       each(newControllers, (controller) => {
+                               controller.reset();
+                       });
+               }
 
                me._updateDatasets(mode);
 
index 4dbc92956a4060bed504131d2ecb5edfd19ed189..beb973a74dd55713ce43b94a29bcd85871b74f6e 100644 (file)
@@ -901,7 +901,7 @@ export default class DatasetController {
         * @protected
         */
        includeOptions(mode, sharedOptions) {
-               return !sharedOptions || isDirectUpdateMode(mode);
+               return !sharedOptions || isDirectUpdateMode(mode) || this.chart._animationsDisabled;
        }
 
        /**