Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent infinite resize when vertical scrollbar appears #6011

Merged
merged 5 commits into from Jan 30, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/core/core.controller.js
Expand Up @@ -213,13 +213,13 @@ helpers.extend(Chart.prototype, /** @lends Chart */ {
plugins.notify(me, 'resize', [newSize]);

// Notify of resize
if (me.options.onResize) {
kurkle marked this conversation as resolved.
Show resolved Hide resolved
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
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] || {};
kurkle marked this conversation as resolved.
Show resolved Hide resolved

// 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;
kurkle marked this conversation as resolved.
Show resolved Hide resolved
var container = aspectRatio && node.parentNode;
var w = container ? container.clientWidth : 0;
var ret = listener(createEvent('resize', chart));
kurkle marked this conversation as resolved.
Show resolved Hide resolved
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