Skip to content

Commit

Permalink
limit to when container size shrinks, verbose comment
Browse files Browse the repository at this point in the history
  • Loading branch information
kurkle committed Jan 26, 2019
1 parent fe90e53 commit 840d11a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/platforms/platform.dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,14 @@ function addResizeListener(node, listener, chart) {
var container = chart.options.maintainAspectRatio && node.parentNode;
var w = container ? container.clientWidth : 0;
listener(createEvent('resize', chart));
if (container && container.clientWidth !== 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
if (container && container.clientWidth < w && chart.canvas) {
// If the container size shrank during chart resize, let's assume
// scrollbar appeared. So we resize again with the scrollbar visible -
// effectively making chart smaller and the scrollbar hidden again.
// Because we are inside `throttled`, and currently `ticking`, scroll
// events are ignored during this whole 2 resize process.
// If we assumed wrong and something else happened, we are resizing
// twice in a frame (potential performance issue)
listener(createEvent('resize', chart));
}
}
Expand Down

0 comments on commit 840d11a

Please sign in to comment.