gka/d3-jetpack

attachTooltip: Flow tooltip towards top, unless it overflows viewport and there's space below to accommodate tooltip

cedricsam opened this issue · 1 comments

Haven't fully explored every use case, but it seems like a better user experience if the tooltip is above the cursor at all times, except when it overflows (towards the top) and there's space below it to accommodate it.

So, if I were to have a super-tall tooltip that doesn't fit the entire height of viewport, the tooltip would never flow over at the bottom, but may flow over at the top. There's probably no ideal solution (and could be parametrized), but it works well for regular bottom-aligned bar charts, where the bars trigger the tooltip.

Going to submit a PR in a sec. cc: @1wheel

Actually, the new code doesn't force tooltip to be above cursor... It just avoids having the tooltip overflow at the bottom when it is taller than 200px.