@@ -169,7 +169,7 @@ function drawHeader(gd, gHeader, gButton, menuOpts) {
169
169
170
170
var active = menuOpts . active ,
171
171
headerOpts = menuOpts . buttons [ active ] || constants . blankHeaderOpts ,
172
- posOpts = { y : 0 , yPad : 0 , x : 0 , xPad : 0 , index : 0 } ,
172
+ posOpts = { y : menuOpts . pad . t , yPad : 0 , x : menuOpts . pad . l , xPad : 0 , index : 0 } ,
173
173
positionOverrides = {
174
174
width : menuOpts . headerWidth ,
175
175
height : menuOpts . headerHeight
@@ -191,8 +191,8 @@ function drawHeader(gd, gHeader, gButton, menuOpts) {
191
191
. text ( '▼' ) ;
192
192
193
193
arrow . attr ( {
194
- x : menuOpts . headerWidth - constants . arrowOffsetX ,
195
- y : menuOpts . headerHeight / 2 + constants . textOffsetY
194
+ x : menuOpts . headerWidth - constants . arrowOffsetX + menuOpts . pad . l ,
195
+ y : menuOpts . headerHeight / 2 + constants . textOffsetY + menuOpts . pad . t
196
196
} ) ;
197
197
198
198
header . on ( 'click' , function ( ) {
@@ -275,8 +275,8 @@ function drawButtons(gd, gHeader, gButton, menuOpts) {
275
275
}
276
276
277
277
var posOpts = {
278
- x : x0 ,
279
- y : y0 ,
278
+ x : x0 + menuOpts . pad . l ,
279
+ y : y0 + menuOpts . pad . t ,
280
280
yPad : constants . gapButton ,
281
281
xPad : constants . gapButton ,
282
282
index : 0 ,
@@ -468,27 +468,30 @@ function findDimenstions(gd, menuOpts) {
468
468
469
469
fakeButtons . remove ( ) ;
470
470
471
+ var paddedWidth = menuOpts . totalWidth + menuOpts . pad . l + menuOpts . pad . r ;
472
+ var paddedHeight = menuOpts . totalHeight + menuOpts . pad . t + menuOpts . pad . b ;
473
+
471
474
var graphSize = gd . _fullLayout . _size ;
472
475
menuOpts . lx = graphSize . l + graphSize . w * menuOpts . x ;
473
476
menuOpts . ly = graphSize . t + graphSize . h * ( 1 - menuOpts . y ) ;
474
477
475
478
var xanchor = 'left' ;
476
479
if ( anchorUtils . isRightAnchor ( menuOpts ) ) {
477
- menuOpts . lx -= menuOpts . totalWidth ;
480
+ menuOpts . lx -= paddedWidth ;
478
481
xanchor = 'right' ;
479
482
}
480
483
if ( anchorUtils . isCenterAnchor ( menuOpts ) ) {
481
- menuOpts . lx -= menuOpts . totalWidth / 2 ;
484
+ menuOpts . lx -= paddedWidth / 2 ;
482
485
xanchor = 'center' ;
483
486
}
484
487
485
488
var yanchor = 'top' ;
486
489
if ( anchorUtils . isBottomAnchor ( menuOpts ) ) {
487
- menuOpts . ly -= menuOpts . totalHeight ;
490
+ menuOpts . ly -= paddedHeight ;
488
491
yanchor = 'bottom' ;
489
492
}
490
493
if ( anchorUtils . isMiddleAnchor ( menuOpts ) ) {
491
- menuOpts . ly -= menuOpts . totalHeight / 2 ;
494
+ menuOpts . ly -= paddedHeight / 2 ;
492
495
yanchor = 'middle' ;
493
496
}
494
497
@@ -500,10 +503,10 @@ function findDimenstions(gd, menuOpts) {
500
503
Plots . autoMargin ( gd , constants . autoMarginIdRoot + menuOpts . _index , {
501
504
x : menuOpts . x ,
502
505
y : menuOpts . y ,
503
- l : menuOpts . totalWidth * ( { right : 1 , center : 0.5 } [ xanchor ] || 0 ) ,
504
- r : menuOpts . totalWidth * ( { left : 1 , center : 0.5 } [ xanchor ] || 0 ) ,
505
- b : menuOpts . totalHeight * ( { top : 1 , middle : 0.5 } [ yanchor ] || 0 ) ,
506
- t : menuOpts . totalHeight * ( { bottom : 1 , middle : 0.5 } [ yanchor ] || 0 )
506
+ l : paddedWidth * ( { right : 1 , center : 0.5 } [ xanchor ] || 0 ) ,
507
+ r : paddedWidth * ( { left : 1 , center : 0.5 } [ xanchor ] || 0 ) ,
508
+ b : paddedHeight * ( { top : 1 , middle : 0.5 } [ yanchor ] || 0 ) ,
509
+ t : paddedHeight * ( { bottom : 1 , middle : 0.5 } [ yanchor ] || 0 )
507
510
} ) ;
508
511
}
509
512
0 commit comments