motion-dom 14.5.0 → 14.7.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 +706 -632
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/animation/AsyncMotionValueAnimation.mjs +3 -6
- package/dist/es/animation/AsyncMotionValueAnimation.mjs.map +1 -1
- package/dist/es/animation/JSAnimation.mjs +18 -30
- package/dist/es/animation/JSAnimation.mjs.map +1 -1
- package/dist/es/animation/NativeAnimation.mjs +14 -8
- package/dist/es/animation/NativeAnimation.mjs.map +1 -1
- package/dist/es/animation/animate/effects.mjs +5 -2
- package/dist/es/animation/animate/effects.mjs.map +1 -1
- package/dist/es/animation/generators/inertia.mjs +3 -2
- package/dist/es/animation/generators/inertia.mjs.map +1 -1
- package/dist/es/animation/generators/spring.mjs +50 -52
- package/dist/es/animation/generators/spring.mjs.map +1 -1
- package/dist/es/animation/interfaces/visual-element-target.mjs +1 -1
- package/dist/es/animation/interfaces/visual-element-target.mjs.map +1 -1
- package/dist/es/animation/keyframes/DOMKeyframesResolver.mjs +7 -15
- package/dist/es/animation/keyframes/DOMKeyframesResolver.mjs.map +1 -1
- package/dist/es/animation/keyframes/KeyframesResolver.mjs.map +1 -1
- package/dist/es/animation/keyframes/utils/unit-conversion.mjs +8 -7
- package/dist/es/animation/keyframes/utils/unit-conversion.mjs.map +1 -1
- package/dist/es/animation/optimized-appear/data-id.mjs +1 -3
- package/dist/es/animation/optimized-appear/data-id.mjs.map +1 -1
- package/dist/es/animation/utils/can-animate.mjs +1 -0
- package/dist/es/animation/utils/can-animate.mjs.map +1 -1
- package/dist/es/animation/utils/css-variables-conversion.mjs +2 -1
- package/dist/es/animation/utils/css-variables-conversion.mjs.map +1 -1
- package/dist/es/animation/utils/is-transition-defined.mjs +1 -0
- package/dist/es/animation/utils/is-transition-defined.mjs.map +1 -1
- package/dist/es/animation/waapi/supports/waapi.mjs +8 -2
- package/dist/es/animation/waapi/supports/waapi.mjs.map +1 -1
- package/dist/es/animation/waapi/transforms/TransformAnimation.mjs +44 -21
- package/dist/es/animation/waapi/transforms/TransformAnimation.mjs.map +1 -1
- package/dist/es/animation/waapi/utils/accelerated-values.mjs +4 -1
- package/dist/es/animation/waapi/utils/accelerated-values.mjs.map +1 -1
- package/dist/es/effects/style/transform.mjs +4 -20
- package/dist/es/effects/style/transform.mjs.map +1 -1
- package/dist/es/frameloop/process-frame.mjs +42 -0
- package/dist/es/frameloop/process-frame.mjs.map +1 -0
- package/dist/es/frameloop/render-step.mjs +15 -1
- package/dist/es/frameloop/render-step.mjs.map +1 -1
- package/dist/es/gestures/drag/VisualElementDragControls.mjs +94 -67
- package/dist/es/gestures/drag/VisualElementDragControls.mjs.map +1 -1
- package/dist/es/gestures/pan/PanSession.mjs +28 -39
- package/dist/es/gestures/pan/PanSession.mjs.map +1 -1
- package/dist/es/index.mjs +4 -2
- package/dist/es/index.mjs.map +1 -1
- package/dist/es/layout/LayoutAnimationBuilder.mjs +2 -2
- package/dist/es/layout/LayoutAnimationBuilder.mjs.map +1 -1
- package/dist/es/projection/animation/mix-values.mjs +3 -11
- package/dist/es/projection/animation/mix-values.mjs.map +1 -1
- package/dist/es/projection/geometry/delta-apply.mjs +10 -6
- package/dist/es/projection/geometry/delta-apply.mjs.map +1 -1
- package/dist/es/projection/geometry/delta-calc.mjs +2 -2
- package/dist/es/projection/geometry/delta-calc.mjs.map +1 -1
- package/dist/es/projection/geometry/delta-remove.mjs +2 -2
- package/dist/es/projection/geometry/delta-remove.mjs.map +1 -1
- package/dist/es/projection/node/DocumentProjectionNode.mjs +8 -3
- package/dist/es/projection/node/DocumentProjectionNode.mjs.map +1 -1
- package/dist/es/projection/node/HTMLProjectionNode.mjs +5 -6
- package/dist/es/projection/node/HTMLProjectionNode.mjs.map +1 -1
- package/dist/es/projection/node/create-projection-node.mjs +158 -148
- package/dist/es/projection/node/create-projection-node.mjs.map +1 -1
- package/dist/es/projection/node/root.mjs +6 -0
- package/dist/es/projection/node/root.mjs.map +1 -0
- package/dist/es/projection/styles/default-scale-correctors.mjs +3 -4
- package/dist/es/projection/styles/default-scale-correctors.mjs.map +1 -1
- package/dist/es/projection/styles/transform.mjs +12 -16
- package/dist/es/projection/styles/transform.mjs.map +1 -1
- package/dist/es/projection/utils/has-transform.mjs +16 -2
- package/dist/es/projection/utils/has-transform.mjs.map +1 -1
- package/dist/es/render/VisualElement.mjs +20 -37
- package/dist/es/render/VisualElement.mjs.map +1 -1
- package/dist/es/render/dom/parse-transform.mjs +6 -17
- package/dist/es/render/dom/parse-transform.mjs.map +1 -1
- package/dist/es/render/html/HTMLVisualElement.mjs +2 -1
- package/dist/es/render/html/HTMLVisualElement.mjs.map +1 -1
- package/dist/es/render/html/utils/build-transform.mjs +25 -29
- package/dist/es/render/html/utils/build-transform.mjs.map +1 -1
- package/dist/es/render/utils/animation-state.mjs +58 -15
- package/dist/es/render/utils/animation-state.mjs.map +1 -1
- package/dist/es/render/utils/variant-props.mjs +1 -1
- package/dist/es/render/utils/variant-props.mjs.map +1 -1
- package/dist/es/utils/interpolate.mjs +2 -1
- package/dist/es/utils/interpolate.mjs.map +1 -1
- package/dist/es/utils/mix/color.mjs +2 -1
- package/dist/es/utils/mix/color.mjs.map +1 -1
- package/dist/es/utils/mix/complex.mjs +4 -4
- package/dist/es/utils/mix/complex.mjs.map +1 -1
- package/dist/es/utils/resolve-elements.mjs.map +1 -1
- package/dist/es/value/index.mjs +13 -34
- package/dist/es/value/index.mjs.map +1 -1
- package/dist/es/value/types/color/hex.mjs +13 -26
- package/dist/es/value/types/color/hex.mjs.map +1 -1
- package/dist/es/value/types/complex/index.mjs +1 -1
- package/dist/es/value/types/complex/index.mjs.map +1 -1
- package/dist/index.d.ts +111 -30
- package/dist/motion-dom.dev.js +690 -625
- 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 +4 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unit-conversion.mjs","sources":["../../../../../src/animation/keyframes/utils/unit-conversion.ts"],"sourcesContent":["import type { Box } from \"motion-utils\"\nimport { parseValueFromTransform } from \"../../../render/dom/parse-transform\"\nimport { transformPropOrder } from \"../../../render/utils/keys-transform\"\nimport { MotionValue } from \"../../../value\"\nimport { number } from \"../../../value/types/numbers\"\nimport { px } from \"../../../value/types/numbers/units\"\nimport { ValueType } from \"../../../value/types/types\"\nimport { AnyResolvedKeyframe } from \"../../types\"\nimport { WithRender } from \"../types\"\n\nexport const isNumOrPxType = (v?: ValueType): v is ValueType =>\n v === number || v === px\n\n/**\n * Measures a positional value in pixels from an element's computed style.\n * The bounding box is only measured on demand as it forces layout and is\n * affected by transforms.\n */\ntype GetActualMeasurementInPixels = (\n computedStyle: Partial<CSSStyleDeclaration>,\n measureBox: () => Box\n) => number\n\nconst transformKeys = new Set([\"x\", \"y\", \"z\"])\nconst nonTranslationalTransformKeys = transformPropOrder.filter(\n (key) => !transformKeys.has(key)\n)\n\ntype RemovedTransforms = [string, AnyResolvedKeyframe][]\n\n/**\n * Reset any bounding box-changing transforms so the element can be\n * measured. Returns the values to restore. Values already at their\n * default don't change the box, so they're left alone: an element with\n * only `rotate: 0` doesn't need to be re-rendered before measuring.\n */\nexport function removeNonTranslationalTransform(visualElement: WithRender) {\n const removedTransforms: RemovedTransforms = []\n\n nonTranslationalTransformKeys.forEach((key) => {\n const value: MotionValue<AnyResolvedKeyframe> | undefined =\n visualElement.getValue(key)\n if (value !== undefined) {\n const current = value.get()\n const reset = key.startsWith(\"scale\") ? 1 : 0\n\n if (current === reset) return\n\n removedTransforms.push([key, current])\n value.set(reset)\n }\n })\n\n return removedTransforms\n}\n\n/**\n * Values that can only be measured from the bounding box. Elements with\n * these values need bounding box-changing transforms removed first.\n */\nexport const boxDependentValues = new Set([\"bottom\", \"right\"])\n\n/**\n * Computed width/height is already in pixels and unaffected by\n * transforms. It's \"auto\" for elements without a layout box (e.g. inline),\n * in which case we fall back to measuring the bounding box.\n */\nfunction measureDimension(\n computed: string | undefined,\n measureBox: () => Box,\n axis: \"x\" | \"y\",\n paddingStart: string,\n paddingEnd: string,\n boxSizing?: string\n) {\n const px = parseFloat(computed as string)\n if (!isNaN(px)) return px\n\n const { min, max } = measureBox()[axis]\n const size = max - min\n return boxSizing === \"border-box\"\n ? size\n : size - parseFloat(paddingStart) - parseFloat(paddingEnd)\n}\n\nexport const positionalValues: { [key: string]: GetActualMeasurementInPixels } =\n {\n // Dimensions\n width: (\n { width, paddingLeft = \"0\", paddingRight = \"0\", boxSizing },\n measureBox\n ) =>\n measureDimension(\n width,\n measureBox,\n \"x\",\n paddingLeft,\n paddingRight,\n boxSizing\n ),\n height: (\n { height, paddingTop = \"0\", paddingBottom = \"0\", boxSizing },\n measureBox\n ) =>\n measureDimension(\n height,\n measureBox,\n \"y\",\n paddingTop,\n paddingBottom,\n boxSizing\n ),\n\n top: ({ top }) => parseFloat(top as string),\n left: ({ left }) => parseFloat(left as string),\n bottom: ({ top }, measureBox) => {\n const { y } = measureBox()\n return parseFloat(top as string) + (y.max - y.min)\n },\n right: ({ left }, measureBox) => {\n const { x } = measureBox()\n return parseFloat(left as string) + (x.max - x.min)\n },\n\n // Transform\n x:
|
|
1
|
+
{"version":3,"file":"unit-conversion.mjs","sources":["../../../../../src/animation/keyframes/utils/unit-conversion.ts"],"sourcesContent":["import type { Box } from \"motion-utils\"\nimport { parseValueFromTransform } from \"../../../render/dom/parse-transform\"\nimport { transformPropOrder } from \"../../../render/utils/keys-transform\"\nimport { MotionValue } from \"../../../value\"\nimport { number } from \"../../../value/types/numbers\"\nimport { px } from \"../../../value/types/numbers/units\"\nimport { ValueType } from \"../../../value/types/types\"\nimport { AnyResolvedKeyframe } from \"../../types\"\nimport { WithRender } from \"../types\"\n\nexport const isNumOrPxType = (v?: ValueType): v is ValueType =>\n v === number || v === px\n\n/**\n * Measures a positional value in pixels from an element's computed style.\n * The bounding box is only measured on demand as it forces layout and is\n * affected by transforms.\n */\ntype GetActualMeasurementInPixels = (\n computedStyle: Partial<CSSStyleDeclaration>,\n measureBox: () => Box\n) => number\n\nconst transformKeys = new Set([\"x\", \"y\", \"z\"])\nconst nonTranslationalTransformKeys = /* @__PURE__ */ transformPropOrder.filter(\n (key) => !transformKeys.has(key)\n)\n\ntype RemovedTransforms = [string, AnyResolvedKeyframe][]\n\n/**\n * Reset any bounding box-changing transforms so the element can be\n * measured. Returns the values to restore. Values already at their\n * default don't change the box, so they're left alone: an element with\n * only `rotate: 0` doesn't need to be re-rendered before measuring.\n */\nexport function removeNonTranslationalTransform(visualElement: WithRender) {\n const removedTransforms: RemovedTransforms = []\n\n nonTranslationalTransformKeys.forEach((key) => {\n const value: MotionValue<AnyResolvedKeyframe> | undefined =\n visualElement.getValue(key)\n if (value !== undefined) {\n const current = value.get()\n const reset = key.startsWith(\"scale\") ? 1 : 0\n\n if (current === reset) return\n\n removedTransforms.push([key, current])\n value.set(reset)\n }\n })\n\n return removedTransforms\n}\n\n/**\n * Values that can only be measured from the bounding box. Elements with\n * these values need bounding box-changing transforms removed first.\n */\nexport const boxDependentValues = new Set([\"bottom\", \"right\"])\n\n/**\n * Computed width/height is already in pixels and unaffected by\n * transforms. It's \"auto\" for elements without a layout box (e.g. inline),\n * in which case we fall back to measuring the bounding box.\n */\nfunction measureDimension(\n computed: string | undefined,\n measureBox: () => Box,\n axis: \"x\" | \"y\",\n paddingStart: string,\n paddingEnd: string,\n boxSizing?: string\n) {\n const px = parseFloat(computed as string)\n if (!isNaN(px)) return px\n\n const { min, max } = measureBox()[axis]\n const size = max - min\n return boxSizing === \"border-box\"\n ? size\n : size - parseFloat(paddingStart) - parseFloat(paddingEnd)\n}\n\nconst transformX: GetActualMeasurementInPixels = ({ transform }) =>\n parseValueFromTransform(transform, \"x\")\nconst transformY: GetActualMeasurementInPixels = ({ transform }) =>\n parseValueFromTransform(transform, \"y\")\n\nexport const positionalValues: { [key: string]: GetActualMeasurementInPixels } =\n {\n // Dimensions\n width: (\n { width, paddingLeft = \"0\", paddingRight = \"0\", boxSizing },\n measureBox\n ) =>\n measureDimension(\n width,\n measureBox,\n \"x\",\n paddingLeft,\n paddingRight,\n boxSizing\n ),\n height: (\n { height, paddingTop = \"0\", paddingBottom = \"0\", boxSizing },\n measureBox\n ) =>\n measureDimension(\n height,\n measureBox,\n \"y\",\n paddingTop,\n paddingBottom,\n boxSizing\n ),\n\n top: ({ top }) => parseFloat(top as string),\n left: ({ left }) => parseFloat(left as string),\n bottom: ({ top }, measureBox) => {\n const { y } = measureBox()\n return parseFloat(top as string) + (y.max - y.min)\n },\n right: ({ left }, measureBox) => {\n const { x } = measureBox()\n return parseFloat(left as string) + (x.max - x.min)\n },\n\n // Transform, including translate longform names\n x: transformX,\n y: transformY,\n translateX: transformX,\n translateY: transformY,\n }\n"],"names":[],"mappings":"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"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { camelToDash } from '../../render/dom/utils/camel-to-dash.mjs';
|
|
2
|
-
|
|
3
1
|
const optimizedAppearDataId = "framerAppearId";
|
|
4
|
-
const optimizedAppearDataAttribute = "data-"
|
|
2
|
+
const optimizedAppearDataAttribute = "data-framer-appear-id";
|
|
5
3
|
|
|
6
4
|
export { optimizedAppearDataAttribute, optimizedAppearDataId };
|
|
7
5
|
//# sourceMappingURL=data-id.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-id.mjs","sources":["../../../../src/animation/optimized-appear/data-id.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"data-id.mjs","sources":["../../../../src/animation/optimized-appear/data-id.ts"],"sourcesContent":["export const optimizedAppearDataId = \"framerAppearId\"\n\nexport const optimizedAppearDataAttribute = \"data-framer-appear-id\"\n"],"names":[],"mappings":"AAAO,MAAM,qBAAqB,GAAG;AAE9B,MAAM,4BAA4B,GAAG;;;;"}
|
|
@@ -35,6 +35,7 @@ function canAnimate(keyframes, name, type, velocity) {
|
|
|
35
35
|
if (!isOriginAnimatable || !isTargetAnimatable) {
|
|
36
36
|
// Only build the message when we're going to warn
|
|
37
37
|
isOriginAnimatable !== isTargetAnimatable &&
|
|
38
|
+
process.env.NODE_ENV !== "production" &&
|
|
38
39
|
warning(false, `You are trying to animate ${name} from "${originKeyframe}" to "${targetKeyframe}". "${isOriginAnimatable ? targetKeyframe : originKeyframe}" is not an animatable value.`, "value-not-animatable");
|
|
39
40
|
return false;
|
|
40
41
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"can-animate.mjs","sources":["../../../../src/animation/utils/can-animate.ts"],"sourcesContent":["import { warning } from \"motion-utils\"\nimport { isGenerator } from \"../generators/utils/is-generator\"\nimport { ResolvedKeyframes } from \"../keyframes/KeyframesResolver\"\nimport { AnimationGeneratorType } from \"../types\"\nimport { isAnimatable } from \"./is-animatable\"\n\nfunction hasKeyframesChanged(keyframes: ResolvedKeyframes<any>) {\n const current = keyframes[0]\n if (keyframes.length === 1) return true\n for (let i = 0; i < keyframes.length; i++) {\n if (keyframes[i] !== current) return true\n }\n}\n\nexport function canAnimate(\n keyframes: ResolvedKeyframes<any>,\n name?: string,\n type?: AnimationGeneratorType,\n velocity?: number\n) {\n /**\n * Check if we're able to animate between the start and end keyframes,\n * and throw a warning if we're attempting to animate between one that's\n * animatable and another that isn't.\n */\n const originKeyframe = keyframes[0]\n if (originKeyframe === null) {\n return false\n }\n\n /**\n * These aren't traditionally animatable but we do support them.\n * In future we could look into making this more generic or replacing\n * this function with mix() === mixImmediate\n */\n if (name === \"display\" || name === \"visibility\") return true\n\n const targetKeyframe = keyframes[keyframes.length - 1]\n const isOriginAnimatable = isAnimatable(originKeyframe, name)\n const isTargetAnimatable = isAnimatable(targetKeyframe, name)\n\n // Always skip if any of these are true\n if (!isOriginAnimatable || !isTargetAnimatable) {\n // Only build the message when we're going to warn\n isOriginAnimatable !== isTargetAnimatable &&\n warning(\n false,\n `You are trying to animate ${name} from \"${originKeyframe}\" to \"${targetKeyframe}\". \"${\n isOriginAnimatable ? targetKeyframe : originKeyframe\n }\" is not an animatable value.`,\n \"value-not-animatable\"\n )\n\n return false\n }\n\n return (\n hasKeyframesChanged(keyframes) ||\n ((type === \"spring\" || isGenerator(type)) && velocity)\n )\n}\n"],"names":[],"mappings":";;;;AAMA,SAAS,mBAAmB,CAAC,SAAiC,EAAA;AAC1D,IAAA,MAAM,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC;AAC5B,IAAA,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;AAAE,QAAA,OAAO,IAAI;AACvC,IAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AACvC,QAAA,IAAI,SAAS,CAAC,CAAC,CAAC,KAAK,OAAO;AAAE,YAAA,OAAO,IAAI;IAC7C;AACJ;AAEM,SAAU,UAAU,CACtB,SAAiC,EACjC,IAAa,EACb,IAA6B,EAC7B,QAAiB,EAAA;AAEjB;;;;AAIG;AACH,IAAA,MAAM,cAAc,GAAG,SAAS,CAAC,CAAC,CAAC;AACnC,IAAA,IAAI,cAAc,KAAK,IAAI,EAAE;AACzB,QAAA,OAAO,KAAK;IAChB;AAEA;;;;AAIG;AACH,IAAA,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,YAAY;AAAE,QAAA,OAAO,IAAI;IAE5D,MAAM,cAAc,GAAG,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;IACtD,MAAM,kBAAkB,GAAG,YAAY,CAAC,cAAc,EAAE,IAAI,CAAC;IAC7D,MAAM,kBAAkB,GAAG,YAAY,CAAC,cAAc,EAAE,IAAI,CAAC;;AAG7D,IAAA,IAAI,CAAC,kBAAkB,IAAI,CAAC,kBAAkB,EAAE;;AAE5C,QAAA,kBAAkB,KAAK,kBAAkB;YACrC,OAAO,CACH,KAAK,EACL,CAAA,0BAAA,EAA6B,IAAI,CAAA,OAAA,EAAU,cAAc,CAAA,MAAA,EAAS,cAAc,CAAA,IAAA,EAC5E,kBAAkB,GAAG,cAAc,GAAG,cAC1C,CAAA,6BAAA,CAA+B,EAC/B,sBAAsB,CACzB;AAEL,QAAA,OAAO,KAAK;IAChB;AAEA,IAAA,QACI,mBAAmB,CAAC,SAAS,CAAC;AAC9B,SAAC,CAAC,IAAI,KAAK,QAAQ,IAAI,WAAW,CAAC,IAAI,CAAC,KAAK,QAAQ,CAAC;AAE9D;;;;"}
|
|
1
|
+
{"version":3,"file":"can-animate.mjs","sources":["../../../../src/animation/utils/can-animate.ts"],"sourcesContent":["import { warning } from \"motion-utils\"\nimport { isGenerator } from \"../generators/utils/is-generator\"\nimport { ResolvedKeyframes } from \"../keyframes/KeyframesResolver\"\nimport { AnimationGeneratorType } from \"../types\"\nimport { isAnimatable } from \"./is-animatable\"\n\nfunction hasKeyframesChanged(keyframes: ResolvedKeyframes<any>) {\n const current = keyframes[0]\n if (keyframes.length === 1) return true\n for (let i = 0; i < keyframes.length; i++) {\n if (keyframes[i] !== current) return true\n }\n}\n\nexport function canAnimate(\n keyframes: ResolvedKeyframes<any>,\n name?: string,\n type?: AnimationGeneratorType,\n velocity?: number\n) {\n /**\n * Check if we're able to animate between the start and end keyframes,\n * and throw a warning if we're attempting to animate between one that's\n * animatable and another that isn't.\n */\n const originKeyframe = keyframes[0]\n if (originKeyframe === null) {\n return false\n }\n\n /**\n * These aren't traditionally animatable but we do support them.\n * In future we could look into making this more generic or replacing\n * this function with mix() === mixImmediate\n */\n if (name === \"display\" || name === \"visibility\") return true\n\n const targetKeyframe = keyframes[keyframes.length - 1]\n const isOriginAnimatable = isAnimatable(originKeyframe, name)\n const isTargetAnimatable = isAnimatable(targetKeyframe, name)\n\n // Always skip if any of these are true\n if (!isOriginAnimatable || !isTargetAnimatable) {\n // Only build the message when we're going to warn\n isOriginAnimatable !== isTargetAnimatable &&\n process.env.NODE_ENV !== \"production\" &&\n warning(\n false,\n `You are trying to animate ${name} from \"${originKeyframe}\" to \"${targetKeyframe}\". \"${\n isOriginAnimatable ? targetKeyframe : originKeyframe\n }\" is not an animatable value.`,\n \"value-not-animatable\"\n )\n\n return false\n }\n\n return (\n hasKeyframesChanged(keyframes) ||\n ((type === \"spring\" || isGenerator(type)) && velocity)\n )\n}\n"],"names":[],"mappings":";;;;AAMA,SAAS,mBAAmB,CAAC,SAAiC,EAAA;AAC1D,IAAA,MAAM,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC;AAC5B,IAAA,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;AAAE,QAAA,OAAO,IAAI;AACvC,IAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AACvC,QAAA,IAAI,SAAS,CAAC,CAAC,CAAC,KAAK,OAAO;AAAE,YAAA,OAAO,IAAI;IAC7C;AACJ;AAEM,SAAU,UAAU,CACtB,SAAiC,EACjC,IAAa,EACb,IAA6B,EAC7B,QAAiB,EAAA;AAEjB;;;;AAIG;AACH,IAAA,MAAM,cAAc,GAAG,SAAS,CAAC,CAAC,CAAC;AACnC,IAAA,IAAI,cAAc,KAAK,IAAI,EAAE;AACzB,QAAA,OAAO,KAAK;IAChB;AAEA;;;;AAIG;AACH,IAAA,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,YAAY;AAAE,QAAA,OAAO,IAAI;IAE5D,MAAM,cAAc,GAAG,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;IACtD,MAAM,kBAAkB,GAAG,YAAY,CAAC,cAAc,EAAE,IAAI,CAAC;IAC7D,MAAM,kBAAkB,GAAG,YAAY,CAAC,cAAc,EAAE,IAAI,CAAC;;AAG7D,IAAA,IAAI,CAAC,kBAAkB,IAAI,CAAC,kBAAkB,EAAE;;AAE5C,QAAA,kBAAkB,KAAK,kBAAkB;AACrC,YAAA,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;YACrC,OAAO,CACH,KAAK,EACL,CAAA,0BAAA,EAA6B,IAAI,CAAA,OAAA,EAAU,cAAc,CAAA,MAAA,EAAS,cAAc,CAAA,IAAA,EAC5E,kBAAkB,GAAG,cAAc,GAAG,cAC1C,CAAA,6BAAA,CAA+B,EAC/B,sBAAsB,CACzB;AAEL,QAAA,OAAO,KAAK;IAChB;AAEA,IAAA,QACI,mBAAmB,CAAC,SAAS,CAAC;AAC9B,SAAC,CAAC,IAAI,KAAK,QAAQ,IAAI,WAAW,CAAC,IAAI,CAAC,KAAK,QAAQ,CAAC;AAE9D;;;;"}
|
|
@@ -22,7 +22,8 @@ function parseCSSVariable(current) {
|
|
|
22
22
|
}
|
|
23
23
|
const maxDepth = 4;
|
|
24
24
|
function getVariableValue(current, element, depth = 1) {
|
|
25
|
-
|
|
25
|
+
process.env.NODE_ENV !== "production" &&
|
|
26
|
+
invariant(depth <= maxDepth, `Max CSS variable fallback depth detected in property "${current}". This may indicate a circular fallback dependency.`, "max-css-var-depth");
|
|
26
27
|
const [token, fallback] = parseCSSVariable(current);
|
|
27
28
|
// No CSS variable detected
|
|
28
29
|
if (!token)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"css-variables-conversion.mjs","sources":["../../../../src/animation/utils/css-variables-conversion.ts"],"sourcesContent":["import { invariant, isNumericalString } from \"motion-utils\"\nimport { AnyResolvedKeyframe } from \"../types\"\nimport { CSSVariableToken, isCSSVariableToken } from \"./is-css-variable\"\n\n/**\n * Parse Framer's special CSS variable format into a CSS token and a fallback.\n *\n * ```\n * `var(--foo, #fff)` => [`--foo`, '#fff']\n * ```\n *\n * @param current\n */\n\nconst splitCSSVariableRegex =\n // eslint-disable-next-line redos-detector/no-unsafe-regex -- false positive, as it can match a lot of words\n /^var\\(--(?:([\\w-]+)|([\\w-]+), ?([a-zA-Z\\d ()%#.,-]+))\\)/u\nexport function parseCSSVariable(current: string) {\n const match = splitCSSVariableRegex.exec(current)\n if (!match) return [,]\n\n const [, token1, token2, fallback] = match\n return [`--${token1 ?? token2}`, fallback]\n}\n\nconst maxDepth = 4\nexport function getVariableValue(\n current: CSSVariableToken,\n element: Element,\n depth = 1\n): AnyResolvedKeyframe | undefined {\n invariant(\n
|
|
1
|
+
{"version":3,"file":"css-variables-conversion.mjs","sources":["../../../../src/animation/utils/css-variables-conversion.ts"],"sourcesContent":["import { invariant, isNumericalString } from \"motion-utils\"\nimport { AnyResolvedKeyframe } from \"../types\"\nimport { CSSVariableToken, isCSSVariableToken } from \"./is-css-variable\"\n\n/**\n * Parse Framer's special CSS variable format into a CSS token and a fallback.\n *\n * ```\n * `var(--foo, #fff)` => [`--foo`, '#fff']\n * ```\n *\n * @param current\n */\n\nconst splitCSSVariableRegex =\n // eslint-disable-next-line redos-detector/no-unsafe-regex -- false positive, as it can match a lot of words\n /^var\\(--(?:([\\w-]+)|([\\w-]+), ?([a-zA-Z\\d ()%#.,-]+))\\)/u\nexport function parseCSSVariable(current: string) {\n const match = splitCSSVariableRegex.exec(current)\n if (!match) return [,]\n\n const [, token1, token2, fallback] = match\n return [`--${token1 ?? token2}`, fallback]\n}\n\nconst maxDepth = 4\nexport function getVariableValue(\n current: CSSVariableToken,\n element: Element,\n depth = 1\n): AnyResolvedKeyframe | undefined {\n process.env.NODE_ENV !== \"production\" &&\n invariant(\n depth <= maxDepth,\n `Max CSS variable fallback depth detected in property \"${current}\". This may indicate a circular fallback dependency.`,\n \"max-css-var-depth\"\n )\n\n const [token, fallback] = parseCSSVariable(current)\n\n // No CSS variable detected\n if (!token) return\n\n // Attempt to read this CSS variable off the element\n const resolved = window.getComputedStyle(element).getPropertyValue(token)\n\n if (resolved) {\n const trimmed = resolved.trim()\n return isNumericalString(trimmed) ? parseFloat(trimmed) : trimmed\n }\n\n return isCSSVariableToken(fallback)\n ? getVariableValue(fallback, element, depth + 1)\n : fallback\n}\n"],"names":[],"mappings":";;;AAIA;;;;;;;;AAQG;AAEH,MAAM,qBAAqB;AACvB;AACA,0DAA0D;AACxD,SAAU,gBAAgB,CAAC,OAAe,EAAA;IAC5C,MAAM,KAAK,GAAG,qBAAqB,CAAC,IAAI,CAAC,OAAO,CAAC;AACjD,IAAA,IAAI,CAAC,KAAK;QAAE,OAAO,GAAG;IAEtB,MAAM,GAAG,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,GAAG,KAAK;IAC1C,OAAO,CAAC,KAAK,MAAM,IAAI,MAAM,CAAA,CAAE,EAAE,QAAQ,CAAC;AAC9C;AAEA,MAAM,QAAQ,GAAG,CAAC;AACZ,SAAU,gBAAgB,CAC5B,OAAyB,EACzB,OAAgB,EAChB,KAAK,GAAG,CAAC,EAAA;AAET,IAAA,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;QACjC,SAAS,CACL,KAAK,IAAI,QAAQ,EACjB,CAAA,sDAAA,EAAyD,OAAO,CAAA,oDAAA,CAAsD,EACtH,mBAAmB,CACtB;IAEL,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,gBAAgB,CAAC,OAAO,CAAC;;AAGnD,IAAA,IAAI,CAAC,KAAK;QAAE;;AAGZ,IAAA,MAAM,QAAQ,GAAG,MAAM,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,gBAAgB,CAAC,KAAK,CAAC;IAEzE,IAAI,QAAQ,EAAE;AACV,QAAA,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,EAAE;AAC/B,QAAA,OAAO,iBAAiB,CAAC,OAAO,CAAC,GAAG,UAAU,CAAC,OAAO,CAAC,GAAG,OAAO;IACrE;IAEA,OAAO,kBAAkB,CAAC,QAAQ;UAC5B,gBAAgB,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,GAAG,CAAC;UAC7C,QAAQ;AAClB;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-transition-defined.mjs","sources":["../../../../src/animation/utils/is-transition-defined.ts"],"sourcesContent":["import type { AnyResolvedKeyframe } from \"../types\"\nimport type { Transition } from \"../types\"\n\nconst orchestrationKeys = new Set([\n \"when\",\n \"delay\",\n \"delayChildren\",\n \"staggerChildren\",\n \"staggerDirection\",\n \"repeat\",\n \"repeatType\",\n \"repeatDelay\",\n \"from\",\n \"elapsed\",\n])\n\n/**\n * Decide whether a transition is defined on a given Transition.\n * This filters out orchestration options and returns true\n * if any options are left.\n */\nexport function isTransitionDefined(\n transition: Transition & { elapsed?: number; from?: AnyResolvedKeyframe }\n) {\n for (const key in transition) {\n if (!orchestrationKeys.has(key)) return true\n }\n return false\n}\n"],"names":[],"mappings":"AAGA,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC;IAC9B,MAAM;IACN,OAAO;IACP,eAAe;IACf,iBAAiB;IACjB,kBAAkB;IAClB,QAAQ;IACR,YAAY;IACZ,aAAa;IACb,MAAM;IACN,SAAS;
|
|
1
|
+
{"version":3,"file":"is-transition-defined.mjs","sources":["../../../../src/animation/utils/is-transition-defined.ts"],"sourcesContent":["import type { AnyResolvedKeyframe } from \"../types\"\nimport type { Transition } from \"../types\"\n\nconst orchestrationKeys = new Set([\n \"when\",\n \"delay\",\n \"delayChildren\",\n \"staggerChildren\",\n \"staggerDirection\",\n \"repeat\",\n \"repeatType\",\n \"repeatDelay\",\n \"from\",\n \"elapsed\",\n \"out\",\n])\n\n/**\n * Decide whether a transition is defined on a given Transition.\n * This filters out orchestration options and returns true\n * if any options are left.\n */\nexport function isTransitionDefined(\n transition: Transition & { elapsed?: number; from?: AnyResolvedKeyframe }\n) {\n for (const key in transition) {\n if (!orchestrationKeys.has(key)) return true\n }\n return false\n}\n"],"names":[],"mappings":"AAGA,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC;IAC9B,MAAM;IACN,OAAO;IACP,eAAe;IACf,iBAAiB;IACjB,kBAAkB;IAClB,QAAQ;IACR,YAAY;IACZ,aAAa;IACb,MAAM;IACN,SAAS;IACT,KAAK;AACR,CAAA,CAAC;AAEF;;;;AAIG;AACG,SAAU,mBAAmB,CAC/B,UAAyE,EAAA;AAEzE,IAAA,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE;AAC1B,QAAA,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,GAAG,CAAC;AAAE,YAAA,OAAO,IAAI;IAChD;AACA,IAAA,OAAO,KAAK;AAChB;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MotionGlobalConfig } from 'motion-utils';
|
|
2
2
|
import { acceleratedValues } from '../utils/accelerated-values.mjs';
|
|
3
3
|
import { hasBrowserOnlyColors } from '../utils/is-browser-color.mjs';
|
|
4
4
|
|
|
@@ -14,7 +14,13 @@ const colorProperties = new Set([
|
|
|
14
14
|
"borderBottomColor",
|
|
15
15
|
"borderLeftColor",
|
|
16
16
|
]);
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
* WAAPI runs on the browser's clock, so on a manual clock every animation
|
|
19
|
+
* runs in JS where processFrame can drive it. Set the flag before starting
|
|
20
|
+
* animations: running WAAPI animations stay on the browser's clock.
|
|
21
|
+
*/
|
|
22
|
+
const supportsWaapi = () => !MotionGlobalConfig.useManualTiming &&
|
|
23
|
+
Object.hasOwnProperty.call(Element.prototype, "animate");
|
|
18
24
|
function supportsBrowserAnimation(options) {
|
|
19
25
|
const { motionValue, name, repeatDelay, repeatType, damping, type, keyframes, } = options;
|
|
20
26
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"waapi.mjs","sources":["../../../../../src/animation/waapi/supports/waapi.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"waapi.mjs","sources":["../../../../../src/animation/waapi/supports/waapi.ts"],"sourcesContent":["import { MotionGlobalConfig } 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\n/**\n * WAAPI runs on the browser's clock, so on a manual clock every animation\n * runs in JS where processFrame can drive it. Set the flag before starting\n * animations: running WAAPI animations stay on the browser's clock.\n */\nexport const supportsWaapi = () =>\n !MotionGlobalConfig.useManualTiming &&\n Object.hasOwnProperty.call(Element.prototype, \"animate\")\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;AAEF;;;;AAIG;AACI,MAAM,aAAa,GAAG,MACzB,CAAC,kBAAkB,CAAC,eAAe;IACnC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS;AAErD,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,CAAC,GAAG,CAAC,IAAI,CAAC;AACxB,aAAC,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC;AACtB,gBAAA,oBAAoB,CAAC,SAAS,CAAC,CAAC,CAAC;AACzC,SAAC,IAAI,KAAK,WAAW,IAAI,CAAC,iBAAiB,CAAC;AAC5C;;;AAGG;AACH,QAAA,CAAC,QAAQ;AACT,QAAA,CAAC,WAAW;AACZ,QAAA,UAAU,KAAK,QAAQ;AACvB,QAAA,OAAO,KAAK,CAAC;QACb,IAAI,KAAK,SAAS;AAE1B;;;;"}
|
|
@@ -2,11 +2,9 @@ import { isBezierDefinition, millisecondsToSeconds, clamp, progress } from 'moti
|
|
|
2
2
|
import { frame } from '../../../frameloop/frame.mjs';
|
|
3
3
|
import { frameData } from '../../../frameloop/frame-data.mjs';
|
|
4
4
|
import { time } from '../../../frameloop/sync-time.mjs';
|
|
5
|
-
import {
|
|
5
|
+
import { isDefaultTransform, transformFunction } from '../../../render/html/utils/build-transform.mjs';
|
|
6
6
|
import { transformPropOrder } from '../../../render/utils/keys-transform.mjs';
|
|
7
7
|
import { mixNumber } from '../../../utils/mix/number.mjs';
|
|
8
|
-
import { numberValueTypes } from '../../../value/types/maps/number.mjs';
|
|
9
|
-
import { getValueAsType } from '../../../value/types/utils/get-as-type.mjs';
|
|
10
8
|
import { frameloopDriver } from '../../drivers/frame.mjs';
|
|
11
9
|
import { keyframes } from '../../generators/keyframes.mjs';
|
|
12
10
|
import { defaultOffset } from '../../keyframes/offsets/default.mjs';
|
|
@@ -355,27 +353,30 @@ function createGroup(owner) {
|
|
|
355
353
|
return values;
|
|
356
354
|
};
|
|
357
355
|
/**
|
|
358
|
-
* Build
|
|
359
|
-
* is written, even at its default, so each keyframe has the
|
|
360
|
-
* of functions and the browser interpolates them one by one.
|
|
356
|
+
* Build a transform from values in transformPropOrder. For a keyframe,
|
|
357
|
+
* every key is written, even at its default, so each keyframe has the
|
|
358
|
+
* same list of functions and the browser interpolates them one by one.
|
|
359
|
+
* As an inline style, defaults are left out, as buildTransform does.
|
|
361
360
|
*/
|
|
362
|
-
const
|
|
361
|
+
const toTransform = (values, isStyle) => {
|
|
363
362
|
let transform = "";
|
|
364
|
-
const values = valuesAt(timestamp, settled);
|
|
365
363
|
for (const key in values) {
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
") ";
|
|
364
|
+
const value = values[key];
|
|
365
|
+
if (!isStyle || !isDefaultTransform(key, value)) {
|
|
366
|
+
transform += transformFunction(key, value) + " ";
|
|
367
|
+
}
|
|
371
368
|
}
|
|
372
|
-
return transform || "none";
|
|
369
|
+
return (isStyle ? transform.trim() : transform) || "none";
|
|
373
370
|
};
|
|
371
|
+
/**
|
|
372
|
+
* Build the transform at a timestamp.
|
|
373
|
+
*/
|
|
374
|
+
const compose = (timestamp, settled) => toTransform(valuesAt(timestamp, settled));
|
|
374
375
|
/**
|
|
375
376
|
* Write the transform as an inline style, as the renderer would.
|
|
376
377
|
*/
|
|
377
378
|
const commit = (values = valuesAt()) => {
|
|
378
|
-
element.style.transform =
|
|
379
|
+
element.style.transform = toTransform(values, true);
|
|
379
380
|
};
|
|
380
381
|
/**
|
|
381
382
|
* Cancel the WAAPI animations, by default first committing the
|
|
@@ -386,6 +387,13 @@ function createGroup(owner) {
|
|
|
386
387
|
segments.forEach(({ animation }) => animation.cancel());
|
|
387
388
|
segments = [];
|
|
388
389
|
};
|
|
390
|
+
/**
|
|
391
|
+
* A WAAPI animation that add() starts by setting its startTime. Playing
|
|
392
|
+
* it first, as element.animate() does, would leave WebKit holding that
|
|
393
|
+
* play's ready time once startTime ends the play, and it uses that for
|
|
394
|
+
* the next updatePlaybackRate(), so the animation would jump.
|
|
395
|
+
*/
|
|
396
|
+
const create = (keyframes, options) => new Animation(new KeyframeEffect(element, keyframes, options));
|
|
389
397
|
const add = (animation, offset, end = Infinity) => {
|
|
390
398
|
const segment = { animation, offset, end };
|
|
391
399
|
animation.startTime = time.now() + offset;
|
|
@@ -578,7 +586,7 @@ function createGroup(owner) {
|
|
|
578
586
|
commit(valuesAt(from, settled));
|
|
579
587
|
keyframes = null;
|
|
580
588
|
}
|
|
581
|
-
return
|
|
589
|
+
return create(keyframes, {
|
|
582
590
|
...options,
|
|
583
591
|
duration: to - from,
|
|
584
592
|
easing: easing || "linear",
|
|
@@ -668,9 +676,7 @@ function createGroup(owner) {
|
|
|
668
676
|
* empty animations that end with them.
|
|
669
677
|
*/
|
|
670
678
|
ends.forEach((trackEnd) => trackEnd < end - 1 &&
|
|
671
|
-
add(
|
|
672
|
-
duration: trackEnd - now,
|
|
673
|
-
}), 0, trackEnd - now));
|
|
679
|
+
add(create(null, { duration: trackEnd - now }), 0, trackEnd - now));
|
|
674
680
|
}
|
|
675
681
|
if (cycle) {
|
|
676
682
|
/**
|
|
@@ -744,12 +750,29 @@ function createGroup(owner) {
|
|
|
744
750
|
if (isDone)
|
|
745
751
|
continue;
|
|
746
752
|
const local = elapsed - offset;
|
|
747
|
-
if (rate
|
|
753
|
+
if (rate &&
|
|
754
|
+
animation.updatePlaybackRate &&
|
|
755
|
+
animation.playState === "running" &&
|
|
756
|
+
Math.abs(Number(animation.currentTime) - local) < 20) {
|
|
757
|
+
/**
|
|
758
|
+
* Only the speed changed. Setting playbackRate and
|
|
759
|
+
* startTime restarts a running compositor animation, which
|
|
760
|
+
* can render the underlying value for a frame.
|
|
761
|
+
*/
|
|
762
|
+
animation.playbackRate !== rate &&
|
|
763
|
+
animation.updatePlaybackRate(rate);
|
|
764
|
+
}
|
|
765
|
+
else if (rate) {
|
|
748
766
|
animation.playbackRate = rate;
|
|
749
767
|
animation.startTime = now - local / rate;
|
|
750
768
|
}
|
|
751
769
|
else {
|
|
752
|
-
|
|
770
|
+
/**
|
|
771
|
+
* Hold it without pause(), whose pending pause setting
|
|
772
|
+
* currentTime would end at once, leaving WebKit holding its
|
|
773
|
+
* ready time (see create()).
|
|
774
|
+
*/
|
|
775
|
+
animation.startTime = null;
|
|
753
776
|
animation.currentTime = local;
|
|
754
777
|
}
|
|
755
778
|
}
|