]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Do not notify plugins when a silent resize occurs (#3650)
authorEvert Timberg <evert.timberg+github@gmail.com>
Tue, 29 Nov 2016 09:43:52 +0000 (04:43 -0500)
committerSimon Brunel <simonbrunel@users.noreply.github.com>
Tue, 29 Nov 2016 09:43:52 +0000 (10:43 +0100)
Prevent the resize method from notifying plugins if it is a silent resize. A silent resize occurs during startup and we do not want plugins to do anything here because the chart is not set up.

src/core/core.controller.js

index ebbd081afa6c3380f01164fdebfa4084fc06c34b..1abc81075dadcc54f4c28014054c3d914ff64878 100644 (file)
@@ -312,16 +312,16 @@ module.exports = function(Chart) {
 
                        helpers.retinaScale(chart);
 
-                       // Notify any plugins about the resize
-                       var newSize = {width: newWidth, height: newHeight};
-                       Chart.plugins.notify('resize', [me, newSize]);
+                       if (!silent) {
+                               // Notify any plugins about the resize
+                               var newSize = {width: newWidth, height: newHeight};
+                               Chart.plugins.notify('resize', [me, newSize]);
 
-                       // Notify of resize
-                       if (me.options.onResize) {
-                               me.options.onResize(me, newSize);
-                       }
+                               // Notify of resize
+                               if (me.options.onResize) {
+                                       me.options.onResize(me, newSize);
+                               }
 
-                       if (!silent) {
                                me.stop();
                                me.update(me.options.responsiveAnimationDuration);
                        }