MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / resolveToken

Function resolveToken

packages/sdk/src/adapters/iframe.ts:206–221  ·  view source on GitHub ↗
(token: string, available: number)

Source from the content-addressed store, hash-verified

204 // `available` is the "slack" (box dimension - content dimension).
205 // fallow-ignore-next-line complexity
206 function resolveToken(token: string, available: number): number {
207 if (token === "left" || token === "top") return 0;
208 if (token === "right" || token === "bottom") return available;
209 if (token === "center") return available / 2;
210 if (token.endsWith("%")) {
211 const pct = parseFloat(token) / 100;
212 return isNaN(pct) ? available / 2 : pct * available;
213 }
214 if (token.endsWith("px")) {
215 const px = parseFloat(token);
216 return isNaN(px) ? available / 2 : px;
217 }
218 // Bare number — treat as px
219 const n = parseFloat(token);
220 return isNaN(n) ? available / 2 : n;
221 }
222
223 const availX = box.width - content.width;
224 const availY = box.height - content.height;

Callers 1

parseObjectPositionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected