From: Evert Timberg Date: Mon, 12 Oct 2015 13:16:49 +0000 (-0400) Subject: Fix a race condition in the resize listener & use the correct merged config object... X-Git-Tag: 2.0.0-beta~11^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1232ca53f00bb5f634bcce23b7e899584edd9e0d;p=thirdparty%2FChart.js.git Fix a race condition in the resize listener & use the correct merged config object for the responsive setting --- 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; };