Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8b6344b

Browse filesBrowse files
committed
Merge pull request plotly#253 from aburato/promise-from-resize
Plots.resize returns a Promise
2 parents 34438d7 + c336dae commit 8b6344b
Copy full SHA for 8b6344b

File tree

1 file changed

+16
-12
lines changed
Filter options

1 file changed

+16
-12
lines changed

‎src/plots/plots.js

Copy file name to clipboardExpand all lines: src/plots/plots.js
+16-12Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -233,22 +233,26 @@ plots.redrawText = function(gd) {
233233

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

238-
if(gd._redrawTimer) clearTimeout(gd._redrawTimer);
238+
return new Promise(function(resolve) {
239239

240-
gd._redrawTimer = setTimeout(function() {
241-
if((gd._fullLayout || {}).autosize) {
242-
// autosizing doesn't count as a change that needs saving
243-
var oldchanged = gd.changed;
240+
if (gd._redrawTimer) clearTimeout(gd._redrawTimer);
244241

245-
// nor should it be included in the undo queue
246-
gd.autoplay = true;
242+
gd._redrawTimer = setTimeout(function() {
243+
if ((gd._fullLayout || {}).autosize) {
244+
// autosizing doesn't count as a change that needs saving
245+
var oldchanged = gd.changed;
247246

248-
Plotly.relayout(gd, {autosize: true});
249-
gd.changed = oldchanged;
250-
}
251-
}, 100);
247+
// nor should it be included in the undo queue
248+
gd.autoplay = true;
249+
250+
Plotly.relayout(gd, { autosize: true });
251+
gd.changed = oldchanged;
252+
resolve();
253+
}
254+
}, 100);
255+
});
252256
};
253257

254258

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.