File tree 2 files changed +10
-10
lines changed
2 files changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -76,15 +76,15 @@ plots.redrawText = function(gd) {
76
76
plots . resize = function ( gd ) {
77
77
gd = Lib . getGraphDiv ( gd ) ;
78
78
79
- return new Promise ( function ( resolve , reject ) {
79
+ var resolveLastResize ;
80
+ var p = new Promise ( function ( resolve , reject ) {
80
81
if ( ! gd || Lib . isHidden ( gd ) ) {
81
82
reject ( new Error ( 'Resize must be passed a displayed plot div element.' ) ) ;
82
83
}
83
84
84
- if ( gd . _rejectResize ) gd . _rejectResize ( ) ;
85
- gd . _rejectResize = reject ;
86
-
87
85
if ( gd . _redrawTimer ) clearTimeout ( gd . _redrawTimer ) ;
86
+ if ( gd . _resolveResize ) resolveLastResize = gd . _resolveResize ;
87
+ gd . _resolveResize = resolve ;
88
88
89
89
gd . _redrawTimer = setTimeout ( function ( ) {
90
90
// return if there is nothing to resize or is hidden
@@ -108,6 +108,9 @@ plots.resize = function(gd) {
108
108
} ) ;
109
109
} , 100 ) ;
110
110
} ) ;
111
+
112
+ if ( resolveLastResize ) resolveLastResize ( p ) ;
113
+ return p ;
111
114
} ;
112
115
113
116
Original file line number Diff line number Diff line change @@ -416,16 +416,13 @@ describe('Test Plots', function() {
416
416
describe ( 'returns Promises' , function ( ) {
417
417
afterEach ( destroyGraphDiv ) ;
418
418
419
- it ( 'should reject or resolve them all' , function ( done ) {
419
+ it ( 'should resolve them all' , function ( done ) {
420
420
gd = createGraphDiv ( ) ;
421
421
var p = [ ] ;
422
422
Plotly . newPlot ( gd , [ { y : [ 5 , 2 , 5 ] } ] )
423
423
. 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 ) ) ;
429
426
p . push ( Plotly . Plots . resize ( gd ) ) ;
430
427
return Promise . all ( p ) ;
431
428
} )
You can’t perform that action at this time.
0 commit comments