motion-dom 14.1.1 → 14.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +1151 -186
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/animation/AsyncMotionValueAnimation.mjs +19 -1
- package/dist/es/animation/AsyncMotionValueAnimation.mjs.map +1 -1
- package/dist/es/animation/JSAnimation.mjs +54 -24
- package/dist/es/animation/JSAnimation.mjs.map +1 -1
- package/dist/es/animation/NativeAnimationExtended.mjs +47 -20
- package/dist/es/animation/NativeAnimationExtended.mjs.map +1 -1
- package/dist/es/animation/interfaces/motion-value.mjs +1 -0
- package/dist/es/animation/interfaces/motion-value.mjs.map +1 -1
- package/dist/es/animation/keyframes/DOMKeyframesResolver.mjs +25 -1
- package/dist/es/animation/keyframes/DOMKeyframesResolver.mjs.map +1 -1
- package/dist/es/animation/waapi/supports/waapi.mjs +1 -1
- package/dist/es/animation/waapi/supports/waapi.mjs.map +1 -1
- package/dist/es/animation/waapi/transforms/TransformAnimation.mjs +854 -0
- package/dist/es/animation/waapi/transforms/TransformAnimation.mjs.map +1 -0
- package/dist/es/animation/waapi/transforms/groups.mjs +4 -0
- package/dist/es/animation/waapi/transforms/groups.mjs.map +1 -0
- package/dist/es/effects/style/index.mjs +6 -3
- package/dist/es/effects/style/index.mjs.map +1 -1
- package/dist/es/effects/style/transform.mjs +2 -7
- package/dist/es/effects/style/transform.mjs.map +1 -1
- package/dist/es/index.mjs +3 -3
- package/dist/es/projection/node/create-projection-node.mjs +10 -0
- package/dist/es/projection/node/create-projection-node.mjs.map +1 -1
- package/dist/es/render/VisualElement.mjs +16 -3
- package/dist/es/render/VisualElement.mjs.map +1 -1
- package/dist/es/render/html/utils/build-transform.mjs +1 -1
- package/dist/es/render/html/utils/build-transform.mjs.map +1 -1
- package/dist/es/value/index.mjs +12 -0
- package/dist/es/value/index.mjs.map +1 -1
- package/dist/index.d.ts +77 -12
- package/dist/motion-dom.dev.js +1151 -186
- package/dist/motion-dom.js +1 -1
- package/dist/size-rollup-motion-value.js +1 -1
- package/dist/size-rollup-motion-value.js.map +1 -1
- package/dist/size-rollup-style-effect.js +1 -1
- package/dist/size-rollup-style-effect.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DOMKeyframesResolver.mjs","sources":["../../../../src/animation/keyframes/DOMKeyframesResolver.ts"],"sourcesContent":["import { positionalKeys } from \"../../render/utils/keys-position\"\nimport { MotionValue } from \"../../value\"\nimport { findDimensionValueType } from \"../../value/types/dimensions\"\nimport { AnyResolvedKeyframe } from \"../types\"\nimport { getVariableValue } from \"../utils/css-variables-conversion\"\nimport {\n containsCSSVariable,\n isCSSVariableToken,\n} from \"../utils/is-css-variable\"\nimport {\n KeyframeResolver,\n OnKeyframesResolved,\n UnresolvedKeyframes,\n} from \"./KeyframesResolver\"\nimport { WithRender } from \"./types\"\nimport { isNone } from \"./utils/is-none\"\nimport { makeNoneKeyframesAnimatable } from \"./utils/make-none-animatable\"\nimport { isNumOrPxType, positionalValues } from \"./utils/unit-conversion\"\n\nexport class DOMKeyframesResolver<\n T extends AnyResolvedKeyframe\n> extends KeyframeResolver<T> {\n name: string\n element?: WithRender\n\n private removedTransforms?: [string, AnyResolvedKeyframe][]\n private measuredOrigin?: AnyResolvedKeyframe\n\n constructor(\n unresolvedKeyframes: UnresolvedKeyframes<AnyResolvedKeyframe>,\n onComplete: OnKeyframesResolved<T>,\n name?: string,\n motionValue?: MotionValue<T>,\n element?: WithRender\n ) {\n super(unresolvedKeyframes, onComplete, name, motionValue, element, true)\n }\n\n readKeyframes() {\n const { unresolvedKeyframes, element, name } = this\n\n if (!element || !element.current) return\n\n super.readKeyframes()\n\n /**\n * If any keyframe is a CSS variable, we need to find its value by sampling the element\n */\n for (let i = 0; i < unresolvedKeyframes.length; i++) {\n let keyframe = unresolvedKeyframes[i]\n\n if (typeof keyframe === \"string\") {\n keyframe = keyframe.trim()\n\n if (isCSSVariableToken(keyframe)) {\n const resolved = getVariableValue(keyframe, element.current)\n\n if (resolved !== undefined) {\n unresolvedKeyframes[i] = resolved as T\n }\n\n if (i === unresolvedKeyframes.length - 1) {\n this.finalKeyframe = keyframe as T\n }\n }\n }\n }\n\n /**\n * Resolve \"none\" values. We do this potentially twice - once before and once after measuring keyframes.\n * This could be seen as inefficient but it's a trade-off to avoid measurements in more situations, which\n * have a far bigger performance impact.\n */\n this.resolveNoneKeyframes()\n\n /**\n * Check to see if unit type has changed. If so schedule jobs that will\n * temporarily set styles to the destination keyframes.\n * Skip if we have more than two keyframes or this isn't a positional value.\n * TODO: We can throw if there are multiple keyframes and the value type changes.\n */\n if (!positionalKeys.has(name) || unresolvedKeyframes.length !== 2) {\n return\n }\n\n const [origin, target] = unresolvedKeyframes\n\n // Two numbers share a unit, so skip the value type search.\n if (typeof origin === \"number\" && typeof target === \"number\") return\n\n const originType = findDimensionValueType(origin)\n const targetType = findDimensionValueType(target)\n\n /**\n * If one keyframe contains embedded CSS variables (e.g. in calc()) and the other\n * doesn't, we need to measure to convert to pixels. This handles GitHub issue #3410.\n */\n const originHasVar = containsCSSVariable(origin)\n const targetHasVar = containsCSSVariable(target)\n\n if (originHasVar !== targetHasVar && positionalValues[name]) {\n this.needsMeasurement = true\n return\n }\n\n /**\n * Either we don't recognise these value types or we can animate between them.\n */\n if (originType === targetType) return\n\n /**\n * If both values are numbers or pixels, we can animate between them by\n * converting them to numbers.\n */\n if (isNumOrPxType(originType) && isNumOrPxType(targetType)) {\n for (let i = 0; i < unresolvedKeyframes.length; i++) {\n const value = unresolvedKeyframes[i]\n if (typeof value === \"string\") {\n unresolvedKeyframes[i] = parseFloat(value as string)\n }\n }\n } else if (positionalValues[name]) {\n /**\n * Else, the only way to resolve this is by measuring the element.\n */\n this.needsMeasurement = true\n }\n }\n\n resolveNoneKeyframes() {\n const { unresolvedKeyframes, name } = this\n\n const noneKeyframeIndexes: number[] = []\n for (let i = 0; i < unresolvedKeyframes.length; i++) {\n if (\n unresolvedKeyframes[i] === null ||\n isNone(unresolvedKeyframes[i])\n ) {\n noneKeyframeIndexes.push(i)\n }\n }\n\n if (noneKeyframeIndexes.length) {\n makeNoneKeyframesAnimatable(\n unresolvedKeyframes,\n noneKeyframeIndexes,\n name\n )\n }\n }\n\n private measure() {\n const { element, name } = this\n return positionalValues[name](\n window.getComputedStyle(element!.current!),\n () => element!.measureViewportBox()\n )\n }\n\n measureInitialState() {\n const { element, unresolvedKeyframes, name } = this\n\n if (!element || !element.current) return\n\n if (name === \"height\") {\n this.suspendedScrollY = window.pageYOffset\n }\n\n this.measuredOrigin = this.measure()\n\n unresolvedKeyframes[0] = this.measuredOrigin\n\n // Set final key frame to measure after next render\n const measureKeyframe =\n unresolvedKeyframes[unresolvedKeyframes.length - 1]\n\n if (measureKeyframe !== undefined) {\n this.motionValue?.jump(measureKeyframe as T, false)\n }\n }\n\n measureEndState() {\n const { element, unresolvedKeyframes } = this\n\n if (!element || !element.current) return\n\n this.motionValue?.jump(this.measuredOrigin as T, false)\n\n const finalKeyframeIndex = unresolvedKeyframes.length - 1\n const finalKeyframe = unresolvedKeyframes[finalKeyframeIndex]\n\n unresolvedKeyframes[finalKeyframeIndex] = this.measure() as any\n\n if (finalKeyframe !== null && this.finalKeyframe === undefined) {\n this.finalKeyframe = finalKeyframe as T\n }\n\n // If we removed transform values, reapply them before the next render\n if (this.removedTransforms?.length) {\n this.removedTransforms.forEach(\n ([unsetTransformName, unsetTransformValue]) => {\n element\n .getValue(unsetTransformName)!\n .set(unsetTransformValue)\n }\n )\n }\n\n this.resolveNoneKeyframes()\n }\n}\n"],"names":[],"mappings":";;;;;;;;;AAmBM,MAAO,oBAEX,SAAQ,gBAAmB,CAAA;IAOzB,WAAA,CACI,mBAA6D,EAC7D,UAAkC,EAClC,IAAa,EACb,WAA4B,EAC5B,OAAoB,EAAA;AAEpB,QAAA,KAAK,CAAC,mBAAmB,EAAE,UAAU,EAAE,IAAI,EA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AAEvD,QAAA,MAAM,kBAAkB,GAAG,mBAAmB,CAAC,MAAM,GAAG,CAAC;AACzD,QAAA,MAAM,aAAa,GAAG,mBAAmB,CAAC,kBAAkB,CAAC;QAE7D,mBAAmB,CAAC,kBAAkB,CAAC,GAAG,IAAI,CAAC,OAAO,EAAS;QAE/D,IAAI,aAAa,KAAK,IAAI,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS,EAAE;AAC5D,YAAA,IAAI,CAAC,aAAa,GAAG,aAAkB;QAC3C;;AAGA,QAAA,IAAI,IAAI,CAAC,iBAAiB,EAAE,MAAM,EAAE;AAChC,YAAA,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAC1B,CAAC,CAAC,kBAAkB,EAAE,mBAAmB,CAAC,KAAI;gBAC1C;qBACK,QAAQ,CAAC,kBAAkB;qBAC3B,GAAG,CAAC,mBAAmB,CAAC;AACjC,YAAA,CAAC,CACJ;QACL;QAEA,IAAI,CAAC,oBAAoB,EAAE;IAC/B;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"DOMKeyframesResolver.mjs","sources":["../../../../src/animation/keyframes/DOMKeyframesResolver.ts"],"sourcesContent":["import { positionalKeys } from \"../../render/utils/keys-position\"\nimport { MotionValue } from \"../../value\"\nimport { findDimensionValueType } from \"../../value/types/dimensions\"\nimport { AnyResolvedKeyframe } from \"../types\"\nimport { getVariableValue } from \"../utils/css-variables-conversion\"\nimport {\n containsCSSVariable,\n isCSSVariableToken,\n} from \"../utils/is-css-variable\"\nimport {\n KeyframeResolver,\n OnKeyframesResolved,\n UnresolvedKeyframes,\n} from \"./KeyframesResolver\"\nimport { WithRender } from \"./types\"\nimport { isNone } from \"./utils/is-none\"\nimport { makeNoneKeyframesAnimatable } from \"./utils/make-none-animatable\"\nimport { isNumOrPxType, positionalValues } from \"./utils/unit-conversion\"\n\nexport class DOMKeyframesResolver<\n T extends AnyResolvedKeyframe\n> extends KeyframeResolver<T> {\n name: string\n element?: WithRender\n\n private removedTransforms?: [string, AnyResolvedKeyframe][]\n private measuredOrigin?: AnyResolvedKeyframe\n\n constructor(\n unresolvedKeyframes: UnresolvedKeyframes<AnyResolvedKeyframe>,\n onComplete: OnKeyframesResolved<T>,\n name?: string,\n motionValue?: MotionValue<T>,\n element?: WithRender\n ) {\n super(unresolvedKeyframes, onComplete, name, motionValue, element, true)\n }\n\n /**\n * Keyframes that don't need reading from the DOM, or measuring,\n * resolve straight away rather than in the frame loop's batched read.\n */\n scheduleResolve() {\n if (this.canReadNow()) {\n this.readKeyframes()\n if (!this.needsMeasurement) return this.complete()\n }\n\n super.scheduleResolve()\n }\n\n private canReadNow() {\n const { unresolvedKeyframes, element, motionValue } = this\n const origin = unresolvedKeyframes[0] ?? motionValue?.get()\n\n if (!element?.current || origin === undefined) return false\n\n for (let i = 0; i < unresolvedKeyframes.length; i++) {\n if (containsCSSVariable(i ? unresolvedKeyframes[i] : origin)) {\n return false\n }\n }\n\n return true\n }\n\n readKeyframes() {\n const { unresolvedKeyframes, element, name } = this\n\n if (!element || !element.current) return\n\n super.readKeyframes()\n\n /**\n * If any keyframe is a CSS variable, we need to find its value by sampling the element\n */\n for (let i = 0; i < unresolvedKeyframes.length; i++) {\n let keyframe = unresolvedKeyframes[i]\n\n if (typeof keyframe === \"string\") {\n keyframe = keyframe.trim()\n\n if (isCSSVariableToken(keyframe)) {\n const resolved = getVariableValue(keyframe, element.current)\n\n if (resolved !== undefined) {\n unresolvedKeyframes[i] = resolved as T\n }\n\n if (i === unresolvedKeyframes.length - 1) {\n this.finalKeyframe = keyframe as T\n }\n }\n }\n }\n\n /**\n * Resolve \"none\" values. We do this potentially twice - once before and once after measuring keyframes.\n * This could be seen as inefficient but it's a trade-off to avoid measurements in more situations, which\n * have a far bigger performance impact.\n */\n this.resolveNoneKeyframes()\n\n /**\n * Check to see if unit type has changed. If so schedule jobs that will\n * temporarily set styles to the destination keyframes.\n * Skip if we have more than two keyframes or this isn't a positional value.\n * TODO: We can throw if there are multiple keyframes and the value type changes.\n */\n if (!positionalKeys.has(name) || unresolvedKeyframes.length !== 2) {\n return\n }\n\n const [origin, target] = unresolvedKeyframes\n\n // Two numbers share a unit, so skip the value type search.\n if (typeof origin === \"number\" && typeof target === \"number\") return\n\n const originType = findDimensionValueType(origin)\n const targetType = findDimensionValueType(target)\n\n /**\n * If one keyframe contains embedded CSS variables (e.g. in calc()) and the other\n * doesn't, we need to measure to convert to pixels. This handles GitHub issue #3410.\n */\n const originHasVar = containsCSSVariable(origin)\n const targetHasVar = containsCSSVariable(target)\n\n if (originHasVar !== targetHasVar && positionalValues[name]) {\n this.needsMeasurement = true\n return\n }\n\n /**\n * Either we don't recognise these value types or we can animate between them.\n */\n if (originType === targetType) return\n\n /**\n * If both values are numbers or pixels, we can animate between them by\n * converting them to numbers.\n */\n if (isNumOrPxType(originType) && isNumOrPxType(targetType)) {\n for (let i = 0; i < unresolvedKeyframes.length; i++) {\n const value = unresolvedKeyframes[i]\n if (typeof value === \"string\") {\n unresolvedKeyframes[i] = parseFloat(value as string)\n }\n }\n } else if (positionalValues[name]) {\n /**\n * Else, the only way to resolve this is by measuring the element.\n */\n this.needsMeasurement = true\n }\n }\n\n resolveNoneKeyframes() {\n const { unresolvedKeyframes, name } = this\n\n const noneKeyframeIndexes: number[] = []\n for (let i = 0; i < unresolvedKeyframes.length; i++) {\n if (\n unresolvedKeyframes[i] === null ||\n isNone(unresolvedKeyframes[i])\n ) {\n noneKeyframeIndexes.push(i)\n }\n }\n\n if (noneKeyframeIndexes.length) {\n makeNoneKeyframesAnimatable(\n unresolvedKeyframes,\n noneKeyframeIndexes,\n name\n )\n }\n }\n\n private measure() {\n const { element, name } = this\n return positionalValues[name](\n window.getComputedStyle(element!.current!),\n () => element!.measureViewportBox()\n )\n }\n\n measureInitialState() {\n const { element, unresolvedKeyframes, name } = this\n\n if (!element || !element.current) return\n\n if (name === \"height\") {\n this.suspendedScrollY = window.pageYOffset\n }\n\n this.measuredOrigin = this.measure()\n\n unresolvedKeyframes[0] = this.measuredOrigin\n\n // Set final key frame to measure after next render\n const measureKeyframe =\n unresolvedKeyframes[unresolvedKeyframes.length - 1]\n\n if (measureKeyframe !== undefined) {\n this.motionValue?.jump(measureKeyframe as T, false)\n }\n }\n\n measureEndState() {\n const { element, unresolvedKeyframes } = this\n\n if (!element || !element.current) return\n\n this.motionValue?.jump(this.measuredOrigin as T, false)\n\n const finalKeyframeIndex = unresolvedKeyframes.length - 1\n const finalKeyframe = unresolvedKeyframes[finalKeyframeIndex]\n\n unresolvedKeyframes[finalKeyframeIndex] = this.measure() as any\n\n if (finalKeyframe !== null && this.finalKeyframe === undefined) {\n this.finalKeyframe = finalKeyframe as T\n }\n\n // If we removed transform values, reapply them before the next render\n if (this.removedTransforms?.length) {\n this.removedTransforms.forEach(\n ([unsetTransformName, unsetTransformValue]) => {\n element\n .getValue(unsetTransformName)!\n .set(unsetTransformValue)\n }\n )\n }\n\n this.resolveNoneKeyframes()\n }\n}\n"],"names":[],"mappings":";;;;;;;;;AAmBM,MAAO,oBAEX,SAAQ,gBAAmB,CAAA;IAOzB,WAAA,CACI,mBAA6D,EAC7D,UAAkC,EAClC,IAAa,EACb,WAA4B,EAC5B,OAAoB,EAAA;AAEpB,QAAA,KAAK,CAAC,mBAAmB,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,CAAC;IAC5E;AAEA;;;AAGG;IACH,eAAe,GAAA;AACX,QAAA,IAAI,IAAI,CAAC,UAAU,EAAE,EAAE;YACnB,IAAI,CAAC,aAAa,EAAE;YACpB,IAAI,CAAC,IAAI,CAAC,gBAAgB;AAAE,gBAAA,OAAO,IAAI,CAAC,QAAQ,EAAE;QACtD;QAEA,KAAK,CAAC,eAAe,EAAE;IAC3B;IAEQ,UAAU,GAAA;QACd,MAAM,EAAE,mBAAmB,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,IAAI;QAC1D,MAAM,MAAM,GAAG,mBAAmB,CAAC,CAAC,CAAC,IAAI,WAAW,E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AAe,KAAK,SAAS,EAAE;YAC/B,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,eAAoB,EAAE,KAAK,CAAC;QACvD;IACJ;IAEA,eAAe,GAAA;AACX,QAAA,MAAM,EAAE,OAAO,EAAE,mBAAmB,EAAE,GAAG,IAAI;AAE7C,QAAA,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO;YAAE;QAElC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,cAAmB,EAAE,KAAK,CAAC;AAEvD,QAAA,MAAM,kBAAkB,GAAG,mBAAmB,CAAC,MAAM,GAAG,CAAC;AACzD,QAAA,MAAM,aAAa,GAAG,mBAAmB,CAAC,kBAAkB,CAAC;QAE7D,mBAAmB,CAAC,kBAAkB,CAAC,GAAG,IAAI,CAAC,OAAO,EAAS;QAE/D,IAAI,aAAa,KAAK,IAAI,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS,EAAE;AAC5D,YAAA,IAAI,CAAC,aAAa,GAAG,aAAkB;QAC3C;;AAGA,QAAA,IAAI,IAAI,CAAC,iBAAiB,EAAE,MAAM,EAAE;AAChC,YAAA,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAC1B,CAAC,CAAC,kBAAkB,EAAE,mBAAmB,CAAC,KAAI;gBAC1C;qBACK,QAAQ,CAAC,kBAAkB;qBAC3B,GAAG,CAAC,mBAAmB,CAAC;AACjC,YAAA,CAAC,CACJ;QACL;QAEA,IAAI,CAAC,oBAAoB,EAAE;IAC/B;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"waapi.mjs","sources":["../../../../../src/animation/waapi/supports/waapi.ts"],"sourcesContent":["import { memo } from \"motion-utils\"\nimport {\n AnyResolvedKeyframe,\n ValueAnimationOptionsWithRenderContext,\n} from \"../../types\"\nimport { acceleratedValues } from \"../utils/accelerated-values\"\nimport { hasBrowserOnlyColors } from \"../utils/is-browser-color\"\n\nconst colorProperties = new Set([\n \"color\",\n \"backgroundColor\",\n \"outlineColor\",\n \"fill\",\n \"stroke\",\n \"borderColor\",\n \"borderTopColor\",\n \"borderRightColor\",\n \"borderBottomColor\",\n \"borderLeftColor\",\n])\n\
|
|
1
|
+
{"version":3,"file":"waapi.mjs","sources":["../../../../../src/animation/waapi/supports/waapi.ts"],"sourcesContent":["import { memo } from \"motion-utils\"\nimport {\n AnyResolvedKeyframe,\n ValueAnimationOptionsWithRenderContext,\n} from \"../../types\"\nimport { acceleratedValues } from \"../utils/accelerated-values\"\nimport { hasBrowserOnlyColors } from \"../utils/is-browser-color\"\n\nconst colorProperties = new Set([\n \"color\",\n \"backgroundColor\",\n \"outlineColor\",\n \"fill\",\n \"stroke\",\n \"borderColor\",\n \"borderTopColor\",\n \"borderRightColor\",\n \"borderBottomColor\",\n \"borderLeftColor\",\n])\n\nexport const supportsWaapi = /*@__PURE__*/ memo(() =>\n Object.hasOwnProperty.call(Element.prototype, \"animate\")\n)\n\nexport function supportsBrowserAnimation<T extends AnyResolvedKeyframe>(\n options: ValueAnimationOptionsWithRenderContext<T>\n) {\n const {\n motionValue,\n name,\n repeatDelay,\n repeatType,\n damping,\n type,\n keyframes,\n } = options\n\n /**\n * Most values can't be accelerated at all, so check the name before\n * looking at the element or its props.\n */\n if (\n !name ||\n !(acceleratedValues.has(name) || colorProperties.has(name))\n ) {\n return false\n }\n\n const subject = motionValue?.owner?.current\n\n /**\n * We use instanceof checks instead of isHTMLElement()/isSVGElement()\n * because we explicitly **don't** want elements in different timing\n * contexts (i.e. popups) to be accelerated, as it's not possible to sync\n * these animations properly with those driven from the main window\n * frameloop.\n */\n if (\n !(subject instanceof HTMLElement) &&\n !(subject instanceof SVGElement)\n ) {\n return false\n }\n\n const { onUpdate, transformTemplate } = motionValue!.owner!.getProps()\n\n return (\n supportsWaapi() &&\n /**\n * Force WAAPI for color properties with browser-only color formats\n * (oklch, oklab, lab, lch, etc.) that the JS animation path can't parse.\n */\n (acceleratedValues.has(name) ||\n (colorProperties.has(name) &&\n hasBrowserOnlyColors(keyframes))) &&\n (name !== \"transform\" || !transformTemplate) &&\n /**\n * If we're outputting values to onUpdate then we can't use WAAPI as there's\n * no way to read the value from WAAPI every frame.\n */\n !onUpdate &&\n !repeatDelay &&\n repeatType !== \"mirror\" &&\n damping !== 0 &&\n type !== \"inertia\"\n )\n}\n"],"names":[],"mappings":";;;;AAQA,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC;IAC5B,OAAO;IACP,iBAAiB;IACjB,cAAc;IACd,MAAM;IACN,QAAQ;IACR,aAAa;IACb,gBAAgB;IAChB,kBAAkB;IAClB,mBAAmB;IACnB,iBAAiB;AACpB,CAAA,CAAC;AAEK,MAAM,aAAa,iBAAiB,IAAI,CAAC,MAC5C,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC;AAGtD,SAAU,wBAAwB,CACpC,OAAkD,EAAA;AAElD,IAAA,MAAM,EACF,WAAW,EACX,IAAI,EACJ,WAAW,EACX,UAAU,EACV,OAAO,EACP,IAAI,EACJ,SAAS,GACZ,GAAG,OAAO;AAEX;;;AAGG;AACH,IAAA,IACI,CAAC,IAAI;AACL,QAAA,EAAE,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EAC7D;AACE,QAAA,OAAO,KAAK;IAChB;AAEA,IAAA,MAAM,OAAO,GAAG,WAAW,EAAE,KAAK,EAAE,OAAO;AAE3C;;;;;;AAMG;AACH,IAAA,IACI,EAAE,OAAO,YAAY,WAAW,CAAC;AACjC,QAAA,EAAE,OAAO,YAAY,UAAU,CAAC,EAClC;AACE,QAAA,OAAO,KAAK;IAChB;AAEA,IAAA,MAAM,EAAE,QAAQ,EAAE,iBAAiB,EAAE,GAAG,WAAY,CAAC,KAAM,CAAC,QAAQ,EAAE;IAEtE,QACI,aAAa,EAAE;AACf;;;AAGG;AACH,SAAC,iBAAiB,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