@@ -256,20 +256,22 @@ function drawButtons(gd, gHeader, gButton, menuOpts) {
256256 var x0 = 0 ;
257257 var y0 = 0 ;
258258
259+ var isVertical = [ 'up' , 'down' ] . indexOf ( menuOpts . direction ) !== - 1 ;
260+
259261 if ( menuOpts . type === 'dropdown' ) {
260- if ( menuOpts . orientation === 'v' ) {
262+ if ( isVertical ) {
261263 y0 = menuOpts . headerHeight + constants . gapButtonHeader ;
262264 } else {
263265 x0 = menuOpts . headerWidth + constants . gapButtonHeader ;
264266 }
265267 }
266268
267- if ( menuOpts . type === 'dropdown' && menuOpts . openreverse ) {
268- if ( menuOpts . orientation === 'v' ) {
269- y0 = - constants . gapButtonHeader + constants . gapButton - menuOpts . openHeight ;
270- } else {
271- x0 = - constants . gapButtonHeader + constants . gapButton - menuOpts . openWidth ;
272- }
269+ if ( menuOpts . type === 'dropdown' && menuOpts . direction === 'up' ) {
270+ y0 = - constants . gapButtonHeader + constants . gapButton - menuOpts . openHeight ;
271+ }
272+
273+ if ( menuOpts . type === 'dropdown' && menuOpts . direction === 'left' ) {
274+ x0 = - constants . gapButtonHeader + constants . gapButton - menuOpts . openWidth ;
273275 }
274276
275277 var posOpts = {
@@ -399,6 +401,8 @@ function findDimenstions(gd, menuOpts) {
399401 fakeButtons . enter ( ) . append ( 'g' )
400402 . classed ( constants . dropdownButtonClassName , true ) ;
401403
404+ var isVertical = [ 'up' , 'down' ] . indexOf ( menuOpts . direction ) !== - 1 ;
405+
402406 // loop over fake buttons to find width / height
403407 fakeButtons . each ( function ( buttonOpts , i ) {
404408 var button = d3 . select ( this ) ;
@@ -429,7 +433,7 @@ function findDimenstions(gd, menuOpts) {
429433 menuOpts . height1 = Math . max ( menuOpts . height1 , hEff ) ;
430434 menuOpts . width1 = Math . max ( menuOpts . width1 , wEff ) ;
431435
432- if ( menuOpts . orientation === 'v' ) {
436+ if ( isVertical ) {
433437 menuOpts . totalWidth = Math . max ( menuOpts . totalWidth , wEff ) ;
434438 menuOpts . openWidth = menuOpts . totalWidth ;
435439 menuOpts . totalHeight += hEff + constants . gapButton ;
@@ -442,7 +446,7 @@ function findDimenstions(gd, menuOpts) {
442446 }
443447 } ) ;
444448
445- if ( menuOpts . orientation === 'v' ) {
449+ if ( isVertical ) {
446450 menuOpts . totalHeight -= constants . gapButton ;
447451 } else {
448452 menuOpts . totalWidth -= constants . gapButton ;
@@ -453,7 +457,7 @@ function findDimenstions(gd, menuOpts) {
453457 menuOpts . headerHeight = menuOpts . height1 ;
454458
455459 if ( menuOpts . type === 'dropdown' ) {
456- if ( menuOpts . orientation === 'v' ) {
460+ if ( isVertical ) {
457461 menuOpts . width1 += constants . arrowPadX ;
458462 menuOpts . totalHeight = menuOpts . height1 ;
459463 } else {
@@ -514,11 +518,13 @@ function setItemPosition(item, menuOpts, posOpts, overrideOpts) {
514518
515519 Lib . setTranslate ( item , borderWidth + posOpts . x , borderWidth + posOpts . y ) ;
516520
521+ var isVertical = [ 'up' , 'down' ] . indexOf ( menuOpts . direction ) !== - 1 ;
522+
517523 rect . attr ( {
518524 x : 0 ,
519525 y : 0 ,
520- width : overrideOpts . width || ( menuOpts . orientation === 'v' ? menuOpts . width1 : menuOpts . widths [ index ] ) ,
521- height : overrideOpts . height || ( menuOpts . orientation === 'v' ? menuOpts . heights [ index ] : menuOpts . height1 )
526+ width : overrideOpts . width || ( isVertical ? menuOpts . width1 : menuOpts . widths [ index ] ) ,
527+ height : overrideOpts . height || ( isVertical ? menuOpts . heights [ index ] : menuOpts . height1 )
522528 } ) ;
523529
524530 var tHeight = menuOpts . font . size * constants . fontSizeToHeight ,
@@ -533,7 +539,7 @@ function setItemPosition(item, menuOpts, posOpts, overrideOpts) {
533539 text . attr ( textAttrs ) ;
534540 tspans . attr ( textAttrs ) ;
535541
536- if ( menuOpts . orientation === 'v' ) {
542+ if ( isVertical ) {
537543 posOpts . y += menuOpts . heights [ index ] + posOpts . yPad ;
538544 } else {
539545 posOpts . x += menuOpts . widths [ index ] + posOpts . xPad ;
0 commit comments