motion-dom 12.42.1 → 12.43.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 +157 -62
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/animation/waapi/supports/waapi.mjs +7 -5
- package/dist/es/animation/waapi/supports/waapi.mjs.map +1 -1
- package/dist/es/animation/waapi/utils/accelerated-values.mjs +1 -3
- package/dist/es/animation/waapi/utils/accelerated-values.mjs.map +1 -1
- package/dist/es/animation/waapi/utils/px-values.mjs +3 -4
- package/dist/es/animation/waapi/utils/px-values.mjs.map +1 -1
- package/dist/es/projection/animation/mix-values.mjs +3 -8
- package/dist/es/projection/animation/mix-values.mjs.map +1 -1
- package/dist/es/projection/styles/scale-correction.mjs +2 -6
- package/dist/es/projection/styles/scale-correction.mjs.map +1 -1
- package/dist/es/render/html/HTMLVisualElement.mjs +10 -0
- package/dist/es/render/html/HTMLVisualElement.mjs.map +1 -1
- package/dist/es/utils/border-radius.mjs +15 -0
- package/dist/es/utils/border-radius.mjs.map +1 -0
- package/dist/es/view/start.mjs +124 -36
- package/dist/es/view/start.mjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/motion-dom.dev.js +157 -62
- package/dist/motion-dom.js +1 -1
- package/package.json +2 -2
|
@@ -19,12 +19,14 @@ function supportsBrowserAnimation(options) {
|
|
|
19
19
|
const { motionValue, name, repeatDelay, repeatType, damping, type, keyframes, } = options;
|
|
20
20
|
const subject = motionValue?.owner?.current;
|
|
21
21
|
/**
|
|
22
|
-
* We use
|
|
23
|
-
* **don't** want elements in different timing
|
|
24
|
-
* to be accelerated, as it's not possible to sync
|
|
25
|
-
* properly with those driven from the main window
|
|
22
|
+
* We use instanceof checks instead of isHTMLElement()/isSVGElement()
|
|
23
|
+
* because we explicitly **don't** want elements in different timing
|
|
24
|
+
* contexts (i.e. popups) to be accelerated, as it's not possible to sync
|
|
25
|
+
* these animations properly with those driven from the main window
|
|
26
|
+
* frameloop.
|
|
26
27
|
*/
|
|
27
|
-
if (!(subject instanceof HTMLElement)
|
|
28
|
+
if (!(subject instanceof HTMLElement) &&
|
|
29
|
+
!(subject instanceof SVGElement)) {
|
|
28
30
|
return false;
|
|
29
31
|
}
|
|
30
32
|
const { onUpdate, transformTemplate } = motionValue.owner.getProps();
|
|
@@ -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\nconst 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 const subject = motionValue?.owner?.current\n\n /**\n * We use
|
|
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\nconst 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 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 name &&\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,MAAM,aAAa,iBAAiB,IAAI,CAAC,MACrC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,CAC3D;AAEK,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,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;QACf,IAAI;AACJ;;;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;;;;"}
|
|
@@ -6,9 +6,7 @@ const acceleratedValues = new Set([
|
|
|
6
6
|
"clipPath",
|
|
7
7
|
"filter",
|
|
8
8
|
"transform",
|
|
9
|
-
|
|
10
|
-
// or until we implement support for linear() easing.
|
|
11
|
-
// "background-color"
|
|
9
|
+
"backgroundColor",
|
|
12
10
|
]);
|
|
13
11
|
|
|
14
12
|
export { acceleratedValues };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accelerated-values.mjs","sources":["../../../../../src/animation/waapi/utils/accelerated-values.ts"],"sourcesContent":["/**\n * A list of values that can be hardware-accelerated.\n */\nexport const acceleratedValues = new Set<string>([\n \"opacity\",\n \"clipPath\",\n \"filter\",\n \"transform\",\n
|
|
1
|
+
{"version":3,"file":"accelerated-values.mjs","sources":["../../../../../src/animation/waapi/utils/accelerated-values.ts"],"sourcesContent":["/**\n * A list of values that can be hardware-accelerated.\n */\nexport const acceleratedValues = new Set<string>([\n \"opacity\",\n \"clipPath\",\n \"filter\",\n \"transform\",\n \"backgroundColor\",\n])\n"],"names":[],"mappings":"AAAA;;AAEG;AACI,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAS;IAC7C,SAAS;IACT,UAAU;IACV,QAAQ;IACR,WAAW;IACX,iBAAiB;AACpB,CAAA;;;;"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { cornerRadiusProps } from '../../../utils/border-radius.mjs';
|
|
2
|
+
|
|
1
3
|
const pxValues = new Set([
|
|
2
4
|
// Border props
|
|
3
5
|
"borderWidth",
|
|
@@ -6,10 +8,7 @@ const pxValues = new Set([
|
|
|
6
8
|
"borderBottomWidth",
|
|
7
9
|
"borderLeftWidth",
|
|
8
10
|
"borderRadius",
|
|
9
|
-
|
|
10
|
-
"borderTopRightRadius",
|
|
11
|
-
"borderBottomRightRadius",
|
|
12
|
-
"borderBottomLeftRadius",
|
|
11
|
+
...cornerRadiusProps,
|
|
13
12
|
// Positioning props
|
|
14
13
|
"width",
|
|
15
14
|
"maxWidth",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"px-values.mjs","sources":["../../../../../src/animation/waapi/utils/px-values.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"px-values.mjs","sources":["../../../../../src/animation/waapi/utils/px-values.ts"],"sourcesContent":["import { cornerRadiusProps } from \"../../../utils/border-radius\"\n\nexport const pxValues = new Set([\n // Border props\n \"borderWidth\",\n \"borderTopWidth\",\n \"borderRightWidth\",\n \"borderBottomWidth\",\n \"borderLeftWidth\",\n \"borderRadius\",\n ...cornerRadiusProps,\n // Positioning props\n \"width\",\n \"maxWidth\",\n \"height\",\n \"maxHeight\",\n \"top\",\n \"right\",\n \"bottom\",\n \"left\",\n \"inset\",\n \"insetBlock\",\n \"insetBlockStart\",\n \"insetBlockEnd\",\n \"insetInline\",\n \"insetInlineStart\",\n \"insetInlineEnd\",\n // Spacing props\n \"padding\",\n \"paddingTop\",\n \"paddingRight\",\n \"paddingBottom\",\n \"paddingLeft\",\n \"paddingBlock\",\n \"paddingBlockStart\",\n \"paddingBlockEnd\",\n \"paddingInline\",\n \"paddingInlineStart\",\n \"paddingInlineEnd\",\n \"margin\",\n \"marginTop\",\n \"marginRight\",\n \"marginBottom\",\n \"marginLeft\",\n \"marginBlock\",\n \"marginBlockStart\",\n \"marginBlockEnd\",\n \"marginInline\",\n \"marginInlineStart\",\n \"marginInlineEnd\",\n // Typography\n \"fontSize\",\n // Misc\n \"backgroundPositionX\",\n \"backgroundPositionY\",\n])\n"],"names":[],"mappings":";;AAEO,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC;;IAE5B,aAAa;IACb,gBAAgB;IAChB,kBAAkB;IAClB,mBAAmB;IACnB,iBAAiB;IACjB,cAAc;AACd,IAAA,GAAG,iBAAiB;;IAEpB,OAAO;IACP,UAAU;IACV,QAAQ;IACR,WAAW;IACX,KAAK;IACL,OAAO;IACP,QAAQ;IACR,MAAM;IACN,OAAO;IACP,YAAY;IACZ,iBAAiB;IACjB,eAAe;IACf,aAAa;IACb,kBAAkB;IAClB,gBAAgB;;IAEhB,SAAS;IACT,YAAY;IACZ,cAAc;IACd,eAAe;IACf,aAAa;IACb,cAAc;IACd,mBAAmB;IACnB,iBAAiB;IACjB,eAAe;IACf,oBAAoB;IACpB,kBAAkB;IAClB,QAAQ;IACR,WAAW;IACX,aAAa;IACb,cAAc;IACd,YAAY;IACZ,aAAa;IACb,kBAAkB;IAClB,gBAAgB;IAChB,cAAc;IACd,mBAAmB;IACnB,iBAAiB;;IAEjB,UAAU;;IAEV,qBAAqB;IACrB,qBAAqB;AACxB,CAAA;;;;"}
|
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
import { mixNumber } from '../../utils/mix/number.mjs';
|
|
2
2
|
import { percent, px } from '../../value/types/numbers/units.mjs';
|
|
3
3
|
import { progress, circOut, noop } from 'motion-utils';
|
|
4
|
+
import { cornerRadiusProps } from '../../utils/border-radius.mjs';
|
|
4
5
|
|
|
5
|
-
const
|
|
6
|
-
"borderTopLeftRadius",
|
|
7
|
-
"borderTopRightRadius",
|
|
8
|
-
"borderBottomLeftRadius",
|
|
9
|
-
"borderBottomRightRadius",
|
|
10
|
-
];
|
|
11
|
-
const numBorders = borderLabels.length;
|
|
6
|
+
const numBorders = cornerRadiusProps.length;
|
|
12
7
|
const asNumber = (value) => typeof value === "string" ? parseFloat(value) : value;
|
|
13
8
|
const isPx = (value) => typeof value === "number" || px.test(value);
|
|
14
9
|
function mixValues(target, follow, lead, progress, shouldCrossfadeOpacity, isOnlyMember) {
|
|
@@ -23,7 +18,7 @@ function mixValues(target, follow, lead, progress, shouldCrossfadeOpacity, isOnl
|
|
|
23
18
|
* Mix border radius
|
|
24
19
|
*/
|
|
25
20
|
for (let i = 0; i < numBorders; i++) {
|
|
26
|
-
const borderLabel =
|
|
21
|
+
const borderLabel = cornerRadiusProps[i];
|
|
27
22
|
let followRadius = getRadius(follow, borderLabel);
|
|
28
23
|
let leadRadius = getRadius(lead, borderLabel);
|
|
29
24
|
if (followRadius === undefined && leadRadius === undefined)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mix-values.mjs","sources":["../../../../src/projection/animation/mix-values.ts"],"sourcesContent":["import { mixNumber } from \"../../utils/mix/number\"\nimport { percent, px } from \"../../value/types/numbers/units\"\nimport type { AnyResolvedKeyframe } from \"../../animation/types\"\nimport {\n progress as calcProgress,\n circOut,\n EasingFunction,\n noop,\n} from \"motion-utils\"\nimport type { ResolvedValues } from \"../../node/types\"\
|
|
1
|
+
{"version":3,"file":"mix-values.mjs","sources":["../../../../src/projection/animation/mix-values.ts"],"sourcesContent":["import { mixNumber } from \"../../utils/mix/number\"\nimport { percent, px } from \"../../value/types/numbers/units\"\nimport type { AnyResolvedKeyframe } from \"../../animation/types\"\nimport {\n progress as calcProgress,\n circOut,\n EasingFunction,\n noop,\n} from \"motion-utils\"\nimport type { ResolvedValues } from \"../../node/types\"\nimport { cornerRadiusProps } from \"../../utils/border-radius\"\n\nconst numBorders = cornerRadiusProps.length\n\nconst asNumber = (value: AnyResolvedKeyframe) =>\n typeof value === \"string\" ? parseFloat(value) : value\n\nconst isPx = (value: AnyResolvedKeyframe) =>\n typeof value === \"number\" || px.test(value)\n\nexport function mixValues(\n target: ResolvedValues,\n follow: ResolvedValues,\n lead: ResolvedValues,\n progress: number,\n shouldCrossfadeOpacity: boolean,\n isOnlyMember: boolean\n) {\n if (shouldCrossfadeOpacity) {\n target.opacity = mixNumber(\n 0,\n (lead.opacity as number) ?? 1,\n easeCrossfadeIn(progress)\n )\n target.opacityExit = mixNumber(\n (follow.opacity as number) ?? 1,\n 0,\n easeCrossfadeOut(progress)\n )\n } else if (isOnlyMember) {\n target.opacity = mixNumber(\n (follow.opacity as number) ?? 1,\n (lead.opacity as number) ?? 1,\n progress\n )\n }\n\n /**\n * Mix border radius\n */\n for (let i = 0; i < numBorders; i++) {\n const borderLabel = cornerRadiusProps[i]\n let followRadius = getRadius(follow, borderLabel)\n let leadRadius = getRadius(lead, borderLabel)\n\n if (followRadius === undefined && leadRadius === undefined) continue\n\n followRadius ||= 0\n leadRadius ||= 0\n\n const canMix =\n followRadius === 0 ||\n leadRadius === 0 ||\n isPx(followRadius) === isPx(leadRadius)\n\n if (canMix) {\n target[borderLabel] = Math.max(\n mixNumber(\n asNumber(followRadius),\n asNumber(leadRadius),\n progress\n ),\n 0\n )\n\n if (percent.test(leadRadius) || percent.test(followRadius)) {\n target[borderLabel] += \"%\"\n }\n } else {\n target[borderLabel] = leadRadius\n }\n }\n\n /**\n * Mix rotation\n */\n if (follow.rotate || lead.rotate) {\n target.rotate = mixNumber(\n (follow.rotate as number) || 0,\n (lead.rotate as number) || 0,\n progress\n )\n }\n}\n\nfunction getRadius(values: ResolvedValues, radiusName: string) {\n return values[radiusName] !== undefined\n ? values[radiusName]\n : values.borderRadius\n}\n\nconst easeCrossfadeIn = /*@__PURE__*/ compress(0, 0.5, circOut)\nconst easeCrossfadeOut = /*@__PURE__*/ compress(0.5, 0.95, noop)\n\nfunction compress(\n min: number,\n max: number,\n easing: EasingFunction\n): EasingFunction {\n return (p: number) => {\n // Could replace ifs with clamp\n if (p < min) return 0\n if (p > max) return 1\n return easing(calcProgress(min, max, p))\n }\n}\n"],"names":["calcProgress"],"mappings":"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"}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import { isCSSVariableName } from '../../animation/utils/is-css-variable.mjs';
|
|
2
|
+
import { cornerRadiusProps } from '../../utils/border-radius.mjs';
|
|
2
3
|
import { correctBorderRadius } from './scale-border-radius.mjs';
|
|
3
4
|
import { correctBoxShadow } from './scale-box-shadow.mjs';
|
|
4
5
|
|
|
5
6
|
const scaleCorrectors = {
|
|
6
7
|
borderRadius: {
|
|
7
8
|
...correctBorderRadius,
|
|
8
|
-
applyTo: [
|
|
9
|
-
"borderTopLeftRadius",
|
|
10
|
-
"borderTopRightRadius",
|
|
11
|
-
"borderBottomLeftRadius",
|
|
12
|
-
"borderBottomRightRadius",
|
|
13
|
-
],
|
|
9
|
+
applyTo: [...cornerRadiusProps],
|
|
14
10
|
},
|
|
15
11
|
borderTopLeftRadius: correctBorderRadius,
|
|
16
12
|
borderTopRightRadius: correctBorderRadius,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scale-correction.mjs","sources":["../../../../src/projection/styles/scale-correction.ts"],"sourcesContent":["import { isCSSVariableName } from \"../../animation/utils/is-css-variable\"\nimport { correctBorderRadius } from \"./scale-border-radius\"\nimport { correctBoxShadow } from \"./scale-box-shadow\"\nimport type { ScaleCorrectorMap } from \"./types\"\n\nexport const scaleCorrectors: ScaleCorrectorMap = {\n borderRadius: {\n ...correctBorderRadius,\n applyTo: [
|
|
1
|
+
{"version":3,"file":"scale-correction.mjs","sources":["../../../../src/projection/styles/scale-correction.ts"],"sourcesContent":["import { isCSSVariableName } from \"../../animation/utils/is-css-variable\"\nimport { cornerRadiusProps } from \"../../utils/border-radius\"\nimport { correctBorderRadius } from \"./scale-border-radius\"\nimport { correctBoxShadow } from \"./scale-box-shadow\"\nimport type { ScaleCorrectorMap } from \"./types\"\n\nexport const scaleCorrectors: ScaleCorrectorMap = {\n borderRadius: {\n ...correctBorderRadius,\n applyTo: [...cornerRadiusProps],\n },\n borderTopLeftRadius: correctBorderRadius,\n borderTopRightRadius: correctBorderRadius,\n borderBottomLeftRadius: correctBorderRadius,\n borderBottomRightRadius: correctBorderRadius,\n boxShadow: correctBoxShadow,\n}\n\nexport function addScaleCorrector(correctors: ScaleCorrectorMap) {\n for (const key in correctors) {\n scaleCorrectors[key] = correctors[key]\n if (isCSSVariableName(key)) {\n scaleCorrectors[key].isCSSVariable = true\n }\n }\n}\n"],"names":[],"mappings":";;;;;AAMO,MAAM,eAAe,GAAsB;AAC9C,IAAA,YAAY,EAAE;AACV,QAAA,GAAG,mBAAmB;AACtB,QAAA,OAAO,EAAE,CAAC,GAAG,iBAAiB,CAAC;AAClC,KAAA;AACD,IAAA,mBAAmB,EAAE,mBAAmB;AACxC,IAAA,oBAAoB,EAAE,mBAAmB;AACzC,IAAA,sBAAsB,EAAE,mBAAmB;AAC3C,IAAA,uBAAuB,EAAE,mBAAmB;AAC5C,IAAA,SAAS,EAAE,gBAAgB;;AAGzB,SAAU,iBAAiB,CAAC,UAA6B,EAAA;AAC3D,IAAA,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE;QAC1B,eAAe,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC;AACtC,QAAA,IAAI,iBAAiB,CAAC,GAAG,CAAC,EAAE;AACxB,YAAA,eAAe,CAAC,GAAG,CAAC,CAAC,aAAa,GAAG,IAAI;QAC7C;IACJ;AACJ;;;;"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { invariant } from 'motion-utils';
|
|
1
2
|
import { isCSSVariableName } from '../../animation/utils/is-css-variable.mjs';
|
|
2
3
|
import { transformProps } from '../utils/keys-transform.mjs';
|
|
3
4
|
import { defaultTransformValue, readTransformValue } from '../dom/parse-transform.mjs';
|
|
@@ -16,6 +17,15 @@ class HTMLVisualElement extends DOMVisualElement {
|
|
|
16
17
|
this.type = "html";
|
|
17
18
|
this.renderInstance = renderHTML;
|
|
18
19
|
}
|
|
20
|
+
mount(instance) {
|
|
21
|
+
/**
|
|
22
|
+
* If a custom component forwards its ref to something other than a
|
|
23
|
+
* HTML/SVG element (a class instance, an imperative handle) there's
|
|
24
|
+
* nothing for Motion to style, measure or attach gestures to. #2777
|
|
25
|
+
*/
|
|
26
|
+
invariant(Boolean(instance.style), "motion.create() components must forward their ref to a HTML or SVG element", "custom-component-ref");
|
|
27
|
+
super.mount(instance);
|
|
28
|
+
}
|
|
19
29
|
readValueFromInstance(instance, key) {
|
|
20
30
|
if (transformProps.has(key)) {
|
|
21
31
|
return this.projection?.isProjecting
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HTMLVisualElement.mjs","sources":["../../../../src/render/html/HTMLVisualElement.ts"],"sourcesContent":["import type
|
|
1
|
+
{"version":3,"file":"HTMLVisualElement.mjs","sources":["../../../../src/render/html/HTMLVisualElement.ts"],"sourcesContent":["import { invariant, type Box } from \"motion-utils\"\nimport type { AnyResolvedKeyframe } from \"../../animation/types\"\nimport { isCSSVariableName } from \"../../animation/utils/is-css-variable\"\nimport type { MotionNodeOptions } from \"../../node/types\"\nimport { transformProps } from \"../utils/keys-transform\"\nimport {\n defaultTransformValue,\n readTransformValue,\n} from \"../dom/parse-transform\"\nimport { measureViewportBox } from \"../../projection/utils/measure\"\nimport { DOMVisualElement } from \"../dom/DOMVisualElement\"\nimport type { DOMVisualElementOptions } from \"../dom/types\"\nimport type { ResolvedValues, MotionConfigContextProps } from \"../types\"\nimport type { VisualElement } from \"../VisualElement\"\nimport { HTMLRenderState } from \"./types\"\nimport { buildHTMLStyles } from \"./utils/build-styles\"\nimport { renderHTML } from \"./utils/render\"\nimport { scrapeMotionValuesFromProps } from \"./utils/scrape-motion-values\"\n\nexport function getComputedStyle(element: HTMLElement) {\n return window.getComputedStyle(element)\n}\n\nexport class HTMLVisualElement extends DOMVisualElement<\n HTMLElement,\n HTMLRenderState,\n DOMVisualElementOptions\n> {\n type = \"html\"\n\n mount(instance: HTMLElement) {\n /**\n * If a custom component forwards its ref to something other than a\n * HTML/SVG element (a class instance, an imperative handle) there's\n * nothing for Motion to style, measure or attach gestures to. #2777\n */\n invariant(\n Boolean(instance.style),\n \"motion.create() components must forward their ref to a HTML or SVG element\",\n \"custom-component-ref\"\n )\n\n super.mount(instance)\n }\n\n readValueFromInstance(\n instance: HTMLElement,\n key: string\n ): AnyResolvedKeyframe | null | undefined {\n if (transformProps.has(key)) {\n return this.projection?.isProjecting\n ? defaultTransformValue(key)\n : readTransformValue(instance, key)\n } else {\n const computedStyle = getComputedStyle(instance)\n const value =\n (isCSSVariableName(key)\n ? computedStyle.getPropertyValue(key)\n : computedStyle[key as keyof typeof computedStyle]) || 0\n\n return typeof value === \"string\" ? value.trim() : (value as number)\n }\n }\n\n measureInstanceViewportBox(\n instance: HTMLElement,\n { transformPagePoint }: MotionNodeOptions & Partial<MotionConfigContextProps>\n ): Box {\n return measureViewportBox(instance, transformPagePoint)\n }\n\n build(\n renderState: HTMLRenderState,\n latestValues: ResolvedValues,\n props: MotionNodeOptions\n ) {\n buildHTMLStyles(renderState, latestValues, props.transformTemplate)\n }\n\n scrapeMotionValuesFromProps(\n props: MotionNodeOptions,\n prevProps: MotionNodeOptions,\n visualElement: VisualElement\n ) {\n return scrapeMotionValuesFromProps(props, prevProps, visualElement)\n }\n\n renderInstance = renderHTML\n}\n"],"names":[],"mappings":";;;;;;;;;;AAmBM,SAAU,gBAAgB,CAAC,OAAoB,EAAA;AACjD,IAAA,OAAO,MAAM,CAAC,gBAAgB,CAAC,OAAO,CAAC;AAC3C;AAEM,MAAO,iBAAkB,SAAQ,gBAItC,CAAA;AAJD,IAAA,WAAA,GAAA;;QAKI,IAAA,CAAA,IAAI,GAAG,MAAM;QA2Db,IAAA,CAAA,cAAc,GAAG,UAAU;IAC/B;AA1DI,IAAA,KAAK,CAAC,QAAqB,EAAA;AACvB;;;;AAIG;AACH,QAAA,SAAS,CACL,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EACvB,4EAA4E,EAC5E,sBAAsB,CACzB;AAED,QAAA,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC;IACzB;IAEA,qBAAqB,CACjB,QAAqB,EACrB,GAAW,EAAA;AAEX,QAAA,IAAI,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;AACzB,YAAA,OAAO,IAAI,CAAC,UAAU,EAAE;AACpB,kBAAE,qBAAqB,CAAC,GAAG;AAC3B,kBAAE,kBAAkB,CAAC,QAAQ,EAAE,GAAG,CAAC;QAC3C;aAAO;AACH,YAAA,MAAM,aAAa,GAAG,gBAAgB,CAAC,QAAQ,CAAC;AAChD,YAAA,MAAM,KAAK,GACP,CAAC,iBAAiB,CAAC,GAAG;AAClB,kBAAE,aAAa,CAAC,gBAAgB,CAAC,GAAG;kBAClC,aAAa,CAAC,GAAiC,CAAC,KAAK,CAAC;AAEhE,YAAA,OAAO,OAAO,KAAK,KAAK,QAAQ,GAAG,KAAK,CAAC,IAAI,EAAE,GAAI,KAAgB;QACvE;IACJ;AAEA,IAAA,0BAA0B,CACtB,QAAqB,EACrB,EAAE,kBAAkB,EAAyD,EAAA;AAE7E,QAAA,OAAO,kBAAkB,CAAC,QAAQ,EAAE,kBAAkB,CAAC;IAC3D;AAEA,IAAA,KAAK,CACD,WAA4B,EAC5B,YAA4B,EAC5B,KAAwB,EAAA;QAExB,eAAe,CAAC,WAAW,EAAE,YAAY,EAAE,KAAK,CAAC,iBAAiB,CAAC;IACvE;AAEA,IAAA,2BAA2B,CACvB,KAAwB,EACxB,SAA4B,EAC5B,aAA4B,EAAA;QAE5B,OAAO,2BAA2B,CAAC,KAAK,EAAE,SAAS,EAAE,aAAa,CAAC;IACvE;AAGH;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The four corner-radius longhands. Shared so the projection mixer, scale
|
|
3
|
+
* corrector, WAAPI px-value set and view-transition crop pass don't each carry
|
|
4
|
+
* their own copy. Order is irrelevant - every consumer mixes/corrects/animates
|
|
5
|
+
* each corner independently.
|
|
6
|
+
*/
|
|
7
|
+
const cornerRadiusProps = [
|
|
8
|
+
"borderTopLeftRadius",
|
|
9
|
+
"borderTopRightRadius",
|
|
10
|
+
"borderBottomRightRadius",
|
|
11
|
+
"borderBottomLeftRadius",
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
export { cornerRadiusProps };
|
|
15
|
+
//# sourceMappingURL=border-radius.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"border-radius.mjs","sources":["../../../src/utils/border-radius.ts"],"sourcesContent":["/**\n * The four corner-radius longhands. Shared so the projection mixer, scale\n * corrector, WAAPI px-value set and view-transition crop pass don't each carry\n * their own copy. Order is irrelevant - every consumer mixes/corrects/animates\n * each corner independently.\n */\nexport const cornerRadiusProps = [\n \"borderTopLeftRadius\",\n \"borderTopRightRadius\",\n \"borderBottomRightRadius\",\n \"borderBottomLeftRadius\",\n] as const\n"],"names":[],"mappings":"AAAA;;;;;AAKG;AACI,MAAM,iBAAiB,GAAG;IAC7B,qBAAqB;IACrB,sBAAsB;IACtB,yBAAyB;IACzB,wBAAwB;;;;;"}
|
package/dist/es/view/start.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { NativeAnimationWrapper } from '../animation/NativeAnimationWrapper.mjs'
|
|
|
5
5
|
import { getValueTransition } from '../animation/utils/get-value-transition.mjs';
|
|
6
6
|
import { mapEasingToNativeEasing } from '../animation/waapi/easing/map-easing.mjs';
|
|
7
7
|
import { applyGeneratorOptions } from '../animation/waapi/utils/apply-generator.mjs';
|
|
8
|
+
import { cornerRadiusProps } from '../utils/border-radius.mjs';
|
|
8
9
|
import { resolveElements } from '../utils/resolve-elements.mjs';
|
|
9
10
|
import { assignViewTransitionNames, releaseViewTransitionNames } from './utils/assign-names.mjs';
|
|
10
11
|
import { chooseLayerType } from './utils/choose-layer-type.mjs';
|
|
@@ -14,6 +15,12 @@ import { getViewAnimations } from './utils/get-view-animations.mjs';
|
|
|
14
15
|
import { hasTarget } from './utils/has-target.mjs';
|
|
15
16
|
|
|
16
17
|
const definitionNames = ["layout", "enter", "exit", "new", "old"];
|
|
18
|
+
/**
|
|
19
|
+
* Whether a computed border-radius is square (every component zero). Splitting
|
|
20
|
+
* on whitespace handles two-value/elliptical radii like "0px 20px" - a leading
|
|
21
|
+
* `parseFloat` alone would misread the non-zero vertical radius as square.
|
|
22
|
+
*/
|
|
23
|
+
const isSquareRadius = (radius) => radius.split(" ").every((value) => parseFloat(value) === 0);
|
|
17
24
|
/**
|
|
18
25
|
* The `ViewTransitionTarget` buckets driving each generated layer type, in
|
|
19
26
|
* priority order - the inverse of `chooseLayerType`. The new view is driven by
|
|
@@ -200,16 +207,48 @@ function startViewAnimation(builder) {
|
|
|
200
207
|
return transition;
|
|
201
208
|
};
|
|
202
209
|
/**
|
|
203
|
-
*
|
|
204
|
-
*
|
|
210
|
+
* Resolve a layer's group (`layout`) timing to plain WAAPI values: native
|
|
211
|
+
* ms `delay`/`duration` and a baked `ease`. The single source of group
|
|
212
|
+
* timing, shared by the generated-group retiming and the crop corner-radius
|
|
213
|
+
* pass so the rounded clip animates on exactly the box's timing. It returns
|
|
214
|
+
* no generator `type` (the WAAPI-only `NativeAnimation` rejects a string
|
|
215
|
+
* type) nor `repeat`/`times` (which the group's `updateTiming` ignores), so
|
|
216
|
+
* none of them can leak into the radius animation and desync it.
|
|
217
|
+
*/
|
|
218
|
+
const resolveGroupTiming = (name) => {
|
|
219
|
+
const [index, total] = staggerPosition(name, "group");
|
|
220
|
+
const transition = resolveLayerTransition(layerTargets.get(name), "group", "layout", index === -1 ? 0 : index, total);
|
|
221
|
+
transition.duration && (transition.duration = secondsToMilliseconds(transition.duration));
|
|
222
|
+
const { delay = 0, duration, ease } = applyGeneratorOptions(transition);
|
|
223
|
+
return { delay: secondsToMilliseconds(delay), duration, ease };
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* Each layer's measured box + corner radii per snapshot. The box lets
|
|
227
|
+
* `finalizeCrop` tell whether a morph's aspect ratio changed (the only case
|
|
228
|
+
* worth cropping); the radii let a cropped morph's group clip animate each
|
|
229
|
+
* corner from the old element's radius to the new element's, keeping it
|
|
230
|
+
* rounded where `overflow: clip` would otherwise square the corners.
|
|
231
|
+
*
|
|
232
|
+
* We never flatten the source for capture (a snapshot is a paint of the live
|
|
233
|
+
* DOM, so squaring an element just for its capture would flash one real
|
|
234
|
+
* square frame). For an aspect-changing morph `object-fit: cover` crops each
|
|
235
|
+
* snapshot's own baked corners off-screen mid-morph, so the animated clip is
|
|
236
|
+
* the only visible corner; a near-same-aspect forced crop (`.crop(true)`)
|
|
237
|
+
* can't hide the outgoing snapshot's silhouette, but the endpoints coincide.
|
|
205
238
|
*/
|
|
206
|
-
const
|
|
239
|
+
const cropMeasurements = new Map();
|
|
207
240
|
const measureLayers = (phase) => nameRegistry.forEach((name, element) => {
|
|
208
|
-
const
|
|
241
|
+
const el = element;
|
|
242
|
+
const rect = el.getBoundingClientRect?.();
|
|
209
243
|
if (rect && rect.height) {
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
|
|
244
|
+
const style = getComputedStyle(el);
|
|
245
|
+
const radii = {};
|
|
246
|
+
for (const corner of cornerRadiusProps) {
|
|
247
|
+
radii[corner] = style[corner];
|
|
248
|
+
}
|
|
249
|
+
const entry = cropMeasurements.get(name) ?? {};
|
|
250
|
+
entry[phase] = { width: rect.width, height: rect.height, radii };
|
|
251
|
+
cropMeasurements.set(name, entry);
|
|
213
252
|
}
|
|
214
253
|
});
|
|
215
254
|
/**
|
|
@@ -239,7 +278,7 @@ function startViewAnimation(builder) {
|
|
|
239
278
|
* never "changed".
|
|
240
279
|
*/
|
|
241
280
|
const aspectChanged = (name) => {
|
|
242
|
-
const box =
|
|
281
|
+
const box = cropMeasurements.get(name);
|
|
243
282
|
if (!box?.old || !box?.new || !box.old.height || !box.new.height) {
|
|
244
283
|
return false;
|
|
245
284
|
}
|
|
@@ -532,36 +571,85 @@ function startViewAnimation(builder) {
|
|
|
532
571
|
const isMorphCrossfade = (name.type === "old" || name.type === "new") &&
|
|
533
572
|
!!stagger?.old &&
|
|
534
573
|
!!stagger?.new;
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
574
|
+
let timing;
|
|
575
|
+
if (name.type.startsWith("group")) {
|
|
576
|
+
// group + group-children follow the resolved group
|
|
577
|
+
// timing - the single source shared with the crop
|
|
578
|
+
// corner-radius pass below.
|
|
579
|
+
const { delay, duration, ease } = resolveGroupTiming(name.layer);
|
|
580
|
+
timing = {
|
|
581
|
+
delay,
|
|
582
|
+
duration,
|
|
583
|
+
easing: mapEasingToNativeEasing(ease, duration),
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
else {
|
|
587
|
+
const timingType = isMorphCrossfade ? "group" : name.type;
|
|
588
|
+
const [index, total] = staggerPosition(name.layer, timingType);
|
|
589
|
+
const transitionName = timingType === "group" ? "layout" : "";
|
|
590
|
+
let animationTransition = resolveLayerTransition(targetDefinition, timingType, transitionName, index === -1 ? 0 : index, total);
|
|
591
|
+
/**
|
|
592
|
+
* The crossfade should resolve at the spring's
|
|
593
|
+
* *perceptual* (visual) duration - the geometry can keep
|
|
594
|
+
* bouncing, but the opacity shouldn't drag through the
|
|
595
|
+
* settle. So capture `visualDuration` before
|
|
596
|
+
* `applyGeneratorOptions` replaces it with the full
|
|
597
|
+
* overshoot duration, and use it for the fade.
|
|
598
|
+
*/
|
|
599
|
+
const visualDuration = animationTransition.visualDuration;
|
|
600
|
+
animationTransition.duration && (animationTransition.duration = secondsToMilliseconds(animationTransition.duration));
|
|
601
|
+
animationTransition =
|
|
602
|
+
applyGeneratorOptions(animationTransition);
|
|
603
|
+
timing = {
|
|
604
|
+
delay: secondsToMilliseconds(animationTransition.delay ?? 0),
|
|
605
|
+
duration: isMorphCrossfade && visualDuration !== undefined
|
|
606
|
+
? secondsToMilliseconds(visualDuration)
|
|
607
|
+
: animationTransition.duration,
|
|
608
|
+
easing: isMorphCrossfade
|
|
609
|
+
? "linear"
|
|
610
|
+
: mapEasingToNativeEasing(animationTransition.ease, animationTransition.duration),
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
effect.updateTiming(timing);
|
|
563
614
|
animations.push(new NativeAnimationWrapper(animation));
|
|
564
615
|
}
|
|
616
|
+
/**
|
|
617
|
+
* Round each cropped layer's clip. Its `::view-transition-group`
|
|
618
|
+
* has `overflow: clip`, which would otherwise square the corners
|
|
619
|
+
* mid-morph; animate each corner from the old element's radius to
|
|
620
|
+
* the new element's so the crop stays rounded. Timed as the group
|
|
621
|
+
* (`layout`) so the radius tracks the morphing box.
|
|
622
|
+
*/
|
|
623
|
+
cropMeasurements.forEach((entry, name) => {
|
|
624
|
+
if (!croppedNames.has(name))
|
|
625
|
+
return;
|
|
626
|
+
// Reuse the group's resolved timing - native ms delay/
|
|
627
|
+
// duration + a baked ease, with no generator `type` or
|
|
628
|
+
// repeat/times to leak into (or throw inside) NativeAnimation.
|
|
629
|
+
const { delay, duration, ease } = resolveGroupTiming(name);
|
|
630
|
+
for (const corner of cornerRadiusProps) {
|
|
631
|
+
// `||` (not `??`) so an empty measurement falls back to
|
|
632
|
+
// the other snapshot rather than an invalid keyframe.
|
|
633
|
+
const from = entry.old?.radii[corner] ||
|
|
634
|
+
entry.new?.radii[corner] ||
|
|
635
|
+
"0px";
|
|
636
|
+
const to = entry.new?.radii[corner] ||
|
|
637
|
+
entry.old?.radii[corner] ||
|
|
638
|
+
"0px";
|
|
639
|
+
// Nothing to round if the corner is square at both ends.
|
|
640
|
+
if (isSquareRadius(from) && isSquareRadius(to))
|
|
641
|
+
continue;
|
|
642
|
+
animations.push(new NativeAnimation({
|
|
643
|
+
element: document.documentElement,
|
|
644
|
+
name: corner,
|
|
645
|
+
pseudoElement: `::view-transition-group(${name})`,
|
|
646
|
+
keyframes: [from, to],
|
|
647
|
+
delay,
|
|
648
|
+
duration,
|
|
649
|
+
ease,
|
|
650
|
+
}));
|
|
651
|
+
}
|
|
652
|
+
});
|
|
565
653
|
resolve(new GroupAnimation(animations));
|
|
566
654
|
})
|
|
567
655
|
.catch(() =>
|