(
{ pageX: childrenX, width: childrenWidth }: ChildrenMeasurement,
{ width: tooltipWidth }: TooltipLayout
)
| 62 | }; |
| 63 | |
| 64 | const getTooltipXPosition = ( |
| 65 | { pageX: childrenX, width: childrenWidth }: ChildrenMeasurement, |
| 66 | { width: tooltipWidth }: TooltipLayout |
| 67 | ): number => { |
| 68 | // when the children use position absolute the childrenWidth is measured as 0, |
| 69 | // so it's best to anchor the tooltip at the start of the children |
| 70 | const center = |
| 71 | childrenWidth > 0 |
| 72 | ? childrenX + (childrenWidth - tooltipWidth) / 2 |
| 73 | : childrenX; |
| 74 | |
| 75 | if (overflowLeft(center)) return childrenX; |
| 76 | |
| 77 | if (overflowRight(center, tooltipWidth)) |
| 78 | return childrenX + childrenWidth - tooltipWidth; |
| 79 | |
| 80 | return center; |
| 81 | }; |
| 82 | |
| 83 | const getTooltipYPosition = ( |
| 84 | { pageY: childrenY, height: childrenHeight }: ChildrenMeasurement, |
no test coverage detected
searching dependent graphs…