@@ -88,13 +88,26 @@ plots.resize = function(gd) {
88
88
89
89
gd . _redrawTimer = setTimeout ( function ( ) {
90
90
// return if there is nothing to resize or is hidden
91
- if ( ! gd . layout || ( gd . layout . width && gd . layout . height ) || Lib . isHidden ( gd ) ) {
91
+
92
+ if ( ! gd . layout || Lib . isHidden ( gd ) ) {
93
+ resolve ( gd ) ;
94
+ return ;
95
+ }
96
+
97
+ var initWidth = gd . layout . width || ( gd . _fullLayout . _template || { } ) . width ;
98
+ var initHeight = gd . layout . height || ( gd . _fullLayout . _template || { } ) . height ;
99
+
100
+ if ( initWidth && initHeight ) {
92
101
resolve ( gd ) ;
93
102
return ;
94
103
}
95
104
96
105
delete gd . layout . width ;
97
106
delete gd . layout . height ;
107
+ if ( gd . layout . template && gd . layout . template . layout ) {
108
+ delete gd . layout . template . layout . width ;
109
+ delete gd . layout . template . layout . height ;
110
+ }
98
111
99
112
// autosizing doesn't count as a change that needs saving
100
113
var oldchanged = gd . changed ;
@@ -1490,9 +1503,9 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut, formatObj) {
1490
1503
// to pass through the autosize routine
1491
1504
//
1492
1505
// This behavior is subject to change in v2.
1493
- var hasWidth = ! ! ( layoutIn . width || ( layoutOut . _template || { } ) . width ) ;
1494
- var hasHeight = ! ! ( layoutIn . height || ( layoutOut . _template || { } ) . height ) ;
1495
- coerce ( 'autosize' , ! ( hasWidth && hasHeight ) ) ;
1506
+ var initWidth = layoutIn . width || ( layoutOut . _template || { } ) . width ;
1507
+ var initHeight = layoutIn . height || ( layoutOut . _template || { } ) . height ;
1508
+ coerce ( 'autosize' , ! ( initWidth && initHeight ) ) ;
1496
1509
1497
1510
coerce ( 'width' ) ;
1498
1511
coerce ( 'height' ) ;
@@ -1503,7 +1516,7 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut, formatObj) {
1503
1516
coerce ( 'margin.pad' ) ;
1504
1517
coerce ( 'margin.autoexpand' ) ;
1505
1518
1506
- if ( hasWidth && hasHeight ) plots . sanitizeMargins ( layoutOut ) ;
1519
+ if ( initWidth && initHeight ) plots . sanitizeMargins ( layoutOut ) ;
1507
1520
1508
1521
Registry . getComponentMethod ( 'grid' , 'sizeDefaults' ) ( layoutIn , layoutOut ) ;
1509
1522
@@ -1587,9 +1600,12 @@ plots.plotAutoSize = function plotAutoSize(gd, layout, fullLayout) {
1587
1600
if ( newWidth < minWidth ) newWidth = minWidth ;
1588
1601
if ( newHeight < minHeight ) newHeight = minHeight ;
1589
1602
1590
- var widthHasChanged = ! layout . width &&
1603
+ var initWidth = layout . width || ( fullLayout . _template || { } ) . width ;
1604
+ var initHeight = layout . height || ( fullLayout . _template || { } ) . height ;
1605
+
1606
+ var widthHasChanged = ! initWidth &&
1591
1607
( Math . abs ( fullLayout . width - newWidth ) > 1 ) ;
1592
- var heightHasChanged = ! layout . height &&
1608
+ var heightHasChanged = ! initHeight &&
1593
1609
( Math . abs ( fullLayout . height - newHeight ) > 1 ) ;
1594
1610
1595
1611
if ( heightHasChanged || widthHasChanged ) {
0 commit comments