mirror of
https://github.com/chartjs/Chart.js.git
synced 2024-10-07 04:39:06 +02:00
Fix a race condition in the resize listener & use the correct merged config object for the responsive setting
This commit is contained in:
parent
81095e777a
commit
1232ca53f0
@ -58,19 +58,18 @@
|
|||||||
Chart.helpers.retinaScale(this);
|
Chart.helpers.retinaScale(this);
|
||||||
|
|
||||||
// Always bind this so that if the responsive state changes we still work
|
// Always bind this so that if the responsive state changes we still work
|
||||||
|
if (config) {
|
||||||
|
this.controller = new Chart.Controller(this);
|
||||||
|
}
|
||||||
|
|
||||||
var _this = this;
|
var _this = this;
|
||||||
Chart.helpers.addResizeListener(context.canvas.parentNode, function() {
|
Chart.helpers.addResizeListener(context.canvas.parentNode, function() {
|
||||||
if (config.options.responsive) {
|
if (_this.controller && _this.controller.config.options.responsive) {
|
||||||
_this.controller.resize();
|
_this.controller.resize();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (config) {
|
return this.controller ? this.controller : this;
|
||||||
this.controller = new Chart.Controller(this);
|
|
||||||
return this.controller;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user