Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/core/core.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,13 @@ helpers.extend(Chart.prototype, /** @lends Chart */ {
plugins.notify(me, 'resize', [newSize]);

// Notify of resize
if (me.options.onResize) {
me.options.onResize(me, newSize);
if (options.onResize) {
options.onResize(me, newSize);
}

me.stop();
me.update({
duration: me.options.responsiveAnimationDuration
duration: options.responsiveAnimationDuration
});
}
},
Expand Down
16 changes: 14 additions & 2 deletions src/platforms/platform.dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,24 @@ function unwatchForRender(node) {
}

function addResizeListener(node, listener, chart) {
var expando = node[EXPANDO_KEY] || (node[EXPANDO_KEY] = {});
var expando = node[EXPANDO_KEY] = node[EXPANDO_KEY] || {};

// Let's keep track of this added resizer and thus avoid DOM query when removing it.
var resizer = expando.resizer = createResizer(throttled(function() {
if (expando.resizer) {
return listener(createEvent('resize', chart));
var aspectRatio = chart.options.maintainAspectRatio && chart.aspectRatio || null;
var container = aspectRatio && node.parentNode;
var w = container ? container.clientWidth : 0;
var ret = listener(createEvent('resize', chart));
if (container) {
expando._width = container.clientWidth;
if (expando._width !== w && chart.canvas) {
// If the container size changed during chart resize, we can assume scrollbar appeared.
// So let's resize again, with the scrollbar visible
ret = listener(createEvent('resize', chart));
}
}
return ret;
}
}));

Expand Down