anchor
Summary
Positions a floating element against a target and tracks geometry, scroll, and resize changes.
Updates inline positioning and size constraints, and records the chosen side in
data-anchor-placement. Call the returned cleanup function when the surface closes or unmounts.
Cleanup stops tracking but leaves the last applied styles and placement attribute in place.
Signature
function anchor(
floating: HTMLElement,
anchorTarget: AnchorTarget,
options: AnchorOptions,
): () => void
Parameters
floating
Element to position.
anchorTarget
Anchor element or viewport coordinates.
options
Placement, alignment, and offsets.
Returns
Cleanup function that stops polling and removes scroll and resize listeners.