@motion-script/core / caretOffsetAt
Function: caretOffsetAt()
caretOffsetAt(
layout,point):number
Defined in: runtime/text-geometry.ts:118
The caret offset nearest point (viewport space) — what a click or a drag
over the rendered text should place the cursor at.
Nearest slot, by distance to the caret segment rather than to its midpoint: a click below a short first line should land on that line's nearest slot, and midpoints would pull it toward whichever line's centre happened to be closer. Segment distance also keeps this correct for rotated and scaled text without needing a separate case, since the slots arrive already transformed.
Parameters
layout
point
Returns
number