-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
responsive handler: do not resize if gd is hidden #3972
Conversation
src/plot_api/plot_api.js
Outdated
function isHidden(gd) { | ||
var display = window.getComputedStyle(gd).display; | ||
return !display || display === 'none'; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this the same helpers as in Plots.resize
?
Can we make this a Lib
function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good idea!
Done in 913bb68
src/plot_api/plot_api.js
Outdated
// make the figure responsive | ||
if(gd._context.responsive) { | ||
if(!gd._responsiveChartHandler) { | ||
// Keep a reference to the resize handler to purge it down the road | ||
gd._responsiveChartHandler = function() { Plots.resize(gd); }; | ||
gd._responsiveChartHandler = function() { if(!isHidden(gd)) Plots.resize(gd).catch(Lib.noop); }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need to .catch
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking this on @antoinerg ! Pinning this for |
thanks again for doing this @antoinerg 💃 |
(let's start merging things for 1.49.0) |
Fixes #3866 using approach number 2 from comment #3866 (comment)