Skip to content

Commit d82a03d

Browse files
feat: Support % length values in SVG CSS animations (#9011)
## Summary There was an issue with propagation of SVG dimensions before, which was finally fixed in [this](software-mansion/react-native-svg#2802) PR. Thanks to these changes, we are able to support `%` in the same way as for non-svg components and don't have to use the separate value struct `SVGLength`. ## Test plan I went through all SVG-related examples in the example app, adjusted descriptions stating that `%` aren't supported (which isn't true anymore) and tested that everything works as expected now. --------- Co-authored-by: Jakub Wiśniewski <119816982+wisniewskij@users.noreply.github.com>
1 parent 7938aa9 commit d82a03d

21 files changed

Lines changed: 132 additions & 221 deletions

File tree

apps/common-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"react-native-reanimated": "workspace:*",
4242
"react-native-safe-area-context": "5.6.1",
4343
"react-native-screens": "4.19.0-nightly-20251125-46052f31e",
44-
"react-native-svg": "15.14.0",
44+
"react-native-svg": "15.15.3",
4545
"react-native-worklets": "workspace:*",
4646
"react-strict-dom": "0.0.54"
4747
},

apps/common-app/src/apps/css/examples/animations/screens/animatedProperties/svg/Circle.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export default function CircleExample() {
6262
},
6363
{
6464
description:
65-
'Interpolation between absolute and relative values is **not supported** in SVG, thus the circle radius is changed **abruptly**',
65+
'Smoothly interpolates between an absolute and a percentage value by resolving them to the same unit',
6666
keyframes: {
6767
from: {
6868
r: 10,
@@ -106,7 +106,7 @@ export default function CircleExample() {
106106
},
107107
{
108108
description:
109-
'Interpolation between absolute and relative values is not supported in SVG, thus the circle position is changed abruptly',
109+
'Smoothly interpolates between an absolute and a percentage value by resolving them to the same unit',
110110
keyframes: {
111111
from: {
112112
cx: 50,
@@ -145,7 +145,7 @@ export default function CircleExample() {
145145
},
146146
{
147147
description:
148-
'Interpolation between absolute and relative values is not supported in SVG, thus the circle position is changed abruptly',
148+
'Smoothly interpolates between an absolute and a percentage value by resolving them to the same unit',
149149
keyframes: {
150150
from: {
151151
cy: 50,

apps/common-app/src/apps/css/examples/animations/screens/animatedProperties/svg/Ellipse.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export default function EllipseExample() {
5151
},
5252
{
5353
description:
54-
'Interpolation between absolute and relative values is **not supported** in SVG, thus the ellipse radii are changed **abruptly**',
54+
'Smoothly interpolates between absolute and percentage values by resolving them to the same unit',
5555
keyframes: {
5656
from: {
5757
rx: 10,
@@ -107,7 +107,7 @@ export default function EllipseExample() {
107107
},
108108
{
109109
description:
110-
'Interpolation between absolute and relative values is **not supported** in SVG, thus the horizontal radius is changed **abruptly**',
110+
'Smoothly interpolates between an absolute and a percentage value by resolving them to the same unit',
111111
keyframes: {
112112
from: {
113113
rx: 10,
@@ -146,7 +146,7 @@ export default function EllipseExample() {
146146
},
147147
{
148148
description:
149-
'Interpolation between absolute and relative values is **not supported** in SVG, thus the vertical radius is changed **abruptly**',
149+
'Smoothly interpolates between an absolute and a percentage value by resolving them to the same unit',
150150
keyframes: {
151151
from: {
152152
ry: 10,
@@ -190,7 +190,7 @@ export default function EllipseExample() {
190190
},
191191
{
192192
description:
193-
'Interpolation between absolute and relative values is not supported in SVG, thus the ellipse position is changed abruptly',
193+
'Smoothly interpolates between an absolute and a percentage value by resolving them to the same unit',
194194
keyframes: {
195195
from: {
196196
cx: 50,
@@ -229,7 +229,7 @@ export default function EllipseExample() {
229229
},
230230
{
231231
description:
232-
'Interpolation between absolute and relative values is not supported in SVG, thus the ellipse position is changed abruptly',
232+
'Smoothly interpolates between an absolute and a percentage value by resolving them to the same unit',
233233
keyframes: {
234234
from: {
235235
cy: 50,

apps/common-app/src/apps/css/examples/animations/screens/animatedProperties/svg/Image.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export default function ImageExample() {
6767
},
6868
{
6969
description:
70-
'Interpolation between absolute and relative values is **not supported** in SVG, thus the X position is changed **abruptly**',
70+
'Smoothly interpolates between an absolute and a percentage value by resolving them to the same unit',
7171
keyframes: {
7272
from: {
7373
x: 20,
@@ -107,7 +107,7 @@ export default function ImageExample() {
107107
},
108108
{
109109
description:
110-
'Interpolation between absolute and relative values is **not supported** in SVG, thus the Y position is changed **abruptly**',
110+
'Smoothly interpolates between an absolute and a percentage value by resolving them to the same unit',
111111
keyframes: {
112112
from: {
113113
y: 20,
@@ -159,7 +159,7 @@ export default function ImageExample() {
159159
},
160160
{
161161
description:
162-
'Interpolation between absolute and relative values is **not supported** in SVG, thus the width is changed **abruptly**',
162+
'Smoothly interpolates between an absolute and a percentage value by resolving them to the same unit',
163163
keyframes: {
164164
from: {
165165
width: 60,
@@ -200,7 +200,7 @@ export default function ImageExample() {
200200
},
201201
{
202202
description:
203-
'Interpolation between absolute and relative values is **not supported** in SVG, thus the height is changed **abruptly**',
203+
'Smoothly interpolates between an absolute and a percentage value by resolving them to the same unit',
204204
keyframes: {
205205
from: {
206206
height: 60,

apps/common-app/src/apps/css/examples/animations/screens/animatedProperties/svg/Line.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export default function LineExample() {
6161
},
6262
{
6363
description:
64-
'Interpolation between absolute and relative values is **not supported** in SVG, thus the start X position is changed **abruptly**',
64+
'Smoothly interpolates between an absolute and a percentage value by resolving them to the same unit',
6565
keyframes: {
6666
from: {
6767
x1: 20,
@@ -100,7 +100,7 @@ export default function LineExample() {
100100
},
101101
{
102102
description:
103-
'Interpolation between absolute and relative values is **not supported** in SVG, thus the start Y position is changed **abruptly**',
103+
'Smoothly interpolates between an absolute and a percentage value by resolving them to the same unit',
104104
keyframes: {
105105
from: {
106106
y1: 15,
@@ -144,7 +144,7 @@ export default function LineExample() {
144144
},
145145
{
146146
description:
147-
'Interpolation between absolute and relative values is **not supported** in SVG, thus the end X position is changed **abruptly**',
147+
'Smoothly interpolates between an absolute and a percentage value by resolving them to the same unit',
148148
keyframes: {
149149
from: {
150150
x2: 80,
@@ -183,7 +183,7 @@ export default function LineExample() {
183183
},
184184
{
185185
description:
186-
'Interpolation between absolute and relative values is **not supported** in SVG, thus the end Y position is changed **abruptly**',
186+
'Smoothly interpolates between an absolute and a percentage value by resolving them to the same unit',
187187
keyframes: {
188188
from: {
189189
y2: 85,

apps/common-app/src/apps/css/examples/animations/screens/animatedProperties/svg/Rect.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export default function RectExample() {
6161
},
6262
{
6363
description:
64-
'Interpolation between absolute and relative values is **not supported** in SVG, thus the X position is changed **abruptly**',
64+
'Smoothly interpolates between an absolute and a percentage value by resolving them to the same unit',
6565
keyframes: {
6666
from: {
6767
x: 20,
@@ -101,7 +101,7 @@ export default function RectExample() {
101101
},
102102
{
103103
description:
104-
'Interpolation between absolute and relative values is **not supported** in SVG, thus the Y position is changed **abruptly**',
104+
'Smoothly interpolates between an absolute and a percentage value by resolving them to the same unit',
105105
keyframes: {
106106
from: {
107107
y: 20,
@@ -153,7 +153,7 @@ export default function RectExample() {
153153
},
154154
{
155155
description:
156-
'Interpolation between absolute and relative values is **not supported** in SVG, thus the width is changed **abruptly**',
156+
'Smoothly interpolates between an absolute and a percentage value by resolving them to the same unit',
157157
keyframes: {
158158
from: {
159159
width: 60,
@@ -194,7 +194,7 @@ export default function RectExample() {
194194
},
195195
{
196196
description:
197-
'Interpolation between absolute and relative values is **not supported** in SVG, thus the height is changed **abruptly**',
197+
'Smoothly interpolates between an absolute and a percentage value by resolving them to the same unit',
198198
keyframes: {
199199
from: {
200200
height: 60,
@@ -239,7 +239,7 @@ export default function RectExample() {
239239
},
240240
{
241241
description:
242-
'Interpolation between absolute and relative values is **not supported** in SVG, thus the horizontal radius is changed **abruptly**',
242+
'Smoothly interpolates between an absolute and a percentage value by resolving them to the same unit',
243243
keyframes: {
244244
from: {
245245
rx: 5,
@@ -279,7 +279,7 @@ export default function RectExample() {
279279
},
280280
{
281281
description:
282-
'Interpolation between absolute and relative values is **not supported** in SVG, thus the vertical radius is changed **abruptly**',
282+
'Smoothly interpolates between an absolute and a percentage value by resolving them to the same unit',
283283
keyframes: {
284284
from: {
285285
ry: 5,

apps/common-app/src/apps/css/examples/animations/screens/animatedProperties/svg/common/Stroke.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,34 @@ export default function StrokeExample() {
171171
},
172172
title: 'Array value with different number of elements',
173173
},
174+
{
175+
keyframes: {
176+
from: {
177+
strokeDasharray: ['10%', '5%'],
178+
},
179+
to: {
180+
strokeDasharray: ['25%', '12%'],
181+
},
182+
},
183+
props: {
184+
strokeWidth: 5,
185+
},
186+
title: 'Percentage values',
187+
},
188+
{
189+
keyframes: {
190+
from: {
191+
strokeDasharray: [8, '15%'],
192+
},
193+
to: {
194+
strokeDasharray: ['5%', 5],
195+
},
196+
},
197+
props: {
198+
strokeWidth: 5,
199+
},
200+
title: 'Mixed values (number + percentage)',
201+
},
174202
],
175203
title: 'strokeDasharray',
176204
},

docs/docs-reanimated/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"react-native": "0.83.0",
5858
"react-native-gesture-handler": "2.28.0",
5959
"react-native-reanimated": "4.2.0-nightly-20251017-235c127fd",
60-
"react-native-svg": "15.14.0",
60+
"react-native-svg": "15.15.3",
6161
"react-native-web": "0.21.2",
6262
"react-native-worklets": "0.7.0-nightly-20251015-0297d2990",
6363
"source-map": "0.7.4",

docs/docs-worklets/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"react-native": "0.83.0",
5959
"react-native-gesture-handler": "2.28.0",
6060
"react-native-reanimated": "4.2.0-nightly-20251017-235c127fd",
61-
"react-native-svg": "15.14.0",
61+
"react-native-svg": "15.15.3",
6262
"react-native-web": "0.21.2",
6363
"react-native-worklets": "0.7.0-nightly-20251015-0297d2990",
6464
"source-map": "0.7.4",

0 commit comments

Comments
 (0)