MCPcopy
hub / github.com/callstack/react-native-paper / getTooltipXPosition

Function getTooltipXPosition

src/components/Tooltip/utils.ts:64–81  ·  view source on GitHub ↗
(
  { pageX: childrenX, width: childrenWidth }: ChildrenMeasurement,
  { width: tooltipWidth }: TooltipLayout
)

Source from the content-addressed store, hash-verified

62};
63
64const 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
83const getTooltipYPosition = (
84 { pageY: childrenY, height: childrenHeight }: ChildrenMeasurement,

Callers 1

getTooltipPositionFunction · 0.85

Calls 2

overflowLeftFunction · 0.85
overflowRightFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…