motion-dom 12.42.2 → 13.0.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 +31 -25
- 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/render/html/HTMLVisualElement.mjs +10 -0
- package/dist/es/render/html/HTMLVisualElement.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/index.d.ts +1 -0
- package/dist/motion-dom.dev.js +31 -25
- package/dist/motion-dom.js +1 -1
- package/package.json +3 -3
package/dist/cjs/index.js
CHANGED
|
@@ -2478,9 +2478,7 @@ const acceleratedValues = new Set([
|
|
|
2478
2478
|
"clipPath",
|
|
2479
2479
|
"filter",
|
|
2480
2480
|
"transform",
|
|
2481
|
-
|
|
2482
|
-
// or until we implement support for linear() easing.
|
|
2483
|
-
// "background-color"
|
|
2481
|
+
"backgroundColor",
|
|
2484
2482
|
]);
|
|
2485
2483
|
|
|
2486
2484
|
const browserColorFunctions = /^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;
|
|
@@ -2511,12 +2509,14 @@ function supportsBrowserAnimation(options) {
|
|
|
2511
2509
|
const { motionValue, name, repeatDelay, repeatType, damping, type, keyframes, } = options;
|
|
2512
2510
|
const subject = motionValue?.owner?.current;
|
|
2513
2511
|
/**
|
|
2514
|
-
* We use
|
|
2515
|
-
* **don't** want elements in different timing
|
|
2516
|
-
* to be accelerated, as it's not possible to sync
|
|
2517
|
-
* properly with those driven from the main window
|
|
2512
|
+
* We use instanceof checks instead of isHTMLElement()/isSVGElement()
|
|
2513
|
+
* because we explicitly **don't** want elements in different timing
|
|
2514
|
+
* contexts (i.e. popups) to be accelerated, as it's not possible to sync
|
|
2515
|
+
* these animations properly with those driven from the main window
|
|
2516
|
+
* frameloop.
|
|
2518
2517
|
*/
|
|
2519
|
-
if (!(subject instanceof HTMLElement)
|
|
2518
|
+
if (!(subject instanceof HTMLElement) &&
|
|
2519
|
+
!(subject instanceof SVGElement)) {
|
|
2520
2520
|
return false;
|
|
2521
2521
|
}
|
|
2522
2522
|
const { onUpdate, transformTemplate } = motionValue.owner.getProps();
|
|
@@ -7590,6 +7590,15 @@ class HTMLVisualElement extends DOMVisualElement {
|
|
|
7590
7590
|
this.type = "html";
|
|
7591
7591
|
this.renderInstance = renderHTML;
|
|
7592
7592
|
}
|
|
7593
|
+
mount(instance) {
|
|
7594
|
+
/**
|
|
7595
|
+
* If a custom component forwards its ref to something other than a
|
|
7596
|
+
* HTML/SVG element (a class instance, an imperative handle) there's
|
|
7597
|
+
* nothing for Motion to style, measure or attach gestures to. #2777
|
|
7598
|
+
*/
|
|
7599
|
+
motionUtils.invariant(Boolean(instance.style), "motion.create() components must forward their ref to a HTML or SVG element", "custom-component-ref");
|
|
7600
|
+
super.mount(instance);
|
|
7601
|
+
}
|
|
7593
7602
|
readValueFromInstance(instance, key) {
|
|
7594
7603
|
if (transformProps.has(key)) {
|
|
7595
7604
|
return this.projection?.isProjecting
|
|
@@ -7682,10 +7691,9 @@ function buildSVGPath(attrs, length, spacing = 1, offset = 0, useDashCase = true
|
|
|
7682
7691
|
attrs[keys.array] = `${length} ${spacing}`;
|
|
7683
7692
|
}
|
|
7684
7693
|
|
|
7685
|
-
|
|
7686
|
-
|
|
7687
|
-
|
|
7688
|
-
const cssMotionPathProperties = [
|
|
7694
|
+
const cssStyleProperties = [
|
|
7695
|
+
"transform",
|
|
7696
|
+
"opacity",
|
|
7689
7697
|
"offsetDistance",
|
|
7690
7698
|
"offsetPath",
|
|
7691
7699
|
"offsetRotate",
|
|
@@ -7711,13 +7719,11 @@ function buildSVGAttrs(state, { attrX, attrY, attrScale, pathLength, pathSpacing
|
|
|
7711
7719
|
state.attrs = state.style;
|
|
7712
7720
|
state.style = {};
|
|
7713
7721
|
const { attrs, style } = state;
|
|
7714
|
-
|
|
7715
|
-
|
|
7716
|
-
|
|
7717
|
-
|
|
7718
|
-
|
|
7719
|
-
style.transform = attrs.transform;
|
|
7720
|
-
delete attrs.transform;
|
|
7722
|
+
for (const key of cssStyleProperties) {
|
|
7723
|
+
if (attrs[key] !== undefined) {
|
|
7724
|
+
style[key] = attrs[key];
|
|
7725
|
+
delete attrs[key];
|
|
7726
|
+
}
|
|
7721
7727
|
}
|
|
7722
7728
|
if (style.transform || attrs.transformOrigin) {
|
|
7723
7729
|
style.transformOrigin = attrs.transformOrigin ?? "50% 50%";
|
|
@@ -7731,12 +7737,6 @@ function buildSVGAttrs(state, { attrX, attrY, attrScale, pathLength, pathSpacing
|
|
|
7731
7737
|
style.transformBox = styleProp?.transformBox ?? "fill-box";
|
|
7732
7738
|
delete attrs.transformBox;
|
|
7733
7739
|
}
|
|
7734
|
-
for (const key of cssMotionPathProperties) {
|
|
7735
|
-
if (attrs[key] !== undefined) {
|
|
7736
|
-
style[key] = attrs[key];
|
|
7737
|
-
delete attrs[key];
|
|
7738
|
-
}
|
|
7739
|
-
}
|
|
7740
7740
|
// Render attrX/attrY/attrScale as attributes
|
|
7741
7741
|
if (attrX !== undefined)
|
|
7742
7742
|
attrs.x = attrX;
|
|
@@ -7817,6 +7817,12 @@ class SVGVisualElement extends DOMVisualElement {
|
|
|
7817
7817
|
const defaultType = getDefaultValueType(key);
|
|
7818
7818
|
return defaultType ? defaultType.default || 0 : 0;
|
|
7819
7819
|
}
|
|
7820
|
+
if (cssStyleProperties.includes(key)) {
|
|
7821
|
+
const computedStyle = getComputedStyle(instance);
|
|
7822
|
+
const value = computedStyle[key];
|
|
7823
|
+
if (typeof value === "string" && value)
|
|
7824
|
+
return value.trim();
|
|
7825
|
+
}
|
|
7820
7826
|
key = !camelCaseAttributes.has(key) ? camelToDash(key) : key;
|
|
7821
7827
|
return instance.getAttribute(key);
|
|
7822
7828
|
}
|