@motion-script/core / resolvePivotPosition
Function: resolvePivotPosition()
resolvePivotPosition<
T>(descriptor,width,height):T
Defined in: render/descriptors/shape.ts:155
Fold a plain pivot + x/y into an equivalent resolved centre, so
{ x, y, pivot: 'topRight' } lands the top-right corner at (x, y) — the same
place { topRight: { x, y } } would — instead of x/y always positioning the
centre regardless of pivot. Uses the same centre = target − a · (size / 2)
formula as the anchor shorthand.
Must run exactly once, on the raw author-facing descriptor, before
resolveShapeAnchor ever sees it (i.e. in flipPositionY, not inside
with*Descriptor, which BaseShape.resolveState calls a second time on
already-resolved state — re-running this there would double the offset, since
the output below is indistinguishable from a plain x/y/pivot descriptor).
A no-op when an anchor shorthand is already present (validated downstream) or
pivot is centre/absent.
Type Parameters
T
T extends Partial<ShapeState> & ShapeAnchorInput
Parameters
descriptor
T
width
number
height
number
Returns
T