From 840d11a8d32260849f9ff3ad0b4f775eda99e9c2 Mon Sep 17 00:00:00 2001 From: Jukka Kurkela Date: Sat, 26 Jan 2019 11:15:10 +0200 Subject: [PATCH] limit to when container size shrinks, verbose comment --- src/platforms/platform.dom.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/platforms/platform.dom.js b/src/platforms/platform.dom.js index 55792de8857..01a46174d7f 100644 --- a/src/platforms/platform.dom.js +++ b/src/platforms/platform.dom.js @@ -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)); } }