motion-dom 12.43.0 → 13.1.1-alpha.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 +85 -44
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/animation/waapi/supports/waapi.mjs +6 -3
- package/dist/es/animation/waapi/supports/waapi.mjs.map +1 -1
- package/dist/es/animation/waapi/utils/accelerated-values.mjs +12 -1
- package/dist/es/animation/waapi/utils/accelerated-values.mjs.map +1 -1
- package/dist/es/effects/style/index.mjs +11 -4
- package/dist/es/effects/style/index.mjs.map +1 -1
- package/dist/es/effects/style/transform.mjs +5 -0
- package/dist/es/effects/style/transform.mjs.map +1 -1
- package/dist/es/index.mjs +1 -1
- package/dist/es/projection/node/create-projection-node.mjs +13 -8
- package/dist/es/projection/node/create-projection-node.mjs.map +1 -1
- package/dist/es/projection/styles/transform.mjs +3 -1
- package/dist/es/projection/styles/transform.mjs.map +1 -1
- package/dist/es/projection/utils/has-transform.mjs +7 -1
- package/dist/es/projection/utils/has-transform.mjs.map +1 -1
- package/dist/es/render/VisualElement.mjs +5 -2
- package/dist/es/render/VisualElement.mjs.map +1 -1
- package/dist/es/render/html/utils/build-styles.mjs +10 -12
- package/dist/es/render/html/utils/build-styles.mjs.map +1 -1
- package/dist/es/render/html/utils/build-transform.mjs +5 -0
- package/dist/es/render/html/utils/build-transform.mjs.map +1 -1
- package/dist/es/render/svg/SVGVisualElement.mjs +7 -1
- package/dist/es/render/svg/SVGVisualElement.mjs.map +1 -1
- package/dist/es/render/svg/utils/build-attrs.mjs +9 -18
- package/dist/es/render/svg/utils/build-attrs.mjs.map +1 -1
- package/dist/es/value/index.mjs.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/motion-dom.dev.js +85 -44
- package/dist/motion-dom.js +1 -1
- package/dist/size-rollup-style-effect.js +1 -1
- package/dist/size-rollup-style-effect.js.map +1 -1
- package/package.json +3 -3
package/dist/cjs/index.js
CHANGED
|
@@ -2480,6 +2480,15 @@ const acceleratedValues = new Set([
|
|
|
2480
2480
|
"transform",
|
|
2481
2481
|
"backgroundColor",
|
|
2482
2482
|
]);
|
|
2483
|
+
function hasIndependentTransform(values) {
|
|
2484
|
+
if (!values)
|
|
2485
|
+
return false;
|
|
2486
|
+
for (const key in values) {
|
|
2487
|
+
if (transformProps.has(key))
|
|
2488
|
+
return true;
|
|
2489
|
+
}
|
|
2490
|
+
return false;
|
|
2491
|
+
}
|
|
2483
2492
|
|
|
2484
2493
|
const browserColorFunctions = /^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;
|
|
2485
2494
|
function hasBrowserOnlyColors(keyframes) {
|
|
@@ -2519,7 +2528,8 @@ function supportsBrowserAnimation(options) {
|
|
|
2519
2528
|
!(subject instanceof SVGElement)) {
|
|
2520
2529
|
return false;
|
|
2521
2530
|
}
|
|
2522
|
-
const
|
|
2531
|
+
const owner = motionValue.owner;
|
|
2532
|
+
const { onUpdate, transformTemplate } = owner.getProps();
|
|
2523
2533
|
return (supportsWaapi() &&
|
|
2524
2534
|
name &&
|
|
2525
2535
|
/**
|
|
@@ -2529,7 +2539,9 @@ function supportsBrowserAnimation(options) {
|
|
|
2529
2539
|
(acceleratedValues.has(name) ||
|
|
2530
2540
|
(colorProperties.has(name) &&
|
|
2531
2541
|
hasBrowserOnlyColors(keyframes))) &&
|
|
2532
|
-
(name !== "transform" ||
|
|
2542
|
+
(name !== "transform" ||
|
|
2543
|
+
(!transformTemplate &&
|
|
2544
|
+
!hasIndependentTransform(owner.latestValues))) &&
|
|
2533
2545
|
/**
|
|
2534
2546
|
* If we're outputting values to onUpdate then we can't use WAAPI as there's
|
|
2535
2547
|
* no way to read the value from WAAPI every frame.
|
|
@@ -4500,25 +4512,37 @@ function buildTransform$1(state) {
|
|
|
4500
4512
|
? `${pathRotation}deg`
|
|
4501
4513
|
: pathRotation}) `;
|
|
4502
4514
|
}
|
|
4515
|
+
const userTransform = state.latest.transform;
|
|
4516
|
+
if (userTransform && userTransform !== "none") {
|
|
4517
|
+
transformIsDefault = false;
|
|
4518
|
+
transform += userTransform;
|
|
4519
|
+
}
|
|
4503
4520
|
return transformIsDefault ? "none" : transform.trim();
|
|
4504
4521
|
}
|
|
4505
4522
|
|
|
4506
4523
|
const originProps = new Set(["originX", "originY", "originZ"]);
|
|
4524
|
+
/**
|
|
4525
|
+
* Internal key for the computed transform channel. The user "transform"
|
|
4526
|
+
* value now composes into this channel, so it can't share the "transform"
|
|
4527
|
+
* key. Prefixed with $ so it can never collide with a real style key
|
|
4528
|
+
* (like "transformStyle", which is the transform-style CSS property).
|
|
4529
|
+
*/
|
|
4530
|
+
const computedTransform = "$transform";
|
|
4507
4531
|
const addStyleValue = (element, state, key, value) => {
|
|
4508
4532
|
let render = undefined;
|
|
4509
4533
|
let computed = undefined;
|
|
4510
|
-
if (transformProps.has(key)) {
|
|
4511
|
-
if (!state.get(
|
|
4534
|
+
if (transformProps.has(key) || key === "transform") {
|
|
4535
|
+
if (!state.get(computedTransform)) {
|
|
4512
4536
|
// If this is an HTML element, we need to set the transform-box to fill-box
|
|
4513
4537
|
// to normalise the transform relative to the element's bounding box
|
|
4514
4538
|
if (!isHTMLElement(element) && !state.get("transformBox")) {
|
|
4515
4539
|
addStyleValue(element, state, "transformBox", new MotionValue("fill-box"));
|
|
4516
4540
|
}
|
|
4517
|
-
state.set(
|
|
4541
|
+
state.set(computedTransform, new MotionValue("none"), () => {
|
|
4518
4542
|
element.style.transform = buildTransform$1(state);
|
|
4519
4543
|
});
|
|
4520
4544
|
}
|
|
4521
|
-
computed = state.get(
|
|
4545
|
+
computed = state.get(computedTransform);
|
|
4522
4546
|
}
|
|
4523
4547
|
else if (originProps.has(key)) {
|
|
4524
4548
|
if (!state.get("transformOrigin")) {
|
|
@@ -6793,7 +6817,10 @@ class VisualElement {
|
|
|
6793
6817
|
}
|
|
6794
6818
|
if (value.accelerate &&
|
|
6795
6819
|
acceleratedValues.has(key) &&
|
|
6796
|
-
this.current instanceof HTMLElement
|
|
6820
|
+
this.current instanceof HTMLElement &&
|
|
6821
|
+
(key !== "transform" ||
|
|
6822
|
+
(!this.props.transformTemplate &&
|
|
6823
|
+
!hasIndependentTransform(this.latestValues)))) {
|
|
6797
6824
|
const { factory, keyframes, times, ease, duration } = value.accelerate;
|
|
6798
6825
|
const animation = new NativeAnimation({
|
|
6799
6826
|
element: this.current,
|
|
@@ -7188,6 +7215,12 @@ function hasTransform(values) {
|
|
|
7188
7215
|
values.skewX ||
|
|
7189
7216
|
values.skewY);
|
|
7190
7217
|
}
|
|
7218
|
+
function hasVisualTransform(values) {
|
|
7219
|
+
return (hasTransform(values) ||
|
|
7220
|
+
(values.transform &&
|
|
7221
|
+
values.transform !== "none" &&
|
|
7222
|
+
values.transform !== ""));
|
|
7223
|
+
}
|
|
7191
7224
|
function has2DTranslate(values) {
|
|
7192
7225
|
return is2DTranslate(values.x) || is2DTranslate(values.y);
|
|
7193
7226
|
}
|
|
@@ -7382,6 +7415,11 @@ function buildTransform(latestValues, transform, transformTemplate) {
|
|
|
7382
7415
|
transformIsDefault = false;
|
|
7383
7416
|
transformString += `rotate(${getValueAsType(pathRotation, numberValueTypes.pathRotation)}) `;
|
|
7384
7417
|
}
|
|
7418
|
+
const userTransform = latestValues.transform;
|
|
7419
|
+
if (userTransform && userTransform !== "none") {
|
|
7420
|
+
transformIsDefault = false;
|
|
7421
|
+
transformString += userTransform;
|
|
7422
|
+
}
|
|
7385
7423
|
transformString = transformString.trim();
|
|
7386
7424
|
// If we have a custom `transform` template, pass our transform values and
|
|
7387
7425
|
// generated transformString to that before returning
|
|
@@ -7407,7 +7445,7 @@ function buildHTMLStyles(state, latestValues, transformTemplate) {
|
|
|
7407
7445
|
*/
|
|
7408
7446
|
for (const key in latestValues) {
|
|
7409
7447
|
const value = latestValues[key];
|
|
7410
|
-
if (transformProps.has(key)) {
|
|
7448
|
+
if (transformProps.has(key) || key === "transform") {
|
|
7411
7449
|
// If this is a transform, flag to enable further transform processing
|
|
7412
7450
|
hasTransform = true;
|
|
7413
7451
|
continue;
|
|
@@ -7430,17 +7468,15 @@ function buildHTMLStyles(state, latestValues, transformTemplate) {
|
|
|
7430
7468
|
}
|
|
7431
7469
|
}
|
|
7432
7470
|
}
|
|
7433
|
-
if (
|
|
7434
|
-
|
|
7435
|
-
|
|
7436
|
-
|
|
7437
|
-
|
|
7438
|
-
|
|
7439
|
-
|
|
7440
|
-
|
|
7441
|
-
|
|
7442
|
-
style.transform = "none";
|
|
7443
|
-
}
|
|
7471
|
+
if (hasTransform || transformTemplate) {
|
|
7472
|
+
style.transform = buildTransform(latestValues, state.transform, transformTemplate);
|
|
7473
|
+
}
|
|
7474
|
+
else if (style.transform) {
|
|
7475
|
+
/**
|
|
7476
|
+
* If we have previously created a transform but currently don't have any,
|
|
7477
|
+
* reset transform style to none.
|
|
7478
|
+
*/
|
|
7479
|
+
style.transform = "none";
|
|
7444
7480
|
}
|
|
7445
7481
|
/**
|
|
7446
7482
|
* Build a transformOrigin style. Uses the same defaults as the browser for
|
|
@@ -7691,10 +7727,9 @@ function buildSVGPath(attrs, length, spacing = 1, offset = 0, useDashCase = true
|
|
|
7691
7727
|
attrs[keys.array] = `${length} ${spacing}`;
|
|
7692
7728
|
}
|
|
7693
7729
|
|
|
7694
|
-
|
|
7695
|
-
|
|
7696
|
-
|
|
7697
|
-
const cssMotionPathProperties = [
|
|
7730
|
+
const cssStyleProperties = [
|
|
7731
|
+
"transform",
|
|
7732
|
+
"opacity",
|
|
7698
7733
|
"offsetDistance",
|
|
7699
7734
|
"offsetPath",
|
|
7700
7735
|
"offsetRotate",
|
|
@@ -7720,13 +7755,11 @@ function buildSVGAttrs(state, { attrX, attrY, attrScale, pathLength, pathSpacing
|
|
|
7720
7755
|
state.attrs = state.style;
|
|
7721
7756
|
state.style = {};
|
|
7722
7757
|
const { attrs, style } = state;
|
|
7723
|
-
|
|
7724
|
-
|
|
7725
|
-
|
|
7726
|
-
|
|
7727
|
-
|
|
7728
|
-
style.transform = attrs.transform;
|
|
7729
|
-
delete attrs.transform;
|
|
7758
|
+
for (const key of cssStyleProperties) {
|
|
7759
|
+
if (attrs[key] !== undefined) {
|
|
7760
|
+
style[key] = attrs[key];
|
|
7761
|
+
delete attrs[key];
|
|
7762
|
+
}
|
|
7730
7763
|
}
|
|
7731
7764
|
if (style.transform || attrs.transformOrigin) {
|
|
7732
7765
|
style.transformOrigin = attrs.transformOrigin ?? "50% 50%";
|
|
@@ -7740,12 +7773,6 @@ function buildSVGAttrs(state, { attrX, attrY, attrScale, pathLength, pathSpacing
|
|
|
7740
7773
|
style.transformBox = styleProp?.transformBox ?? "fill-box";
|
|
7741
7774
|
delete attrs.transformBox;
|
|
7742
7775
|
}
|
|
7743
|
-
for (const key of cssMotionPathProperties) {
|
|
7744
|
-
if (attrs[key] !== undefined) {
|
|
7745
|
-
style[key] = attrs[key];
|
|
7746
|
-
delete attrs[key];
|
|
7747
|
-
}
|
|
7748
|
-
}
|
|
7749
7776
|
// Render attrX/attrY/attrScale as attributes
|
|
7750
7777
|
if (attrX !== undefined)
|
|
7751
7778
|
attrs.x = attrX;
|
|
@@ -7826,6 +7853,12 @@ class SVGVisualElement extends DOMVisualElement {
|
|
|
7826
7853
|
const defaultType = getDefaultValueType(key);
|
|
7827
7854
|
return defaultType ? defaultType.default || 0 : 0;
|
|
7828
7855
|
}
|
|
7856
|
+
if (cssStyleProperties.includes(key)) {
|
|
7857
|
+
const computedStyle = getComputedStyle(instance);
|
|
7858
|
+
const value = computedStyle[key];
|
|
7859
|
+
if (typeof value === "string" && value)
|
|
7860
|
+
return value.trim();
|
|
7861
|
+
}
|
|
7829
7862
|
key = !camelCaseAttributes.has(key) ? camelToDash(key) : key;
|
|
7830
7863
|
return instance.getAttribute(key);
|
|
7831
7864
|
}
|
|
@@ -8448,7 +8481,7 @@ function buildProjectionTransform(delta, treeScale, latestTransform) {
|
|
|
8448
8481
|
transform += `scale(${1 / treeScale.x}, ${1 / treeScale.y}) `;
|
|
8449
8482
|
}
|
|
8450
8483
|
if (latestTransform) {
|
|
8451
|
-
const { transformPerspective, rotate, pathRotation, rotateX, rotateY, skewX, skewY, } = latestTransform;
|
|
8484
|
+
const { transformPerspective, rotate, pathRotation, rotateX, rotateY, skewX, skewY, transform: userTransform, } = latestTransform;
|
|
8452
8485
|
if (transformPerspective)
|
|
8453
8486
|
transform = `perspective(${transformPerspective}px) ${transform}`;
|
|
8454
8487
|
if (rotate)
|
|
@@ -8464,6 +8497,8 @@ function buildProjectionTransform(delta, treeScale, latestTransform) {
|
|
|
8464
8497
|
transform += `skewX(${skewX}deg) `;
|
|
8465
8498
|
if (skewY)
|
|
8466
8499
|
transform += `skewY(${skewY}deg) `;
|
|
8500
|
+
if (userTransform && userTransform !== "none")
|
|
8501
|
+
transform += `${userTransform} `;
|
|
8467
8502
|
}
|
|
8468
8503
|
/**
|
|
8469
8504
|
* Apply scale to match the size of the element to the size we want it.
|
|
@@ -8707,14 +8742,14 @@ const transformAxes = ["", "X", "Y", "Z"];
|
|
|
8707
8742
|
*/
|
|
8708
8743
|
const animationTarget = 1000;
|
|
8709
8744
|
let id = 0;
|
|
8710
|
-
function resetDistortingTransform(key, visualElement, values, sharedAnimationValues) {
|
|
8745
|
+
function resetDistortingTransform(key, visualElement, values, sharedAnimationValues, resetValue = 0) {
|
|
8711
8746
|
const { latestValues } = visualElement;
|
|
8712
|
-
// Record the distorting transform and then temporarily
|
|
8747
|
+
// Record the distorting transform and then temporarily reset it
|
|
8713
8748
|
if (latestValues[key]) {
|
|
8714
8749
|
values[key] = latestValues[key];
|
|
8715
|
-
visualElement.setStaticValue(key,
|
|
8750
|
+
visualElement.setStaticValue(key, resetValue);
|
|
8716
8751
|
if (sharedAnimationValues) {
|
|
8717
|
-
sharedAnimationValues[key] =
|
|
8752
|
+
sharedAnimationValues[key] = resetValue;
|
|
8718
8753
|
}
|
|
8719
8754
|
}
|
|
8720
8755
|
}
|
|
@@ -9293,7 +9328,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
9293
9328
|
if (isResetRequested &&
|
|
9294
9329
|
this.instance &&
|
|
9295
9330
|
(hasProjection ||
|
|
9296
|
-
|
|
9331
|
+
hasVisualTransform(this.latestValues) ||
|
|
9297
9332
|
transformTemplateHasChanged)) {
|
|
9298
9333
|
resetTransform(this.instance, transformTemplateValue);
|
|
9299
9334
|
this.shouldResetTransform = false;
|
|
@@ -9961,7 +9996,8 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
9961
9996
|
latestValues.rotateY ||
|
|
9962
9997
|
latestValues.rotateZ ||
|
|
9963
9998
|
latestValues.skewX ||
|
|
9964
|
-
latestValues.skewY
|
|
9999
|
+
latestValues.skewY ||
|
|
10000
|
+
(latestValues.transform && latestValues.transform !== "none")) {
|
|
9965
10001
|
hasDistortingTransform = true;
|
|
9966
10002
|
}
|
|
9967
10003
|
// If there's no distorting values, we don't need to do any more.
|
|
@@ -9971,6 +10007,9 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
9971
10007
|
if (latestValues.z) {
|
|
9972
10008
|
resetDistortingTransform("z", visualElement, resetValues, this.animationValues);
|
|
9973
10009
|
}
|
|
10010
|
+
if (latestValues.transform && latestValues.transform !== "none") {
|
|
10011
|
+
resetDistortingTransform("transform", visualElement, resetValues, this.animationValues, "none");
|
|
10012
|
+
}
|
|
9974
10013
|
// Check the skew and rotate value of all axes and reset to 0
|
|
9975
10014
|
for (let i = 0; i < transformAxes.length; i++) {
|
|
9976
10015
|
resetDistortingTransform(`rotate${transformAxes[i]}`, visualElement, resetValues, this.animationValues);
|
|
@@ -10020,7 +10059,8 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
10020
10059
|
targetStyle.pointerEvents =
|
|
10021
10060
|
resolveMotionValue(styleProp?.pointerEvents) || "";
|
|
10022
10061
|
}
|
|
10023
|
-
if (this.hasProjected &&
|
|
10062
|
+
if (this.hasProjected &&
|
|
10063
|
+
!hasVisualTransform(this.latestValues)) {
|
|
10024
10064
|
targetStyle.transform = transformTemplate
|
|
10025
10065
|
? transformTemplate({}, "")
|
|
10026
10066
|
: "none";
|
|
@@ -10905,6 +10945,7 @@ exports.getViewAnimationLayerInfo = getViewAnimationLayerInfo;
|
|
|
10905
10945
|
exports.getViewAnimations = getViewAnimations;
|
|
10906
10946
|
exports.globalProjectionState = globalProjectionState;
|
|
10907
10947
|
exports.has2DTranslate = has2DTranslate;
|
|
10948
|
+
exports.hasIndependentTransform = hasIndependentTransform;
|
|
10908
10949
|
exports.hasReducedMotionListener = hasReducedMotionListener;
|
|
10909
10950
|
exports.hasScale = hasScale;
|
|
10910
10951
|
exports.hasTransform = hasTransform;
|