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 040d6ac

Browse filesBrowse files
committed
Plots.resize: resolve old promises
1 parent deb32ff commit 040d6ac
Copy full SHA for 040d6ac

File tree

Expand file treeCollapse file tree

2 files changed

+10
-10
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+10
-10
lines changed

‎src/plots/plots.js

Copy file name to clipboardExpand all lines: src/plots/plots.js
+7-4Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@ plots.redrawText = function(gd) {
7676
plots.resize = function(gd) {
7777
gd = Lib.getGraphDiv(gd);
7878

79-
return new Promise(function(resolve, reject) {
79+
var resolveLastResize;
80+
var p = new Promise(function(resolve, reject) {
8081
if(!gd || Lib.isHidden(gd)) {
8182
reject(new Error('Resize must be passed a displayed plot div element.'));
8283
}
8384

84-
if(gd._rejectResize) gd._rejectResize();
85-
gd._rejectResize = reject;
86-
8785
if(gd._redrawTimer) clearTimeout(gd._redrawTimer);
86+
if(gd._resolveResize) resolveLastResize = gd._resolveResize;
87+
gd._resolveResize = resolve;
8888

8989
gd._redrawTimer = setTimeout(function() {
9090
// return if there is nothing to resize or is hidden
@@ -108,6 +108,9 @@ plots.resize = function(gd) {
108108
});
109109
}, 100);
110110
});
111+
112+
if(resolveLastResize) resolveLastResize(p);
113+
return p;
111114
};
112115

113116

‎test/jasmine/tests/plots_test.js

Copy file name to clipboardExpand all lines: test/jasmine/tests/plots_test.js
+3-6Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -416,16 +416,13 @@ describe('Test Plots', function() {
416416
describe('returns Promises', function() {
417417
afterEach(destroyGraphDiv);
418418

419-
it('should reject or resolve them all', function(done) {
419+
it('should resolve them all', function(done) {
420420
gd = createGraphDiv();
421421
var p = [];
422422
Plotly.newPlot(gd, [{y: [5, 2, 5]}])
423423
.then(function() {
424-
// First call should get rejected
425-
p.push(Plotly.Plots.resize(gd).catch(function() {
426-
return Promise.resolve(true);
427-
}));
428-
// because we call the function again within 100ms
424+
p.push(Plotly.Plots.resize(gd));
425+
p.push(Plotly.Plots.resize(gd));
429426
p.push(Plotly.Plots.resize(gd));
430427
return Promise.all(p);
431428
})

0 commit comments

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