Geometry types ​
Rect is the exported rectangle shape used by drag and drop helpers:
ts
interface Rect {
x: number;
y: number;
width: number;
height: number;
}anchoredPosition ​
anchoredPosition(options) returns the { x, y } viewport position of a panel placed against an anchor rectangle:
ts
import { anchoredPosition } from "@jolly-pixel/ui";
const { x, y } = anchoredPosition({
anchor: button.getBoundingClientRect(),
panel: { width: 240, height: 120 },
viewport: { width: innerWidth, height: innerHeight },
gap: 8,
side: "right"
});anchoris anAnchorRect(top,bottom,left,right) in viewport pixels; aDOMRectfits.sideis the preferred side,"above","below"(default),"left"or"right". The panel flips to the opposite side when it does not fit there and fits on the other one.alignis"start"(default), aligned with the anchor's top or left edge,"center", or"end", aligned with its bottom or right edge.- The result is clamped to the viewport. A panel larger than the viewport starts at its edge.