Skip to content
Merged
Changes from 1 commit
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
11 changes: 4 additions & 7 deletions src/platforms/platform.dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,10 @@ function addResizeListener(node, listener, chart) {
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));
}
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
ret = listener(createEvent('resize', chart));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious how the 2nd resize doesn't cause the scrollbar to go away

Copy link
Member Author

@kurkle kurkle Jan 24, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I think happens: We are doing the resize in a onScroll event. We resize, notice it made scrollbars visible and resize again. Scrollbars are hidden in the end of this scroll event. And I suppose browsers won't fire another scroll until the previous is done.
And throttled() prevents multiple onScroll's in same frame.

Initially I was storing the width, but accidentally found out, it was not really needed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, that's a good find. If throttled() can prevent the double event then I'm ok with testing this out further

}
return ret;
}
Expand Down