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.
@@ -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
- strokeWidth: true,
53
- opacity: true,
54
- fillOpacity: true,
55
- strokeOpacity: true,
56
- strokeLinecap: true,
57
- strokeLinejoin: true,
58
- strokeDasharray: true,
59
- strokeDashoffset: true,
60
- cx: true,
61
- cy: true,
62
- r: true,
63
- d: true,
64
- x1: true,
65
- y1: true,
66
- x2: true,
67
- y2: true,
68
- points: true,
69
- pathLength: true,
70
- viewBox: true,
71
- width: true,
72
- height: true,
73
- preserveAspectRatio: true,
74
- clipPath: true,
75
- filter: true,
76
- mask: true,
77
- stopColor: true,
78
- stopOpacity: true,
79
- gradientTransform: true,
80
- gradientUnits: true,
81
- spreadMethod: true,
82
- markerEnd: true,
83
- markerMid: true,
84
- markerStart: true,
85
- textAnchor: true,
86
- dominantBaseline: true,
87
- fontFamily: true,
88
- fontSize: true,
89
- fontWeight: true,
90
- letterSpacing: true,
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.pathLength = 1;
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
- if (key in SVG_STYLE_TO_ATTRIBUTES) {
106
+ const kebabKey = camelToKebab(key);
107
+ if (kebabKey in SVG_STYLE_TO_ATTRIBUTES) {
105
108
  const value = keyframes[key];
106
- attributes[key] = isMotionValue(value) ? value.get() : value;
109
+ attributes[kebabKey] = isMotionValue(value) ? value.get() : value;
107
110
  } else {
108
111
  styleProps[key] = keyframes[key];
109
112
  }
110
113
  }
111
- if (attributes.pathLength) {
112
- buildSVGPath(attributes, attributes.pathLength, attributes.pathSpacing, attributes.pathOffset);
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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "motion-v",
3
- "version": "1.0.0-alpha.2",
3
+ "version": "1.0.0-alpha.4",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "license": "MIT",