From 1232ca53f00bb5f634bcce23b7e899584edd9e0d Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Mon, 12 Oct 2015 09:16:49 -0400 Subject: [PATCH 1/2] Fix a race condition in the resize listener & use the correct merged config object for the responsive setting --- src/core/core.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/core/core.js b/src/core/core.js index d930c024f..039f34419 100755 --- a/src/core/core.js +++ b/src/core/core.js @@ -58,19 +58,18 @@ Chart.helpers.retinaScale(this); // Always bind this so that if the responsive state changes we still work + if (config) { + this.controller = new Chart.Controller(this); + } + var _this = this; Chart.helpers.addResizeListener(context.canvas.parentNode, function() { - if (config.options.responsive) { + if (_this.controller && _this.controller.config.options.responsive) { _this.controller.resize(); } }); - if (config) { - this.controller = new Chart.Controller(this); - return this.controller; - } - - return this; + return this.controller ? this.controller : this; }; From 93ee8f85f66e3dcfc9b213ae9733ae12a513953e Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Mon, 12 Oct 2015 09:19:14 -0400 Subject: [PATCH 2/2] Put comment back in correct spot --- src/core/core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/core.js b/src/core/core.js index 039f34419..fb84f0e73 100755 --- a/src/core/core.js +++ b/src/core/core.js @@ -57,11 +57,11 @@ // High pixel density displays - multiply the size of the canvas height/width by the device pixel ratio, then scale. Chart.helpers.retinaScale(this); - // Always bind this so that if the responsive state changes we still work if (config) { this.controller = new Chart.Controller(this); } + // Always bind this so that if the responsive state changes we still work var _this = this; Chart.helpers.addResizeListener(context.canvas.parentNode, function() { if (_this.controller && _this.controller.config.options.responsive) {