Skip to content

Commit df50898

Browse files
committed
handle case of zero outerHeight to bring back unified hover in documentaion website
1 parent 0841bcc commit df50898

File tree

1 file changed

+30
-22
lines changed

1 file changed

+30
-22
lines changed

src/components/fx/hover.js

+30-22
Original file line numberDiff line numberDiff line change
@@ -1199,36 +1199,44 @@ function createHoverText(hoverData, opts, gd) {
11991199
var lx, ly; // top and left positions of the hover box
12001200

12011201
// horizontal alignment to end up on screen
1202-
if(lxRight + tWidth < outerWidth && lxRight >= 0) {
1203-
lx = lxRight;
1204-
} else if(lxLeft + tWidth < outerWidth && lxLeft >= 0) {
1205-
lx = lxLeft;
1206-
} else if(xOffset + tWidth < outerWidth) {
1207-
lx = xOffset; // subplot left corner
1208-
} else {
1209-
// closest left or right side of the paper
1210-
if(lxRight - avgX < avgX - lxLeft + tWidth) {
1211-
lx = outerWidth - tWidth;
1202+
if(outerWidth > 0) {
1203+
if(lxRight + tWidth < outerWidth && lxRight >= 0) {
1204+
lx = lxRight;
1205+
} else if(lxLeft + tWidth < outerWidth && lxLeft >= 0) {
1206+
lx = lxLeft;
1207+
} else if(outerWidth > 0 && xOffset + tWidth < outerWidth) {
1208+
lx = xOffset; // subplot left corner
12121209
} else {
1213-
lx = 0;
1210+
// closest left or right side of the paper
1211+
if(lxRight - avgX < avgX - lxLeft + tWidth) {
1212+
lx = outerWidth - tWidth;
1213+
} else {
1214+
lx = 0;
1215+
}
12141216
}
1217+
} else {
1218+
lx = lxLeft;
12151219
}
12161220
lx += HOVERTEXTPAD;
12171221

12181222
// vertical alignement to end up on screen
1219-
if(lyBottom + tHeight < outerHeight && lyBottom >= 0) {
1220-
ly = lyBottom;
1221-
} else if(lyTop + tHeight < outerHeight && lyTop >= 0) {
1222-
ly = lyTop;
1223-
} else if(yOffset + tHeight < outerHeight) {
1224-
ly = yOffset; // subplot top corner
1225-
} else {
1226-
// closest top or bottom side of the paper
1227-
if(lyBottom - avgY < avgY - lyTop + tHeight) {
1228-
ly = outerHeight - tHeight;
1223+
if(outerHeight > 0) {
1224+
if(lyBottom + tHeight < outerHeight && lyBottom >= 0) {
1225+
ly = lyBottom;
1226+
} else if(lyTop + tHeight < outerHeight && lyTop >= 0) {
1227+
ly = lyTop;
1228+
} else if(yOffset + tHeight < outerHeight) {
1229+
ly = yOffset; // subplot top corner
12291230
} else {
1230-
ly = 0;
1231+
// closest top or bottom side of the paper
1232+
if(lyBottom - avgY < avgY - lyTop + tHeight) {
1233+
ly = outerHeight - tHeight;
1234+
} else {
1235+
ly = 0;
1236+
}
12311237
}
1238+
} else { // N.B. this case happens on documentation website (outerHeight: 0)
1239+
ly = lyTop;
12321240
}
12331241
ly += HOVERTEXTPAD;
12341242

0 commit comments

Comments
 (0)