motion-v 1.0.0-alpha.2 → 1.0.0-alpha.4
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/es/state/style.mjs
CHANGED
|
@@ -47,51 +47,53 @@ function createStyles(keyframes) {
|
|
|
47
47
|
return initialKeyframes;
|
|
48
48
|
}
|
|
49
49
|
const SVG_STYLE_TO_ATTRIBUTES = {
|
|
50
|
-
fill: true,
|
|
51
|
-
stroke: true,
|
|
52
|
-
|
|
53
|
-
opacity: true,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
vectorEffect: true
|
|
50
|
+
"fill": true,
|
|
51
|
+
"stroke": true,
|
|
52
|
+
"opacity": true,
|
|
53
|
+
"fill-opacity": true,
|
|
54
|
+
"stroke-opacity": true,
|
|
55
|
+
"stroke-linecap": true,
|
|
56
|
+
"stroke-linejoin": true,
|
|
57
|
+
"stroke-dasharray": true,
|
|
58
|
+
"stroke-dashoffset": true,
|
|
59
|
+
"cx": true,
|
|
60
|
+
"cy": true,
|
|
61
|
+
"r": true,
|
|
62
|
+
"d": true,
|
|
63
|
+
"x1": true,
|
|
64
|
+
"y1": true,
|
|
65
|
+
"x2": true,
|
|
66
|
+
"y2": true,
|
|
67
|
+
"points": true,
|
|
68
|
+
"path-length": true,
|
|
69
|
+
"viewBox": true,
|
|
70
|
+
"width": true,
|
|
71
|
+
"height": true,
|
|
72
|
+
"preserve-aspect-ratio": true,
|
|
73
|
+
"clip-path": true,
|
|
74
|
+
"filter": true,
|
|
75
|
+
"mask": true,
|
|
76
|
+
"stop-color": true,
|
|
77
|
+
"stop-opacity": true,
|
|
78
|
+
"gradient-transform": true,
|
|
79
|
+
"gradient-units": true,
|
|
80
|
+
"spread-method": true,
|
|
81
|
+
"marker-end": true,
|
|
82
|
+
"marker-mid": true,
|
|
83
|
+
"marker-start": true,
|
|
84
|
+
"text-anchor": true,
|
|
85
|
+
"dominant-baseline": true,
|
|
86
|
+
"font-family": true,
|
|
87
|
+
"font-size": true,
|
|
88
|
+
"font-weight": true,
|
|
89
|
+
"letter-spacing": true,
|
|
90
|
+
"vector-effect": true
|
|
92
91
|
};
|
|
92
|
+
function camelToKebab(str) {
|
|
93
|
+
return str.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
94
|
+
}
|
|
93
95
|
function buildSVGPath(attrs, length, spacing = 1, offset = 0) {
|
|
94
|
-
attrs
|
|
96
|
+
attrs["path-length"] = 1;
|
|
95
97
|
attrs["stroke-dashoffset"] = px.transform(-offset);
|
|
96
98
|
const pathLength = px.transform(length);
|
|
97
99
|
const pathSpacing = px.transform(spacing);
|
|
@@ -101,15 +103,16 @@ function convertSvgStyleToAttributes(keyframes) {
|
|
|
101
103
|
const attributes = {};
|
|
102
104
|
const styleProps = {};
|
|
103
105
|
for (const key in keyframes) {
|
|
104
|
-
|
|
106
|
+
const kebabKey = camelToKebab(key);
|
|
107
|
+
if (kebabKey in SVG_STYLE_TO_ATTRIBUTES) {
|
|
105
108
|
const value = keyframes[key];
|
|
106
|
-
attributes[
|
|
109
|
+
attributes[kebabKey] = isMotionValue(value) ? value.get() : value;
|
|
107
110
|
} else {
|
|
108
111
|
styleProps[key] = keyframes[key];
|
|
109
112
|
}
|
|
110
113
|
}
|
|
111
|
-
if (attributes
|
|
112
|
-
buildSVGPath(attributes, attributes
|
|
114
|
+
if (attributes["path-length"] !== void 0) {
|
|
115
|
+
buildSVGPath(attributes, attributes["path-length"], attributes["path-spacing"], attributes["path-offset"]);
|
|
113
116
|
}
|
|
114
117
|
return {
|
|
115
118
|
attributes,
|