@@ -169,7 +169,7 @@ function drawHeader(gd, gHeader, gButton, menuOpts) {
169169
170170 var active = menuOpts . active ,
171171 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 } ,
173173 positionOverrides = {
174174 width : menuOpts . headerWidth ,
175175 height : menuOpts . headerHeight
@@ -191,8 +191,8 @@ function drawHeader(gd, gHeader, gButton, menuOpts) {
191191 . text ( '▼' ) ;
192192
193193 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
196196 } ) ;
197197
198198 header . on ( 'click' , function ( ) {
@@ -275,8 +275,8 @@ function drawButtons(gd, gHeader, gButton, menuOpts) {
275275 }
276276
277277 var posOpts = {
278- x : x0 ,
279- y : y0 ,
278+ x : x0 + menuOpts . pad . l ,
279+ y : y0 + menuOpts . pad . t ,
280280 yPad : constants . gapButton ,
281281 xPad : constants . gapButton ,
282282 index : 0 ,
@@ -468,27 +468,30 @@ function findDimenstions(gd, menuOpts) {
468468
469469 fakeButtons . remove ( ) ;
470470
471+ var paddedWidth = menuOpts . totalWidth + menuOpts . pad . l + menuOpts . pad . r ;
472+ var paddedHeight = menuOpts . totalHeight + menuOpts . pad . t + menuOpts . pad . b ;
473+
471474 var graphSize = gd . _fullLayout . _size ;
472475 menuOpts . lx = graphSize . l + graphSize . w * menuOpts . x ;
473476 menuOpts . ly = graphSize . t + graphSize . h * ( 1 - menuOpts . y ) ;
474477
475478 var xanchor = 'left' ;
476479 if ( anchorUtils . isRightAnchor ( menuOpts ) ) {
477- menuOpts . lx -= menuOpts . totalWidth ;
480+ menuOpts . lx -= paddedWidth ;
478481 xanchor = 'right' ;
479482 }
480483 if ( anchorUtils . isCenterAnchor ( menuOpts ) ) {
481- menuOpts . lx -= menuOpts . totalWidth / 2 ;
484+ menuOpts . lx -= paddedWidth / 2 ;
482485 xanchor = 'center' ;
483486 }
484487
485488 var yanchor = 'top' ;
486489 if ( anchorUtils . isBottomAnchor ( menuOpts ) ) {
487- menuOpts . ly -= menuOpts . totalHeight ;
490+ menuOpts . ly -= paddedHeight ;
488491 yanchor = 'bottom' ;
489492 }
490493 if ( anchorUtils . isMiddleAnchor ( menuOpts ) ) {
491- menuOpts . ly -= menuOpts . totalHeight / 2 ;
494+ menuOpts . ly -= paddedHeight / 2 ;
492495 yanchor = 'middle' ;
493496 }
494497
@@ -500,10 +503,10 @@ function findDimenstions(gd, menuOpts) {
500503 Plots . autoMargin ( gd , constants . autoMarginIdRoot + menuOpts . _index , {
501504 x : menuOpts . x ,
502505 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 )
507510 } ) ;
508511}
509512
0 commit comments