Skip to content

Commit 563009b

Browse files
committed
updatemenus: center dropmenu on active option
1 parent 8d1f333 commit 563009b

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/components/updatemenus/draw.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,33 @@ function drawButtons(gd, gHeader, gButton, menuOpts) {
332332
buttons.call(styleButtons, menuOpts);
333333

334334
scrollBox.enable();
335+
336+
var active = menuOpts.active,
337+
i;
338+
if(isVertical) {
339+
if(scrollBox._vbar) {
340+
var translateY = 0;
341+
for(i = 0; i < active; i++) {
342+
translateY += menuOpts.heights[i] + constants.gapButton;
343+
}
344+
translateY -= constants.gapButton;
345+
346+
var yf = translateY / (scrollBox.position.h - scrollBox._box.h);
347+
scrollBox.setTranslate(0, yf);
348+
}
349+
}
350+
else {
351+
if(scrollBox._hbar) {
352+
var translateX = 0;
353+
for(i = 0; i < active; i++) {
354+
translateX += menuOpts.widths[i] + constants.gapButton;
355+
}
356+
translateX -= constants.gapButton;
357+
358+
var xf = translateX / (scrollBox.position.w - scrollBox._box.w);
359+
scrollBox.setTranslate(xf, 0);
360+
}
361+
}
335362
}
336363

337364
function setActive(gd, menuOpts, buttonOpts, gHeader, gButton, buttonIndex, isSilentUpdate) {

0 commit comments

Comments
 (0)