@@ -256,20 +256,22 @@ function drawButtons(gd, gHeader, gButton, menuOpts) {
256
256
var x0 = 0 ;
257
257
var y0 = 0 ;
258
258
259
+ var isVertical = [ 'up' , 'down' ] . indexOf ( menuOpts . direction ) !== - 1 ;
260
+
259
261
if ( menuOpts . type === 'dropdown' ) {
260
- if ( menuOpts . orientation === 'v' ) {
262
+ if ( isVertical ) {
261
263
y0 = menuOpts . headerHeight + constants . gapButtonHeader ;
262
264
} else {
263
265
x0 = menuOpts . headerWidth + constants . gapButtonHeader ;
264
266
}
265
267
}
266
268
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 ;
273
275
}
274
276
275
277
var posOpts = {
@@ -399,6 +401,8 @@ function findDimenstions(gd, menuOpts) {
399
401
fakeButtons . enter ( ) . append ( 'g' )
400
402
. classed ( constants . dropdownButtonClassName , true ) ;
401
403
404
+ var isVertical = [ 'up' , 'down' ] . indexOf ( menuOpts . direction ) !== - 1 ;
405
+
402
406
// loop over fake buttons to find width / height
403
407
fakeButtons . each ( function ( buttonOpts , i ) {
404
408
var button = d3 . select ( this ) ;
@@ -429,7 +433,7 @@ function findDimenstions(gd, menuOpts) {
429
433
menuOpts . height1 = Math . max ( menuOpts . height1 , hEff ) ;
430
434
menuOpts . width1 = Math . max ( menuOpts . width1 , wEff ) ;
431
435
432
- if ( menuOpts . orientation === 'v' ) {
436
+ if ( isVertical ) {
433
437
menuOpts . totalWidth = Math . max ( menuOpts . totalWidth , wEff ) ;
434
438
menuOpts . openWidth = menuOpts . totalWidth ;
435
439
menuOpts . totalHeight += hEff + constants . gapButton ;
@@ -442,7 +446,7 @@ function findDimenstions(gd, menuOpts) {
442
446
}
443
447
} ) ;
444
448
445
- if ( menuOpts . orientation === 'v' ) {
449
+ if ( isVertical ) {
446
450
menuOpts . totalHeight -= constants . gapButton ;
447
451
} else {
448
452
menuOpts . totalWidth -= constants . gapButton ;
@@ -453,7 +457,7 @@ function findDimenstions(gd, menuOpts) {
453
457
menuOpts . headerHeight = menuOpts . height1 ;
454
458
455
459
if ( menuOpts . type === 'dropdown' ) {
456
- if ( menuOpts . orientation === 'v' ) {
460
+ if ( isVertical ) {
457
461
menuOpts . width1 += constants . arrowPadX ;
458
462
menuOpts . totalHeight = menuOpts . height1 ;
459
463
} else {
@@ -514,11 +518,13 @@ function setItemPosition(item, menuOpts, posOpts, overrideOpts) {
514
518
515
519
Lib . setTranslate ( item , borderWidth + posOpts . x , borderWidth + posOpts . y ) ;
516
520
521
+ var isVertical = [ 'up' , 'down' ] . indexOf ( menuOpts . direction ) !== - 1 ;
522
+
517
523
rect . attr ( {
518
524
x : 0 ,
519
525
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 )
522
528
} ) ;
523
529
524
530
var tHeight = menuOpts . font . size * constants . fontSizeToHeight ,
@@ -533,7 +539,7 @@ function setItemPosition(item, menuOpts, posOpts, overrideOpts) {
533
539
text . attr ( textAttrs ) ;
534
540
tspans . attr ( textAttrs ) ;
535
541
536
- if ( menuOpts . orientation === 'v' ) {
542
+ if ( isVertical ) {
537
543
posOpts . y += menuOpts . heights [ index ] + posOpts . yPad ;
538
544
} else {
539
545
posOpts . x += menuOpts . widths [ index ] + posOpts . xPad ;
0 commit comments