PositionCalculator

Primitive #18

🔍 Problem it solves

Once you have the trigger's rect, you need to calculate where to place the overlay (e.g., top, bottom, left, or right of the trigger) with alignment (start, center, end). You also need to apply an offset.

✅ Solution

Calculates overlay coordinates (top/left) based on the chosen side, alignment, offset, and current scroll position. Returns absolute pixel values.

🧩 Used by components

Tooltip, Popover, Dropdown, Select, Combobox, Menu

🎮 Interactive demo