motion 12.8.0 → 12.8.2

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.
@@ -30,9 +30,6 @@ if (process.env.NODE_ENV !== "production") {
30
30
 
31
31
  const MotionGlobalConfig = {};
32
32
 
33
- /*#__NO_SIDE_EFFECTS__*/
34
- const noop = (any) => any;
35
-
36
33
  const LayoutGroupContext = react.createContext({});
37
34
 
38
35
  const LazyContext = react.createContext({ strict: false });
@@ -352,8 +349,6 @@ function createRenderBatcher(scheduleNextBatch, allowKeepAlive) {
352
349
  return { schedule, cancel, state, steps };
353
350
  }
354
351
 
355
- const { schedule: frame, cancel: cancelFrame, state: frameData, steps: frameSteps, } = /* @__PURE__ */ createRenderBatcher(typeof requestAnimationFrame !== "undefined" ? requestAnimationFrame : noop, true);
356
-
357
352
  const checkStringStartsWith = (token) => (key) => typeof key === "string" && key.startsWith(token);
358
353
  const isCSSVariableName =
359
354
  /*@__PURE__*/ checkStringStartsWith("--");
@@ -1111,25 +1106,10 @@ function buildSVGPath(attrs, length, spacing = 1, offset = 0, useDashCase = true
1111
1106
  attrs[keys.array] = `${pathLength} ${pathSpacing}`;
1112
1107
  }
1113
1108
 
1114
- function calcOrigin(origin, offset, size) {
1115
- return typeof origin === "string"
1116
- ? origin
1117
- : px.transform(offset + size * origin);
1118
- }
1119
- /**
1120
- * The SVG transform origin defaults are different to CSS and is less intuitive,
1121
- * so we use the measured dimensions of the SVG to reconcile these.
1122
- */
1123
- function calcSVGTransformOrigin(dimensions, originX, originY) {
1124
- const pxOriginX = calcOrigin(originX, dimensions.x, dimensions.width);
1125
- const pxOriginY = calcOrigin(originY, dimensions.y, dimensions.height);
1126
- return `${pxOriginX} ${pxOriginY}`;
1127
- }
1128
-
1129
1109
  /**
1130
1110
  * Build SVG visual attrbutes, like cx and style.transform
1131
1111
  */
1132
- function buildSVGAttrs(state, { attrX, attrY, attrScale, originX, originY, pathLength, pathSpacing = 1, pathOffset = 0,
1112
+ function buildSVGAttrs(state, { attrX, attrY, attrScale, pathLength, pathSpacing = 1, pathOffset = 0,
1133
1113
  // This is object creation, which we try to avoid per-frame.
1134
1114
  ...latest }, isSVGTag, transformTemplate) {
1135
1115
  buildHTMLStyles(state, latest, transformTemplate);
@@ -1145,20 +1125,26 @@ function buildSVGAttrs(state, { attrX, attrY, attrScale, originX, originY, pathL
1145
1125
  }
1146
1126
  state.attrs = state.style;
1147
1127
  state.style = {};
1148
- const { attrs, style, dimensions } = state;
1128
+ const { attrs, style } = state;
1149
1129
  /**
1150
- * However, we apply transforms as CSS transforms. So if we detect a transform we take it from attrs
1151
- * and copy it into style.
1130
+ * However, we apply transforms as CSS transforms.
1131
+ * So if we detect a transform, transformOrigin we take it from attrs and copy it into style.
1152
1132
  */
1153
1133
  if (attrs.transform) {
1154
- if (dimensions)
1155
- style.transform = attrs.transform;
1134
+ style.transform = attrs.transform;
1156
1135
  delete attrs.transform;
1157
1136
  }
1158
- // Parse transformOrigin
1159
- if (dimensions &&
1160
- (originX !== undefined || originY !== undefined || style.transform)) {
1161
- style.transformOrigin = calcSVGTransformOrigin(dimensions, originX !== undefined ? originX : 0.5, originY !== undefined ? originY : 0.5);
1137
+ if (style.transform || attrs.transformOrigin) {
1138
+ style.transformOrigin = attrs.transformOrigin ?? "50% 50%";
1139
+ delete attrs.transformOrigin;
1140
+ }
1141
+ if (style.transform) {
1142
+ /**
1143
+ * SVG's element transform-origin uses its own median as a reference.
1144
+ * Therefore, transformBox becomes a fill-box
1145
+ */
1146
+ style.transformBox = "fill-box";
1147
+ delete attrs.transformBox;
1162
1148
  }
1163
1149
  // Render attrX/attrY/attrScale as attributes
1164
1150
  if (attrX !== undefined)
@@ -1281,20 +1267,11 @@ function resolveMotionValue(value) {
1281
1267
  return isMotionValue(value) ? value.get() : value;
1282
1268
  }
1283
1269
 
1284
- function makeState({ scrapeMotionValuesFromProps, createRenderState, onUpdate, }, props, context, presenceContext) {
1270
+ function makeState({ scrapeMotionValuesFromProps, createRenderState, }, props, context, presenceContext) {
1285
1271
  const state = {
1286
1272
  latestValues: makeLatestValues(props, context, presenceContext, scrapeMotionValuesFromProps),
1287
1273
  renderState: createRenderState(),
1288
1274
  };
1289
- if (onUpdate) {
1290
- /**
1291
- * onMount works without the VisualElement because it could be
1292
- * called before the VisualElement payload has been hydrated.
1293
- * (e.g. if someone is using m components <m.circle />)
1294
- */
1295
- state.onMount = (instance) => onUpdate({ props, current: instance, ...state });
1296
- state.onUpdate = (visualElement) => onUpdate(visualElement);
1297
- }
1298
1275
  return state;
1299
1276
  }
1300
1277
  const makeUseVisualState = (config) => (props, isStatic) => {
@@ -1381,68 +1358,6 @@ const htmlMotionConfig = {
1381
1358
  }),
1382
1359
  };
1383
1360
 
1384
- function updateSVGDimensions(instance, renderState) {
1385
- try {
1386
- renderState.dimensions =
1387
- typeof instance.getBBox === "function"
1388
- ? instance.getBBox()
1389
- : instance.getBoundingClientRect();
1390
- }
1391
- catch (e) {
1392
- // Most likely trying to measure an unrendered element under Firefox
1393
- renderState.dimensions = {
1394
- x: 0,
1395
- y: 0,
1396
- width: 0,
1397
- height: 0,
1398
- };
1399
- }
1400
- }
1401
-
1402
- function renderHTML(element, { style, vars }, styleProp, projection) {
1403
- Object.assign(element.style, style, projection && projection.getProjectionStyles(styleProp));
1404
- // Loop over any CSS variables and assign those.
1405
- for (const key in vars) {
1406
- element.style.setProperty(key, vars[key]);
1407
- }
1408
- }
1409
-
1410
- /**
1411
- * A set of attribute names that are always read/written as camel case.
1412
- */
1413
- const camelCaseAttributes = new Set([
1414
- "baseFrequency",
1415
- "diffuseConstant",
1416
- "kernelMatrix",
1417
- "kernelUnitLength",
1418
- "keySplines",
1419
- "keyTimes",
1420
- "limitingConeAngle",
1421
- "markerHeight",
1422
- "markerWidth",
1423
- "numOctaves",
1424
- "targetX",
1425
- "targetY",
1426
- "surfaceScale",
1427
- "specularConstant",
1428
- "specularExponent",
1429
- "stdDeviation",
1430
- "tableValues",
1431
- "viewBox",
1432
- "gradientTransform",
1433
- "pathLength",
1434
- "startOffset",
1435
- "textLength",
1436
- "lengthAdjust",
1437
- ]);
1438
-
1439
- function renderSVG(element, renderState, _styleProp, projection) {
1440
- renderHTML(element, renderState, undefined, projection);
1441
- for (const key in renderState.attrs) {
1442
- element.setAttribute(!camelCaseAttributes.has(key) ? camelToDash(key) : key, renderState.attrs[key]);
1443
- }
1444
- }
1445
-
1446
1361
  function scrapeMotionValuesFromProps(props, prevProps, visualElement) {
1447
1362
  const newValues = scrapeMotionValuesFromProps$1(props, prevProps, visualElement);
1448
1363
  for (const key in props) {
@@ -1457,49 +1372,10 @@ function scrapeMotionValuesFromProps(props, prevProps, visualElement) {
1457
1372
  return newValues;
1458
1373
  }
1459
1374
 
1460
- const layoutProps = ["x", "y", "width", "height", "cx", "cy", "r"];
1461
1375
  const svgMotionConfig = {
1462
1376
  useVisualState: makeUseVisualState({
1463
1377
  scrapeMotionValuesFromProps: scrapeMotionValuesFromProps,
1464
1378
  createRenderState: createSvgRenderState,
1465
- onUpdate: ({ props, prevProps, current, renderState, latestValues, }) => {
1466
- if (!current)
1467
- return;
1468
- let hasTransform = !!props.drag;
1469
- if (!hasTransform) {
1470
- for (const key in latestValues) {
1471
- if (transformProps.has(key)) {
1472
- hasTransform = true;
1473
- break;
1474
- }
1475
- }
1476
- }
1477
- if (!hasTransform)
1478
- return;
1479
- let needsMeasure = !prevProps;
1480
- if (prevProps) {
1481
- /**
1482
- * Check the layout props for changes, if any are found we need to
1483
- * measure the element again.
1484
- */
1485
- for (let i = 0; i < layoutProps.length; i++) {
1486
- const key = layoutProps[i];
1487
- if (props[key] !==
1488
- prevProps[key]) {
1489
- needsMeasure = true;
1490
- }
1491
- }
1492
- }
1493
- if (!needsMeasure)
1494
- return;
1495
- frame.read(() => {
1496
- updateSVGDimensions(current, renderState);
1497
- frame.render(() => {
1498
- buildSVGAttrs(renderState, latestValues, isSVGTag(current.tagName), props.transformTemplate);
1499
- renderSVG(current, renderState);
1500
- });
1501
- });
1502
- },
1503
1379
  }),
1504
1380
  };
1505
1381
 
@@ -7,20 +7,11 @@ import { resolveVariantFromProps } from '../../render/utils/resolve-variants.mjs
7
7
  import { useConstant } from '../../utils/use-constant.mjs';
8
8
  import { resolveMotionValue } from '../../value/utils/resolve-motion-value.mjs';
9
9
 
10
- function makeState({ scrapeMotionValuesFromProps, createRenderState, onUpdate, }, props, context, presenceContext) {
10
+ function makeState({ scrapeMotionValuesFromProps, createRenderState, }, props, context, presenceContext) {
11
11
  const state = {
12
12
  latestValues: makeLatestValues(props, context, presenceContext, scrapeMotionValuesFromProps),
13
13
  renderState: createRenderState(),
14
14
  };
15
- if (onUpdate) {
16
- /**
17
- * onMount works without the VisualElement because it could be
18
- * called before the VisualElement payload has been hydrated.
19
- * (e.g. if someone is using m components <m.circle />)
20
- */
21
- state.onMount = (instance) => onUpdate({ props, current: instance, ...state });
22
- state.onUpdate = (visualElement) => onUpdate(visualElement);
23
- }
24
15
  return state;
25
16
  }
26
17
  const makeUseVisualState = (config) => (props, isStatic) => {
@@ -114,8 +114,7 @@ class VisualElement {
114
114
  frame.render(this.render, false, true);
115
115
  }
116
116
  };
117
- const { latestValues, renderState, onUpdate } = visualState;
118
- this.onUpdate = onUpdate;
117
+ const { latestValues, renderState } = visualState;
119
118
  this.latestValues = latestValues;
120
119
  this.baseTarget = { ...latestValues };
121
120
  this.initialValues = props.initial ? { ...latestValues } : {};
@@ -317,7 +316,6 @@ class VisualElement {
317
316
  if (this.handleChildMotionValue) {
318
317
  this.handleChildMotionValue();
319
318
  }
320
- this.onUpdate && this.onUpdate(this);
321
319
  }
322
320
  getProps() {
323
321
  return this.props;
@@ -4,12 +4,10 @@ import { camelToDash } from '../dom/utils/camel-to-dash.mjs';
4
4
  import { buildSVGAttrs } from './utils/build-attrs.mjs';
5
5
  import { camelCaseAttributes } from './utils/camel-case-attrs.mjs';
6
6
  import { isSVGTag } from './utils/is-svg-tag.mjs';
7
- import { updateSVGDimensions } from './utils/measure.mjs';
8
7
  import { renderSVG } from './utils/render.mjs';
9
8
  import { scrapeMotionValuesFromProps } from './utils/scrape-motion-values.mjs';
10
9
  import { transformProps } from '../../../../../motion-dom/dist/es/render/utils/keys-transform.mjs';
11
10
  import { getDefaultValueType } from '../../../../../motion-dom/dist/es/value/types/maps/defaults.mjs';
12
- import { frame } from '../../../../../motion-dom/dist/es/frameloop/frame.mjs';
13
11
 
14
12
  class SVGVisualElement extends DOMVisualElement {
15
13
  constructor() {
@@ -17,11 +15,6 @@ class SVGVisualElement extends DOMVisualElement {
17
15
  this.type = "svg";
18
16
  this.isSVGTag = false;
19
17
  this.measureInstanceViewportBox = createBox;
20
- this.updateDimensions = () => {
21
- if (this.current && !this.renderState.dimensions) {
22
- updateSVGDimensions(this.current, this.renderState);
23
- }
24
- };
25
18
  }
26
19
  getBaseTargetFromProps(props, key) {
27
20
  return props[key];
@@ -37,11 +30,6 @@ class SVGVisualElement extends DOMVisualElement {
37
30
  scrapeMotionValuesFromProps(props, prevProps, visualElement) {
38
31
  return scrapeMotionValuesFromProps(props, prevProps, visualElement);
39
32
  }
40
- onBindTransform() {
41
- if (this.current && !this.renderState.dimensions) {
42
- frame.postRender(this.updateDimensions);
43
- }
44
- }
45
33
  build(renderState, latestValues, props) {
46
34
  buildSVGAttrs(renderState, latestValues, this.isSVGTag, props.transformTemplate);
47
35
  }
@@ -1,56 +1,11 @@
1
1
  import { makeUseVisualState } from '../../motion/utils/use-visual-state.mjs';
2
- import { buildSVGAttrs } from './utils/build-attrs.mjs';
3
2
  import { createSvgRenderState } from './utils/create-render-state.mjs';
4
- import { isSVGTag } from './utils/is-svg-tag.mjs';
5
- import { updateSVGDimensions } from './utils/measure.mjs';
6
- import { renderSVG } from './utils/render.mjs';
7
3
  import { scrapeMotionValuesFromProps } from './utils/scrape-motion-values.mjs';
8
- import { transformProps } from '../../../../../motion-dom/dist/es/render/utils/keys-transform.mjs';
9
- import { frame } from '../../../../../motion-dom/dist/es/frameloop/frame.mjs';
10
4
 
11
- const layoutProps = ["x", "y", "width", "height", "cx", "cy", "r"];
12
5
  const svgMotionConfig = {
13
6
  useVisualState: makeUseVisualState({
14
7
  scrapeMotionValuesFromProps: scrapeMotionValuesFromProps,
15
8
  createRenderState: createSvgRenderState,
16
- onUpdate: ({ props, prevProps, current, renderState, latestValues, }) => {
17
- if (!current)
18
- return;
19
- let hasTransform = !!props.drag;
20
- if (!hasTransform) {
21
- for (const key in latestValues) {
22
- if (transformProps.has(key)) {
23
- hasTransform = true;
24
- break;
25
- }
26
- }
27
- }
28
- if (!hasTransform)
29
- return;
30
- let needsMeasure = !prevProps;
31
- if (prevProps) {
32
- /**
33
- * Check the layout props for changes, if any are found we need to
34
- * measure the element again.
35
- */
36
- for (let i = 0; i < layoutProps.length; i++) {
37
- const key = layoutProps[i];
38
- if (props[key] !==
39
- prevProps[key]) {
40
- needsMeasure = true;
41
- }
42
- }
43
- }
44
- if (!needsMeasure)
45
- return;
46
- frame.read(() => {
47
- updateSVGDimensions(current, renderState);
48
- frame.render(() => {
49
- buildSVGAttrs(renderState, latestValues, isSVGTag(current.tagName), props.transformTemplate);
50
- renderSVG(current, renderState);
51
- });
52
- });
53
- },
54
9
  }),
55
10
  };
56
11
 
@@ -1,11 +1,10 @@
1
1
  import { buildHTMLStyles } from '../../html/utils/build-styles.mjs';
2
2
  import { buildSVGPath } from './path.mjs';
3
- import { calcSVGTransformOrigin } from './transform-origin.mjs';
4
3
 
5
4
  /**
6
5
  * Build SVG visual attrbutes, like cx and style.transform
7
6
  */
8
- function buildSVGAttrs(state, { attrX, attrY, attrScale, originX, originY, pathLength, pathSpacing = 1, pathOffset = 0,
7
+ function buildSVGAttrs(state, { attrX, attrY, attrScale, pathLength, pathSpacing = 1, pathOffset = 0,
9
8
  // This is object creation, which we try to avoid per-frame.
10
9
  ...latest }, isSVGTag, transformTemplate) {
11
10
  buildHTMLStyles(state, latest, transformTemplate);
@@ -21,20 +20,26 @@ function buildSVGAttrs(state, { attrX, attrY, attrScale, originX, originY, pathL
21
20
  }
22
21
  state.attrs = state.style;
23
22
  state.style = {};
24
- const { attrs, style, dimensions } = state;
23
+ const { attrs, style } = state;
25
24
  /**
26
- * However, we apply transforms as CSS transforms. So if we detect a transform we take it from attrs
27
- * and copy it into style.
25
+ * However, we apply transforms as CSS transforms.
26
+ * So if we detect a transform, transformOrigin we take it from attrs and copy it into style.
28
27
  */
29
28
  if (attrs.transform) {
30
- if (dimensions)
31
- style.transform = attrs.transform;
29
+ style.transform = attrs.transform;
32
30
  delete attrs.transform;
33
31
  }
34
- // Parse transformOrigin
35
- if (dimensions &&
36
- (originX !== undefined || originY !== undefined || style.transform)) {
37
- style.transformOrigin = calcSVGTransformOrigin(dimensions, originX !== undefined ? originX : 0.5, originY !== undefined ? originY : 0.5);
32
+ if (style.transform || attrs.transformOrigin) {
33
+ style.transformOrigin = attrs.transformOrigin ?? "50% 50%";
34
+ delete attrs.transformOrigin;
35
+ }
36
+ if (style.transform) {
37
+ /**
38
+ * SVG's element transform-origin uses its own median as a reference.
39
+ * Therefore, transformBox becomes a fill-box
40
+ */
41
+ style.transformBox = "fill-box";
42
+ delete attrs.transformBox;
38
43
  }
39
44
  // Render attrX/attrY/attrScale as attributes
40
45
  if (attrX !== undefined)
@@ -17,7 +17,7 @@ function updateMotionValuesFromProps(element, next, prev) {
17
17
  * and warn against mismatches.
18
18
  */
19
19
  if (process.env.NODE_ENV === "development") {
20
- warnOnce(nextValue.version === "12.8.0", `Attempting to mix Motion versions ${nextValue.version} with 12.8.0 may not work as expected.`);
20
+ warnOnce(nextValue.version === "12.8.2", `Attempting to mix Motion versions ${nextValue.version} with 12.8.2 may not work as expected.`);
21
21
  }
22
22
  }
23
23
  else if (isMotionValue(prevValue)) {
@@ -32,7 +32,7 @@ class MotionValue {
32
32
  * This will be replaced by the build step with the latest version number.
33
33
  * When MotionValues are provided to motion components, warn if versions are mixed.
34
34
  */
35
- this.version = "12.8.0";
35
+ this.version = "12.8.1";
36
36
  /**
37
37
  * Tracks whether this value can output a velocity. Currently this is only true
38
38
  * if the value is numerical, but we might be able to widen the scope here and support
@@ -176,8 +176,6 @@ class MotionValue {
176
176
  * @public
177
177
  */
178
178
  set(v, render = true) {
179
- if (v === "none")
180
- console.trace();
181
179
  if (!render || !this.passiveEffect) {
182
180
  this.updateAndNotify(v, render);
183
181
  }
@@ -3777,7 +3777,7 @@
3777
3777
  * This will be replaced by the build step with the latest version number.
3778
3778
  * When MotionValues are provided to motion components, warn if versions are mixed.
3779
3779
  */
3780
- this.version = "12.8.0";
3780
+ this.version = "12.8.1";
3781
3781
  /**
3782
3782
  * Tracks whether this value can output a velocity. Currently this is only true
3783
3783
  * if the value is numerical, but we might be able to widen the scope here and support
@@ -3921,8 +3921,6 @@
3921
3921
  * @public
3922
3922
  */
3923
3923
  set(v, render = true) {
3924
- if (v === "none")
3925
- console.trace();
3926
3924
  if (!render || !this.passiveEffect) {
3927
3925
  this.updateAndNotify(v, render);
3928
3926
  }
@@ -5240,7 +5238,7 @@
5240
5238
  * and warn against mismatches.
5241
5239
  */
5242
5240
  {
5243
- warnOnce(nextValue.version === "12.8.0", `Attempting to mix Motion versions ${nextValue.version} with 12.8.0 may not work as expected.`);
5241
+ warnOnce(nextValue.version === "12.8.2", `Attempting to mix Motion versions ${nextValue.version} with 12.8.2 may not work as expected.`);
5244
5242
  }
5245
5243
  }
5246
5244
  else if (isMotionValue(prevValue)) {
@@ -5373,8 +5371,7 @@
5373
5371
  frame.render(this.render, false, true);
5374
5372
  }
5375
5373
  };
5376
- const { latestValues, renderState, onUpdate } = visualState;
5377
- this.onUpdate = onUpdate;
5374
+ const { latestValues, renderState } = visualState;
5378
5375
  this.latestValues = latestValues;
5379
5376
  this.baseTarget = { ...latestValues };
5380
5377
  this.initialValues = props.initial ? { ...latestValues } : {};
@@ -5576,7 +5573,6 @@
5576
5573
  if (this.handleChildMotionValue) {
5577
5574
  this.handleChildMotionValue();
5578
5575
  }
5579
- this.onUpdate && this.onUpdate(this);
5580
5576
  }
5581
5577
  getProps() {
5582
5578
  return this.props;
@@ -5918,25 +5914,10 @@
5918
5914
  attrs[keys.array] = `${pathLength} ${pathSpacing}`;
5919
5915
  }
5920
5916
 
5921
- function calcOrigin(origin, offset, size) {
5922
- return typeof origin === "string"
5923
- ? origin
5924
- : px.transform(offset + size * origin);
5925
- }
5926
- /**
5927
- * The SVG transform origin defaults are different to CSS and is less intuitive,
5928
- * so we use the measured dimensions of the SVG to reconcile these.
5929
- */
5930
- function calcSVGTransformOrigin(dimensions, originX, originY) {
5931
- const pxOriginX = calcOrigin(originX, dimensions.x, dimensions.width);
5932
- const pxOriginY = calcOrigin(originY, dimensions.y, dimensions.height);
5933
- return `${pxOriginX} ${pxOriginY}`;
5934
- }
5935
-
5936
5917
  /**
5937
5918
  * Build SVG visual attrbutes, like cx and style.transform
5938
5919
  */
5939
- function buildSVGAttrs(state, { attrX, attrY, attrScale, originX, originY, pathLength, pathSpacing = 1, pathOffset = 0,
5920
+ function buildSVGAttrs(state, { attrX, attrY, attrScale, pathLength, pathSpacing = 1, pathOffset = 0,
5940
5921
  // This is object creation, which we try to avoid per-frame.
5941
5922
  ...latest }, isSVGTag, transformTemplate) {
5942
5923
  buildHTMLStyles(state, latest, transformTemplate);
@@ -5952,20 +5933,26 @@
5952
5933
  }
5953
5934
  state.attrs = state.style;
5954
5935
  state.style = {};
5955
- const { attrs, style, dimensions } = state;
5936
+ const { attrs, style } = state;
5956
5937
  /**
5957
- * However, we apply transforms as CSS transforms. So if we detect a transform we take it from attrs
5958
- * and copy it into style.
5938
+ * However, we apply transforms as CSS transforms.
5939
+ * So if we detect a transform, transformOrigin we take it from attrs and copy it into style.
5959
5940
  */
5960
5941
  if (attrs.transform) {
5961
- if (dimensions)
5962
- style.transform = attrs.transform;
5942
+ style.transform = attrs.transform;
5963
5943
  delete attrs.transform;
5964
5944
  }
5965
- // Parse transformOrigin
5966
- if (dimensions &&
5967
- (originX !== undefined || originY !== undefined || style.transform)) {
5968
- style.transformOrigin = calcSVGTransformOrigin(dimensions, originX !== undefined ? originX : 0.5, originY !== undefined ? originY : 0.5);
5945
+ if (style.transform || attrs.transformOrigin) {
5946
+ style.transformOrigin = attrs.transformOrigin ?? "50% 50%";
5947
+ delete attrs.transformOrigin;
5948
+ }
5949
+ if (style.transform) {
5950
+ /**
5951
+ * SVG's element transform-origin uses its own median as a reference.
5952
+ * Therefore, transformBox becomes a fill-box
5953
+ */
5954
+ style.transformBox = "fill-box";
5955
+ delete attrs.transformBox;
5969
5956
  }
5970
5957
  // Render attrX/attrY/attrScale as attributes
5971
5958
  if (attrX !== undefined)
@@ -6011,24 +5998,6 @@
6011
5998
 
6012
5999
  const isSVGTag = (tag) => typeof tag === "string" && tag.toLowerCase() === "svg";
6013
6000
 
6014
- function updateSVGDimensions(instance, renderState) {
6015
- try {
6016
- renderState.dimensions =
6017
- typeof instance.getBBox === "function"
6018
- ? instance.getBBox()
6019
- : instance.getBoundingClientRect();
6020
- }
6021
- catch (e) {
6022
- // Most likely trying to measure an unrendered element under Firefox
6023
- renderState.dimensions = {
6024
- x: 0,
6025
- y: 0,
6026
- width: 0,
6027
- height: 0,
6028
- };
6029
- }
6030
- }
6031
-
6032
6001
  function renderHTML(element, { style, vars }, styleProp, projection) {
6033
6002
  Object.assign(element.style, style, projection && projection.getProjectionStyles(styleProp));
6034
6003
  // Loop over any CSS variables and assign those.
@@ -6088,11 +6057,6 @@
6088
6057
  this.type = "svg";
6089
6058
  this.isSVGTag = false;
6090
6059
  this.measureInstanceViewportBox = createBox;
6091
- this.updateDimensions = () => {
6092
- if (this.current && !this.renderState.dimensions) {
6093
- updateSVGDimensions(this.current, this.renderState);
6094
- }
6095
- };
6096
6060
  }
6097
6061
  getBaseTargetFromProps(props, key) {
6098
6062
  return props[key];
@@ -6108,11 +6072,6 @@
6108
6072
  scrapeMotionValuesFromProps(props, prevProps, visualElement) {
6109
6073
  return scrapeMotionValuesFromProps(props, prevProps, visualElement);
6110
6074
  }
6111
- onBindTransform() {
6112
- if (this.current && !this.renderState.dimensions) {
6113
- frame.postRender(this.updateDimensions);
6114
- }
6115
- }
6116
6075
  build(renderState, latestValues, props) {
6117
6076
  buildSVGAttrs(renderState, latestValues, this.isSVGTag, props.transformTemplate);
6118
6077
  }