File tree Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Expand file tree Collapse file tree 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) {
7676plots . 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
Original file line number Diff line number Diff 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 } )
You can’t perform that action at this time.
0 commit comments