@@ -314,6 +314,11 @@ function drawButtons(gd, gHeader, gButton, scrollBox, menuOpts) {
314314 index : 0 ,
315315 } ;
316316
317+ var scrollBoxPosition = {
318+ l : posOpts . x + menuOpts . borderwidth ,
319+ t : posOpts . y + menuOpts . borderwidth
320+ } ;
321+
317322 buttons . each ( function ( buttonOpts , buttonIndex ) {
318323 var button = d3 . select ( this ) ;
319324
@@ -344,49 +349,29 @@ function drawButtons(gd, gHeader, gButton, scrollBox, menuOpts) {
344349
345350 buttons . call ( styleButtons , menuOpts ) ;
346351
352+ if ( isVertical ) {
353+ scrollBoxPosition . w = Math . max ( menuOpts . openWidth , menuOpts . headerWidth ) ;
354+ scrollBoxPosition . h = posOpts . y - scrollBoxPosition . t ;
355+ }
356+ else {
357+ scrollBoxPosition . w = posOpts . x - scrollBoxPosition . l ;
358+ scrollBoxPosition . h = Math . max ( menuOpts . openHeight , menuOpts . headerHeight ) ;
359+ }
360+
347361 if ( scrollBox ) {
348362 if ( buttons . size ( ) ) {
349- drawScrollBox ( gd , gHeader , gButton , scrollBox , menuOpts ) ;
363+ drawScrollBox ( gd , gHeader , gButton , scrollBox , menuOpts , scrollBoxPosition ) ;
350364 }
351365 else {
352366 hideScrollBox ( scrollBox ) ;
353367 }
354368 }
355369}
356370
357- function drawScrollBox ( gd , gHeader , gButton , scrollBox , menuOpts ) {
371+ function drawScrollBox ( gd , gHeader , gButton , scrollBox , menuOpts , position ) {
358372 // enable the scrollbox
359373 var direction = menuOpts . direction ,
360- isUp = ( direction === 'up' ) ,
361- isDown = ( direction === 'down' ) ,
362- isLeft = ( direction === 'left' ) ,
363- isRight = ( direction === 'right' ) ,
364- isVertical = ( isUp || isDown ) ;
365-
366- var x0 , y0 ;
367- if ( isDown ) {
368- x0 = 0 ;
369- y0 = menuOpts . headerHeight + constants . gapButtonHeader ;
370- }
371- else if ( isUp ) {
372- x0 = 0 ;
373- y0 = menuOpts . headerHeight + constants . gapButton - menuOpts . openHeight ;
374- }
375- else if ( isRight ) {
376- x0 = menuOpts . headerWidth + constants . gapButtonHeader ;
377- y0 = 0 ;
378- }
379- else if ( isLeft ) {
380- x0 = menuOpts . headerWidth + constants . gapButton - menuOpts . openWidth ;
381- y0 = 0 ;
382- }
383-
384- var position = {
385- l : menuOpts . lx + menuOpts . borderwidth + x0 + menuOpts . pad . l ,
386- t : menuOpts . ly + menuOpts . borderwidth + y0 + menuOpts . pad . t ,
387- w : Math . max ( menuOpts . openWidth , menuOpts . headerWidth ) ,
388- h : menuOpts . openHeight
389- } ;
374+ isVertical = ( direction === 'up' || direction === 'down' ) ;
390375
391376 var active = menuOpts . active ,
392377 translateX , translateY ,
0 commit comments