@@ -1199,44 +1199,36 @@ 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 ( 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
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 ;
12091212 } else {
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- }
1213+ lx = 0 ;
12161214 }
1217- } else {
1218- lx = lxLeft ;
12191215 }
12201216 lx += HOVERTEXTPAD ;
12211217
12221218 // vertical alignement to end up on screen
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
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 ;
12301229 } else {
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- }
1230+ ly = 0 ;
12371231 }
1238- } else { // N.B. this case happens on documentation website (outerHeight: 0)
1239- ly = lyTop ;
12401232 }
12411233 ly += HOVERTEXTPAD ;
12421234
0 commit comments