heartbeat-monitor/node_modules/motion-dom/dist/es/projection/styles/scale-box-shadow.mjs.map

1 line
2.7 KiB
Plaintext

{"version":3,"file":"scale-box-shadow.mjs","sources":["../../../../src/projection/styles/scale-box-shadow.ts"],"sourcesContent":["import { complex } from \"../../value/types/complex\"\nimport { mixNumber } from \"../../utils/mix/number\"\nimport type { ScaleCorrectorDefinition } from \"./types\"\n\nexport const correctBoxShadow: ScaleCorrectorDefinition = {\n correct: (latest: string, { treeScale, projectionDelta }) => {\n const original = latest\n const shadow = complex.parse(latest)\n\n // TODO: Doesn't support multiple shadows\n if (shadow.length > 5) return original\n\n const template = complex.createTransformer(latest)\n const offset = typeof shadow[0] !== \"number\" ? 1 : 0\n\n // Calculate the overall context scale\n const xScale = projectionDelta!.x.scale * treeScale!.x\n const yScale = projectionDelta!.y.scale * treeScale!.y\n\n // Scale x/y\n ;(shadow[0 + offset] as number) /= xScale\n ;(shadow[1 + offset] as number) /= yScale\n\n /**\n * Ideally we'd correct x and y scales individually, but because blur and\n * spread apply to both we have to take a scale average and apply that instead.\n * We could potentially improve the outcome of this by incorporating the ratio between\n * the two scales.\n */\n const averageScale = mixNumber(xScale, yScale, 0.5)\n\n // Blur\n if (typeof shadow[2 + offset] === \"number\")\n (shadow[2 + offset] as number) /= averageScale\n\n // Spread\n if (typeof shadow[3 + offset] === \"number\")\n (shadow[3 + offset] as number) /= averageScale\n\n return template(shadow)\n },\n}\n"],"names":[],"mappings":";;;AAIa,MAAA,gBAAgB,GAA6B;IACtD,OAAO,EAAE,CAAC,MAAc,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,KAAI;QACxD,MAAM,QAAQ,GAAG,MAAM,CAAA;QACvB,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;;AAGpC,QAAA,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;AAAE,YAAA,OAAO,QAAQ,CAAA;QAEtC,MAAM,QAAQ,GAAG,OAAO,CAAC,iBAAiB,C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