@@ -266,9 +266,9 @@ function drawButtons(gd, gHeader, gButton, menuOpts) {
266
266
267
267
if ( menuOpts . type === 'dropdown' && menuOpts . openreverse ) {
268
268
if ( menuOpts . orientation === 'v' ) {
269
- y0 = - 2 * constants . gapButtonHeader - constants . gapButton - menuOpts . totalHeight ;
269
+ y0 = - 2 * constants . gapButtonHeader - constants . gapButton - menuOpts . openHeight ;
270
270
} else {
271
- x0 = - 2 * constants . gapButtonHeader - constants . gapButton - menuOpts . totalWidth ;
271
+ x0 = - 2 * constants . gapButtonHeader - constants . gapButton - menuOpts . openWidth ;
272
272
}
273
273
}
274
274
@@ -384,14 +384,14 @@ function styleOnMouseOut(item, menuOpts) {
384
384
function findDimenstions ( gd , menuOpts ) {
385
385
var i ;
386
386
387
- menuOpts . width = 0 ;
388
387
menuOpts . width1 = 0 ;
389
- menuOpts . height = 0 ;
390
388
menuOpts . height1 = 0 ;
391
389
menuOpts . heights = [ ] ;
392
390
menuOpts . widths = [ ] ;
393
391
menuOpts . totalWidth = 0 ;
394
392
menuOpts . totalHeight = 0 ;
393
+ menuOpts . openWidth = 0 ;
394
+ menuOpts . openHeight = 0 ;
395
395
menuOpts . lx = 0 ;
396
396
menuOpts . ly = 0 ;
397
397
@@ -424,41 +424,32 @@ function findDimenstions(gd, menuOpts) {
424
424
menuOpts . widths [ i ] = wEff ;
425
425
menuOpts . heights [ i ] = hEff ;
426
426
427
- if ( menuOpts . orientation === 'v' | menuOpts . type === 'dropdown' ) {
428
- menuOpts . width = Math . max ( menuOpts . width , wEff ) ;
429
- } else {
430
- menuOpts . width += wEff ;
431
- }
432
427
// Height and width of individual element:
433
428
menuOpts . height1 = Math . max ( menuOpts . height1 , hEff ) ;
434
429
menuOpts . width1 = Math . max ( menuOpts . width1 , wEff ) ;
435
430
436
431
if ( menuOpts . orientation === 'v' ) {
437
432
menuOpts . totalWidth = Math . max ( menuOpts . totalWidth , wEff ) ;
433
+ menuOpts . openWidth = menuOpts . totalWidth ;
438
434
menuOpts . totalHeight += hEff ;
435
+ menuOpts . openHeight += hEff ;
439
436
} else {
440
437
menuOpts . totalWidth += wEff ;
441
- menuOpts . totalHeight += Math . max ( menuOpts . totalWidth , hEff ) ;
438
+ menuOpts . openWidth += wEff ;
439
+ menuOpts . totalHeight = Math . max ( menuOpts . totalHeight , hEff ) ;
440
+ menuOpts . openHeight = menuOpts . totalHeight ;
442
441
}
443
442
} ) ;
444
443
445
444
menuOpts . headerWidth = menuOpts . width1 + constants . arrowPadX ;
446
445
menuOpts . headerHeight = menuOpts . height1 ;
447
446
448
- if ( menuOpts . orientation === 'v' ) {
449
- menuOpts . width = menuOpts . width1 ;
450
-
451
- if ( menuOpts . type === 'dropdown' ) {
447
+ if ( menuOpts . type === 'dropdown' ) {
448
+ if ( menuOpts . orientation === 'v' ) {
452
449
menuOpts . width1 += constants . arrowPadX ;
453
- }
454
-
455
- for ( i = 0 ; i < menuOpts . heights ; i ++ ) {
456
- menuOpts . height += menuOpts . heights [ i ] ;
457
- }
458
- } else {
459
- menuOpts . height = menuOpts . height1 ;
460
- for ( i = 0 ; i < menuOpts . heights ; i ++ ) {
461
- menuOpts . width += menuOpts . width [ i ] ;
450
+ menuOpts . totalHeight = menuOpts . height1 ;
451
+ } else {
452
+ menuOpts . totalWidth = menuOpts . width1 ;
462
453
}
463
454
}
464
455
@@ -470,37 +461,39 @@ function findDimenstions(gd, menuOpts) {
470
461
471
462
var xanchor = 'left' ;
472
463
if ( anchorUtils . isRightAnchor ( menuOpts ) ) {
473
- menuOpts . lx -= menuOpts . width ;
464
+ menuOpts . lx -= menuOpts . totalWidth ;
474
465
xanchor = 'right' ;
475
466
}
476
467
if ( anchorUtils . isCenterAnchor ( menuOpts ) ) {
477
- menuOpts . lx -= menuOpts . width / 2 ;
468
+ menuOpts . lx -= menuOpts . totalWidth / 2 ;
478
469
xanchor = 'center' ;
479
470
}
480
471
481
472
var yanchor = 'top' ;
482
473
if ( anchorUtils . isBottomAnchor ( menuOpts ) ) {
483
- menuOpts . ly -= menuOpts . height ;
474
+ menuOpts . ly -= menuOpts . totalHeight ;
484
475
yanchor = 'bottom' ;
485
476
}
486
477
if ( anchorUtils . isMiddleAnchor ( menuOpts ) ) {
487
- menuOpts . ly -= menuOpts . height / 2 ;
478
+ menuOpts . ly -= menuOpts . totalHeight / 2 ;
488
479
yanchor = 'middle' ;
489
480
}
490
481
491
- menuOpts . width = Math . ceil ( menuOpts . width ) ;
492
- menuOpts . height = Math . ceil ( menuOpts . height ) ;
482
+ menuOpts . totalWidth = Math . ceil ( menuOpts . totalWidth ) ;
483
+ menuOpts . totalHeight = Math . ceil ( menuOpts . totalHeight ) ;
493
484
menuOpts . lx = Math . round ( menuOpts . lx ) ;
494
485
menuOpts . ly = Math . round ( menuOpts . ly ) ;
495
486
496
487
Plots . autoMargin ( gd , constants . autoMarginIdRoot + menuOpts . _index , {
497
488
x : menuOpts . x ,
498
489
y : menuOpts . y ,
499
- l : menuOpts . width * ( { right : 1 , center : 0.5 } [ xanchor ] || 0 ) ,
500
- r : menuOpts . width * ( { left : 1 , center : 0.5 } [ xanchor ] || 0 ) ,
501
- b : menuOpts . height * ( { top : 1 , middle : 0.5 } [ yanchor ] || 0 ) ,
502
- t : menuOpts . height * ( { bottom : 1 , middle : 0.5 } [ yanchor ] || 0 )
490
+ l : menuOpts . totalWidth * ( { right : 1 , center : 0.5 } [ xanchor ] || 0 ) ,
491
+ r : menuOpts . totalWidth * ( { left : 1 , center : 0.5 } [ xanchor ] || 0 ) ,
492
+ b : menuOpts . totalHeight * ( { top : 1 , middle : 0.5 } [ yanchor ] || 0 ) ,
493
+ t : menuOpts . totalHeight * ( { bottom : 1 , middle : 0.5 } [ yanchor ] || 0 )
503
494
} ) ;
495
+
496
+ console . log ( 'menuOpts:' , menuOpts ) ;
504
497
}
505
498
506
499
// set item positions (mutates posOpts)
0 commit comments