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
Next Next commit
Plots.resize returns a Promise
As the resize operation will modify the size of the plot only after a
timeout, if you call resize and then immediately do something based on
the current plot size, you'll get the "old" size. This fixes it.
  • Loading branch information
Alessandro Burato committed Feb 12, 2016
commit fdb0a2a0830370533684cebbba4a733e8dd768fe
30 changes: 17 additions & 13 deletions src/plots/plots.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,23 +232,27 @@ plots.redrawText = function(gd) {
};

// resize plot about the container size
plots.resize = function(gd) {
if(!gd || d3.select(gd).style('display') === 'none') return;
plots.resize = function (gd) {
if (!gd || d3.select(gd).style('display') === 'none') return;

if(gd._redrawTimer) clearTimeout(gd._redrawTimer);
return new Promise(function (resolve) {

if (gd._redrawTimer) clearTimeout(gd._redrawTimer);

gd._redrawTimer = setTimeout(function() {
if((gd._fullLayout || {}).autosize) {
// autosizing doesn't count as a change that needs saving
var oldchanged = gd.changed;
gd._redrawTimer = setTimeout(function () {
if ((gd._fullLayout || {}).autosize) {
// autosizing doesn't count as a change that needs saving
var oldchanged = gd.changed;

// nor should it be included in the undo queue
gd.autoplay = true;
// nor should it be included in the undo queue
gd.autoplay = true;

Plotly.relayout(gd, {autosize: true});
gd.changed = oldchanged;
}
}, 100);
Plotly.relayout(gd, { autosize: true });
gd.changed = oldchanged;
resolve();
}
}, 100);
});
};


Expand Down