motion 12.7.5 → 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.
Files changed (26) hide show
  1. package/dist/cjs/index.js +125 -89
  2. package/dist/cjs/react-client.js +72 -168
  3. package/dist/cjs/react-m.js +18 -150
  4. package/dist/es/framer-motion/dist/es/motion/utils/use-visual-state.mjs +1 -10
  5. package/dist/es/framer-motion/dist/es/render/VisualElement.mjs +1 -3
  6. package/dist/es/framer-motion/dist/es/render/svg/SVGVisualElement.mjs +0 -12
  7. package/dist/es/framer-motion/dist/es/render/svg/config-motion.mjs +0 -45
  8. package/dist/es/framer-motion/dist/es/render/svg/utils/build-attrs.mjs +16 -11
  9. package/dist/es/framer-motion/dist/es/render/utils/motion-values.mjs +1 -1
  10. package/dist/es/framer-motion/dist/es/render/utils/setters.mjs +5 -1
  11. package/dist/es/framer-motion/dist/es/value/use-transform.mjs +1 -1
  12. package/dist/es/framer-motion/dist/es/value/utils/resolve-motion-value.mjs +1 -5
  13. package/dist/es/motion/lib/index.mjs +3 -1
  14. package/dist/es/motion/lib/react.mjs +3 -1
  15. package/dist/es/{framer-motion → motion-dom}/dist/es/utils/transform.mjs +2 -9
  16. package/dist/es/motion-dom/dist/es/value/index.mjs +2 -3
  17. package/dist/es/motion-dom/dist/es/value/map-value.mjs +46 -0
  18. package/dist/es/motion-dom/dist/es/value/subscribe-value.mjs +13 -0
  19. package/dist/es/motion-dom/dist/es/value/transform-value.mjs +35 -0
  20. package/dist/es/motion-dom/dist/es/value/types/maps/number.mjs +0 -1
  21. package/dist/motion.dev.js +125 -89
  22. package/dist/motion.js +1 -1
  23. package/package.json +3 -3
  24. package/dist/es/framer-motion/dist/es/render/svg/utils/measure.mjs +0 -19
  25. package/dist/es/framer-motion/dist/es/render/svg/utils/transform-origin.mjs +0 -18
  26. package/dist/es/framer-motion/dist/es/utils/resolve-value.mjs +0 -11
@@ -2983,7 +2983,6 @@ const numberValueTypes = {
2983
2983
  backgroundPositionY: px,
2984
2984
  ...transformValueTypes,
2985
2985
  zIndex: int,
2986
- size: px,
2987
2986
  // SVG
2988
2987
  fillOpacity: alpha,
2989
2988
  strokeOpacity: alpha,
@@ -3450,7 +3449,7 @@ class MotionValue {
3450
3449
  * This will be replaced by the build step with the latest version number.
3451
3450
  * When MotionValues are provided to motion components, warn if versions are mixed.
3452
3451
  */
3453
- this.version = "12.7.5";
3452
+ this.version = "12.8.1";
3454
3453
  /**
3455
3454
  * Tracks whether this value can output a velocity. Currently this is only true
3456
3455
  * if the value is numerical, but we might be able to widen the scope here and support
@@ -3594,8 +3593,6 @@ class MotionValue {
3594
3593
  * @public
3595
3594
  */
3596
3595
  set(v, render = true) {
3597
- if (v === "none")
3598
- console.trace();
3599
3596
  if (!render || !this.passiveEffect) {
3600
3597
  this.updateAndNotify(v, render);
3601
3598
  }
@@ -3716,6 +3713,7 @@ class MotionValue {
3716
3713
  * @public
3717
3714
  */
3718
3715
  destroy() {
3716
+ this.events.destroy?.notify();
3719
3717
  this.clearListeners();
3720
3718
  this.stop();
3721
3719
  if (this.stopPassiveEffect) {
@@ -3749,14 +3747,6 @@ const isKeyframesTarget = (v) => {
3749
3747
  return Array.isArray(v);
3750
3748
  };
3751
3749
 
3752
- const isCustomValue = (v) => {
3753
- return Boolean(v && typeof v === "object" && v.mix && v.toValue);
3754
- };
3755
- const resolveFinalValueInKeyframes = (v) => {
3756
- // TODO maybe throw if v.length - 1 is placeholder token?
3757
- return isKeyframesTarget(v) ? v[v.length - 1] || 0 : v;
3758
- };
3759
-
3760
3750
  /**
3761
3751
  * Set VisualElement's MotionValue, creating a new MotionValue for it if
3762
3752
  * it doesn't exist.
@@ -3769,6 +3759,10 @@ function setMotionValue(visualElement, key, value) {
3769
3759
  visualElement.addValue(key, motionValue(value));
3770
3760
  }
3771
3761
  }
3762
+ function resolveFinalValueInKeyframes(v) {
3763
+ // TODO maybe throw if v.length - 1 is placeholder token?
3764
+ return isKeyframesTarget(v) ? v[v.length - 1] || 0 : v;
3765
+ }
3772
3766
  function setTarget(visualElement, definition) {
3773
3767
  const resolved = resolveVariant(visualElement, definition);
3774
3768
  let { transitionEnd = {}, transition = {}, ...target } = resolved || {};
@@ -5089,7 +5083,7 @@ function calcViewportConstraints(layoutBox, constraintsBox) {
5089
5083
  * Calculate a transform origin relative to the source axis, between 0-1, that results
5090
5084
  * in an asthetically pleasing scale/transform needed to project from source to target.
5091
5085
  */
5092
- function calcOrigin$1(source, target) {
5086
+ function calcOrigin(source, target) {
5093
5087
  let origin = 0.5;
5094
5088
  const sourceLength = calcLength(source);
5095
5089
  const targetLength = calcLength(target);
@@ -5483,7 +5477,7 @@ class VisualElementDragControls {
5483
5477
  const axisValue = this.getAxisMotionValue(axis);
5484
5478
  if (axisValue && this.constraints !== false) {
5485
5479
  const latest = axisValue.get();
5486
- boxProgress[axis] = calcOrigin$1({ min: latest, max: latest }, this.constraints[axis]);
5480
+ boxProgress[axis] = calcOrigin({ min: latest, max: latest }, this.constraints[axis]);
5487
5481
  }
5488
5482
  });
5489
5483
  /**
@@ -5989,10 +5983,7 @@ function delay(callback, timeout) {
5989
5983
  * TODO: Remove and move to library
5990
5984
  */
5991
5985
  function resolveMotionValue(value) {
5992
- const unwrappedValue = isMotionValue(value) ? value.get() : value;
5993
- return isCustomValue(unwrappedValue)
5994
- ? unwrappedValue.toValue()
5995
- : unwrappedValue;
5986
+ return isMotionValue(value) ? value.get() : value;
5996
5987
  }
5997
5988
 
5998
5989
  const borders = ["TopLeft", "TopRight", "BottomLeft", "BottomRight"];
@@ -8839,25 +8830,10 @@ function buildSVGPath(attrs, length, spacing = 1, offset = 0, useDashCase = true
8839
8830
  attrs[keys.array] = `${pathLength} ${pathSpacing}`;
8840
8831
  }
8841
8832
 
8842
- function calcOrigin(origin, offset, size) {
8843
- return typeof origin === "string"
8844
- ? origin
8845
- : px.transform(offset + size * origin);
8846
- }
8847
- /**
8848
- * The SVG transform origin defaults are different to CSS and is less intuitive,
8849
- * so we use the measured dimensions of the SVG to reconcile these.
8850
- */
8851
- function calcSVGTransformOrigin(dimensions, originX, originY) {
8852
- const pxOriginX = calcOrigin(originX, dimensions.x, dimensions.width);
8853
- const pxOriginY = calcOrigin(originY, dimensions.y, dimensions.height);
8854
- return `${pxOriginX} ${pxOriginY}`;
8855
- }
8856
-
8857
8833
  /**
8858
8834
  * Build SVG visual attrbutes, like cx and style.transform
8859
8835
  */
8860
- function buildSVGAttrs(state, { attrX, attrY, attrScale, originX, originY, pathLength, pathSpacing = 1, pathOffset = 0,
8836
+ function buildSVGAttrs(state, { attrX, attrY, attrScale, pathLength, pathSpacing = 1, pathOffset = 0,
8861
8837
  // This is object creation, which we try to avoid per-frame.
8862
8838
  ...latest }, isSVGTag, transformTemplate) {
8863
8839
  buildHTMLStyles(state, latest, transformTemplate);
@@ -8873,20 +8849,26 @@ function buildSVGAttrs(state, { attrX, attrY, attrScale, originX, originY, pathL
8873
8849
  }
8874
8850
  state.attrs = state.style;
8875
8851
  state.style = {};
8876
- const { attrs, style, dimensions } = state;
8852
+ const { attrs, style } = state;
8877
8853
  /**
8878
- * However, we apply transforms as CSS transforms. So if we detect a transform we take it from attrs
8879
- * and copy it into style.
8854
+ * However, we apply transforms as CSS transforms.
8855
+ * So if we detect a transform, transformOrigin we take it from attrs and copy it into style.
8880
8856
  */
8881
8857
  if (attrs.transform) {
8882
- if (dimensions)
8883
- style.transform = attrs.transform;
8858
+ style.transform = attrs.transform;
8884
8859
  delete attrs.transform;
8885
8860
  }
8886
- // Parse transformOrigin
8887
- if (dimensions &&
8888
- (originX !== undefined || originY !== undefined || style.transform)) {
8889
- style.transformOrigin = calcSVGTransformOrigin(dimensions, originX !== undefined ? originX : 0.5, originY !== undefined ? originY : 0.5);
8861
+ if (style.transform || attrs.transformOrigin) {
8862
+ style.transformOrigin = attrs.transformOrigin ?? "50% 50%";
8863
+ delete attrs.transformOrigin;
8864
+ }
8865
+ if (style.transform) {
8866
+ /**
8867
+ * SVG's element transform-origin uses its own median as a reference.
8868
+ * Therefore, transformBox becomes a fill-box
8869
+ */
8870
+ style.transformBox = "fill-box";
8871
+ delete attrs.transformBox;
8890
8872
  }
8891
8873
  // Render attrX/attrY/attrScale as attributes
8892
8874
  if (attrX !== undefined)
@@ -8965,20 +8947,11 @@ function useConstant(init) {
8965
8947
  return ref.current;
8966
8948
  }
8967
8949
 
8968
- function makeState({ scrapeMotionValuesFromProps, createRenderState, onUpdate, }, props, context, presenceContext) {
8950
+ function makeState({ scrapeMotionValuesFromProps, createRenderState, }, props, context, presenceContext) {
8969
8951
  const state = {
8970
8952
  latestValues: makeLatestValues(props, context, presenceContext, scrapeMotionValuesFromProps),
8971
8953
  renderState: createRenderState(),
8972
8954
  };
8973
- if (onUpdate) {
8974
- /**
8975
- * onMount works without the VisualElement because it could be
8976
- * called before the VisualElement payload has been hydrated.
8977
- * (e.g. if someone is using m components <m.circle />)
8978
- */
8979
- state.onMount = (instance) => onUpdate({ props, current: instance, ...state });
8980
- state.onUpdate = (visualElement) => onUpdate(visualElement);
8981
- }
8982
8955
  return state;
8983
8956
  }
8984
8957
  const makeUseVisualState = (config) => (props, isStatic) => {
@@ -9065,68 +9038,6 @@ const htmlMotionConfig = {
9065
9038
  }),
9066
9039
  };
9067
9040
 
9068
- function updateSVGDimensions(instance, renderState) {
9069
- try {
9070
- renderState.dimensions =
9071
- typeof instance.getBBox === "function"
9072
- ? instance.getBBox()
9073
- : instance.getBoundingClientRect();
9074
- }
9075
- catch (e) {
9076
- // Most likely trying to measure an unrendered element under Firefox
9077
- renderState.dimensions = {
9078
- x: 0,
9079
- y: 0,
9080
- width: 0,
9081
- height: 0,
9082
- };
9083
- }
9084
- }
9085
-
9086
- function renderHTML(element, { style, vars }, styleProp, projection) {
9087
- Object.assign(element.style, style, projection && projection.getProjectionStyles(styleProp));
9088
- // Loop over any CSS variables and assign those.
9089
- for (const key in vars) {
9090
- element.style.setProperty(key, vars[key]);
9091
- }
9092
- }
9093
-
9094
- /**
9095
- * A set of attribute names that are always read/written as camel case.
9096
- */
9097
- const camelCaseAttributes = new Set([
9098
- "baseFrequency",
9099
- "diffuseConstant",
9100
- "kernelMatrix",
9101
- "kernelUnitLength",
9102
- "keySplines",
9103
- "keyTimes",
9104
- "limitingConeAngle",
9105
- "markerHeight",
9106
- "markerWidth",
9107
- "numOctaves",
9108
- "targetX",
9109
- "targetY",
9110
- "surfaceScale",
9111
- "specularConstant",
9112
- "specularExponent",
9113
- "stdDeviation",
9114
- "tableValues",
9115
- "viewBox",
9116
- "gradientTransform",
9117
- "pathLength",
9118
- "startOffset",
9119
- "textLength",
9120
- "lengthAdjust",
9121
- ]);
9122
-
9123
- function renderSVG(element, renderState, _styleProp, projection) {
9124
- renderHTML(element, renderState, undefined, projection);
9125
- for (const key in renderState.attrs) {
9126
- element.setAttribute(!camelCaseAttributes.has(key) ? camelToDash(key) : key, renderState.attrs[key]);
9127
- }
9128
- }
9129
-
9130
9041
  function scrapeMotionValuesFromProps(props, prevProps, visualElement) {
9131
9042
  const newValues = scrapeMotionValuesFromProps$1(props, prevProps, visualElement);
9132
9043
  for (const key in props) {
@@ -9141,49 +9052,10 @@ function scrapeMotionValuesFromProps(props, prevProps, visualElement) {
9141
9052
  return newValues;
9142
9053
  }
9143
9054
 
9144
- const layoutProps = ["x", "y", "width", "height", "cx", "cy", "r"];
9145
9055
  const svgMotionConfig = {
9146
9056
  useVisualState: makeUseVisualState({
9147
9057
  scrapeMotionValuesFromProps: scrapeMotionValuesFromProps,
9148
9058
  createRenderState: createSvgRenderState,
9149
- onUpdate: ({ props, prevProps, current, renderState, latestValues, }) => {
9150
- if (!current)
9151
- return;
9152
- let hasTransform = !!props.drag;
9153
- if (!hasTransform) {
9154
- for (const key in latestValues) {
9155
- if (transformProps.has(key)) {
9156
- hasTransform = true;
9157
- break;
9158
- }
9159
- }
9160
- }
9161
- if (!hasTransform)
9162
- return;
9163
- let needsMeasure = !prevProps;
9164
- if (prevProps) {
9165
- /**
9166
- * Check the layout props for changes, if any are found we need to
9167
- * measure the element again.
9168
- */
9169
- for (let i = 0; i < layoutProps.length; i++) {
9170
- const key = layoutProps[i];
9171
- if (props[key] !==
9172
- prevProps[key]) {
9173
- needsMeasure = true;
9174
- }
9175
- }
9176
- }
9177
- if (!needsMeasure)
9178
- return;
9179
- frame.read(() => {
9180
- updateSVGDimensions(current, renderState);
9181
- frame.render(() => {
9182
- buildSVGAttrs(renderState, latestValues, isSVGTag(current.tagName), props.transformTemplate);
9183
- renderSVG(current, renderState);
9184
- });
9185
- });
9186
- },
9187
9059
  }),
9188
9060
  };
9189
9061
 
@@ -9239,7 +9111,7 @@ function updateMotionValuesFromProps(element, next, prev) {
9239
9111
  * and warn against mismatches.
9240
9112
  */
9241
9113
  if (process.env.NODE_ENV === "development") {
9242
- warnOnce(nextValue.version === "12.7.5", `Attempting to mix Motion versions ${nextValue.version} with 12.7.5 may not work as expected.`);
9114
+ warnOnce(nextValue.version === "12.8.2", `Attempting to mix Motion versions ${nextValue.version} with 12.8.2 may not work as expected.`);
9243
9115
  }
9244
9116
  }
9245
9117
  else if (isMotionValue(prevValue)) {
@@ -9372,8 +9244,7 @@ class VisualElement {
9372
9244
  frame.render(this.render, false, true);
9373
9245
  }
9374
9246
  };
9375
- const { latestValues, renderState, onUpdate } = visualState;
9376
- this.onUpdate = onUpdate;
9247
+ const { latestValues, renderState } = visualState;
9377
9248
  this.latestValues = latestValues;
9378
9249
  this.baseTarget = { ...latestValues };
9379
9250
  this.initialValues = props.initial ? { ...latestValues } : {};
@@ -9575,7 +9446,6 @@ class VisualElement {
9575
9446
  if (this.handleChildMotionValue) {
9576
9447
  this.handleChildMotionValue();
9577
9448
  }
9578
- this.onUpdate && this.onUpdate(this);
9579
9449
  }
9580
9450
  getProps() {
9581
9451
  return this.props;
@@ -9773,6 +9643,14 @@ class DOMVisualElement extends VisualElement {
9773
9643
  }
9774
9644
  }
9775
9645
 
9646
+ function renderHTML(element, { style, vars }, styleProp, projection) {
9647
+ Object.assign(element.style, style, projection && projection.getProjectionStyles(styleProp));
9648
+ // Loop over any CSS variables and assign those.
9649
+ for (const key in vars) {
9650
+ element.style.setProperty(key, vars[key]);
9651
+ }
9652
+ }
9653
+
9776
9654
  function getComputedStyle$1(element) {
9777
9655
  return window.getComputedStyle(element);
9778
9656
  }
@@ -9805,17 +9683,48 @@ class HTMLVisualElement extends DOMVisualElement {
9805
9683
  }
9806
9684
  }
9807
9685
 
9686
+ /**
9687
+ * A set of attribute names that are always read/written as camel case.
9688
+ */
9689
+ const camelCaseAttributes = new Set([
9690
+ "baseFrequency",
9691
+ "diffuseConstant",
9692
+ "kernelMatrix",
9693
+ "kernelUnitLength",
9694
+ "keySplines",
9695
+ "keyTimes",
9696
+ "limitingConeAngle",
9697
+ "markerHeight",
9698
+ "markerWidth",
9699
+ "numOctaves",
9700
+ "targetX",
9701
+ "targetY",
9702
+ "surfaceScale",
9703
+ "specularConstant",
9704
+ "specularExponent",
9705
+ "stdDeviation",
9706
+ "tableValues",
9707
+ "viewBox",
9708
+ "gradientTransform",
9709
+ "pathLength",
9710
+ "startOffset",
9711
+ "textLength",
9712
+ "lengthAdjust",
9713
+ ]);
9714
+
9715
+ function renderSVG(element, renderState, _styleProp, projection) {
9716
+ renderHTML(element, renderState, undefined, projection);
9717
+ for (const key in renderState.attrs) {
9718
+ element.setAttribute(!camelCaseAttributes.has(key) ? camelToDash(key) : key, renderState.attrs[key]);
9719
+ }
9720
+ }
9721
+
9808
9722
  class SVGVisualElement extends DOMVisualElement {
9809
9723
  constructor() {
9810
9724
  super(...arguments);
9811
9725
  this.type = "svg";
9812
9726
  this.isSVGTag = false;
9813
9727
  this.measureInstanceViewportBox = createBox;
9814
- this.updateDimensions = () => {
9815
- if (this.current && !this.renderState.dimensions) {
9816
- updateSVGDimensions(this.current, this.renderState);
9817
- }
9818
- };
9819
9728
  }
9820
9729
  getBaseTargetFromProps(props, key) {
9821
9730
  return props[key];
@@ -9831,11 +9740,6 @@ class SVGVisualElement extends DOMVisualElement {
9831
9740
  scrapeMotionValuesFromProps(props, prevProps, visualElement) {
9832
9741
  return scrapeMotionValuesFromProps(props, prevProps, visualElement);
9833
9742
  }
9834
- onBindTransform() {
9835
- if (this.current && !this.renderState.dimensions) {
9836
- frame.postRender(this.updateDimensions);
9837
- }
9838
- }
9839
9743
  build(renderState, latestValues, props) {
9840
9744
  buildSVGAttrs(renderState, latestValues, this.isSVGTag, props.transformTemplate);
9841
9745
  }
@@ -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("--");
@@ -484,7 +479,6 @@ const numberValueTypes = {
484
479
  backgroundPositionY: px,
485
480
  ...transformValueTypes,
486
481
  zIndex: int,
487
- size: px,
488
482
  // SVG
489
483
  fillOpacity: alpha,
490
484
  strokeOpacity: alpha,
@@ -1112,25 +1106,10 @@ function buildSVGPath(attrs, length, spacing = 1, offset = 0, useDashCase = true
1112
1106
  attrs[keys.array] = `${pathLength} ${pathSpacing}`;
1113
1107
  }
1114
1108
 
1115
- function calcOrigin(origin, offset, size) {
1116
- return typeof origin === "string"
1117
- ? origin
1118
- : px.transform(offset + size * origin);
1119
- }
1120
- /**
1121
- * The SVG transform origin defaults are different to CSS and is less intuitive,
1122
- * so we use the measured dimensions of the SVG to reconcile these.
1123
- */
1124
- function calcSVGTransformOrigin(dimensions, originX, originY) {
1125
- const pxOriginX = calcOrigin(originX, dimensions.x, dimensions.width);
1126
- const pxOriginY = calcOrigin(originY, dimensions.y, dimensions.height);
1127
- return `${pxOriginX} ${pxOriginY}`;
1128
- }
1129
-
1130
1109
  /**
1131
1110
  * Build SVG visual attrbutes, like cx and style.transform
1132
1111
  */
1133
- 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,
1134
1113
  // This is object creation, which we try to avoid per-frame.
1135
1114
  ...latest }, isSVGTag, transformTemplate) {
1136
1115
  buildHTMLStyles(state, latest, transformTemplate);
@@ -1146,20 +1125,26 @@ function buildSVGAttrs(state, { attrX, attrY, attrScale, originX, originY, pathL
1146
1125
  }
1147
1126
  state.attrs = state.style;
1148
1127
  state.style = {};
1149
- const { attrs, style, dimensions } = state;
1128
+ const { attrs, style } = state;
1150
1129
  /**
1151
- * However, we apply transforms as CSS transforms. So if we detect a transform we take it from attrs
1152
- * 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.
1153
1132
  */
1154
1133
  if (attrs.transform) {
1155
- if (dimensions)
1156
- style.transform = attrs.transform;
1134
+ style.transform = attrs.transform;
1157
1135
  delete attrs.transform;
1158
1136
  }
1159
- // Parse transformOrigin
1160
- if (dimensions &&
1161
- (originX !== undefined || originY !== undefined || style.transform)) {
1162
- 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;
1163
1148
  }
1164
1149
  // Render attrX/attrY/attrScale as attributes
1165
1150
  if (attrX !== undefined)
@@ -1273,36 +1258,20 @@ function useConstant(init) {
1273
1258
  return ref.current;
1274
1259
  }
1275
1260
 
1276
- const isCustomValue = (v) => {
1277
- return Boolean(v && typeof v === "object" && v.mix && v.toValue);
1278
- };
1279
-
1280
1261
  /**
1281
1262
  * If the provided value is a MotionValue, this returns the actual value, otherwise just the value itself
1282
1263
  *
1283
1264
  * TODO: Remove and move to library
1284
1265
  */
1285
1266
  function resolveMotionValue(value) {
1286
- const unwrappedValue = isMotionValue(value) ? value.get() : value;
1287
- return isCustomValue(unwrappedValue)
1288
- ? unwrappedValue.toValue()
1289
- : unwrappedValue;
1267
+ return isMotionValue(value) ? value.get() : value;
1290
1268
  }
1291
1269
 
1292
- function makeState({ scrapeMotionValuesFromProps, createRenderState, onUpdate, }, props, context, presenceContext) {
1270
+ function makeState({ scrapeMotionValuesFromProps, createRenderState, }, props, context, presenceContext) {
1293
1271
  const state = {
1294
1272
  latestValues: makeLatestValues(props, context, presenceContext, scrapeMotionValuesFromProps),
1295
1273
  renderState: createRenderState(),
1296
1274
  };
1297
- if (onUpdate) {
1298
- /**
1299
- * onMount works without the VisualElement because it could be
1300
- * called before the VisualElement payload has been hydrated.
1301
- * (e.g. if someone is using m components <m.circle />)
1302
- */
1303
- state.onMount = (instance) => onUpdate({ props, current: instance, ...state });
1304
- state.onUpdate = (visualElement) => onUpdate(visualElement);
1305
- }
1306
1275
  return state;
1307
1276
  }
1308
1277
  const makeUseVisualState = (config) => (props, isStatic) => {
@@ -1389,68 +1358,6 @@ const htmlMotionConfig = {
1389
1358
  }),
1390
1359
  };
1391
1360
 
1392
- function updateSVGDimensions(instance, renderState) {
1393
- try {
1394
- renderState.dimensions =
1395
- typeof instance.getBBox === "function"
1396
- ? instance.getBBox()
1397
- : instance.getBoundingClientRect();
1398
- }
1399
- catch (e) {
1400
- // Most likely trying to measure an unrendered element under Firefox
1401
- renderState.dimensions = {
1402
- x: 0,
1403
- y: 0,
1404
- width: 0,
1405
- height: 0,
1406
- };
1407
- }
1408
- }
1409
-
1410
- function renderHTML(element, { style, vars }, styleProp, projection) {
1411
- Object.assign(element.style, style, projection && projection.getProjectionStyles(styleProp));
1412
- // Loop over any CSS variables and assign those.
1413
- for (const key in vars) {
1414
- element.style.setProperty(key, vars[key]);
1415
- }
1416
- }
1417
-
1418
- /**
1419
- * A set of attribute names that are always read/written as camel case.
1420
- */
1421
- const camelCaseAttributes = new Set([
1422
- "baseFrequency",
1423
- "diffuseConstant",
1424
- "kernelMatrix",
1425
- "kernelUnitLength",
1426
- "keySplines",
1427
- "keyTimes",
1428
- "limitingConeAngle",
1429
- "markerHeight",
1430
- "markerWidth",
1431
- "numOctaves",
1432
- "targetX",
1433
- "targetY",
1434
- "surfaceScale",
1435
- "specularConstant",
1436
- "specularExponent",
1437
- "stdDeviation",
1438
- "tableValues",
1439
- "viewBox",
1440
- "gradientTransform",
1441
- "pathLength",
1442
- "startOffset",
1443
- "textLength",
1444
- "lengthAdjust",
1445
- ]);
1446
-
1447
- function renderSVG(element, renderState, _styleProp, projection) {
1448
- renderHTML(element, renderState, undefined, projection);
1449
- for (const key in renderState.attrs) {
1450
- element.setAttribute(!camelCaseAttributes.has(key) ? camelToDash(key) : key, renderState.attrs[key]);
1451
- }
1452
- }
1453
-
1454
1361
  function scrapeMotionValuesFromProps(props, prevProps, visualElement) {
1455
1362
  const newValues = scrapeMotionValuesFromProps$1(props, prevProps, visualElement);
1456
1363
  for (const key in props) {
@@ -1465,49 +1372,10 @@ function scrapeMotionValuesFromProps(props, prevProps, visualElement) {
1465
1372
  return newValues;
1466
1373
  }
1467
1374
 
1468
- const layoutProps = ["x", "y", "width", "height", "cx", "cy", "r"];
1469
1375
  const svgMotionConfig = {
1470
1376
  useVisualState: makeUseVisualState({
1471
1377
  scrapeMotionValuesFromProps: scrapeMotionValuesFromProps,
1472
1378
  createRenderState: createSvgRenderState,
1473
- onUpdate: ({ props, prevProps, current, renderState, latestValues, }) => {
1474
- if (!current)
1475
- return;
1476
- let hasTransform = !!props.drag;
1477
- if (!hasTransform) {
1478
- for (const key in latestValues) {
1479
- if (transformProps.has(key)) {
1480
- hasTransform = true;
1481
- break;
1482
- }
1483
- }
1484
- }
1485
- if (!hasTransform)
1486
- return;
1487
- let needsMeasure = !prevProps;
1488
- if (prevProps) {
1489
- /**
1490
- * Check the layout props for changes, if any are found we need to
1491
- * measure the element again.
1492
- */
1493
- for (let i = 0; i < layoutProps.length; i++) {
1494
- const key = layoutProps[i];
1495
- if (props[key] !==
1496
- prevProps[key]) {
1497
- needsMeasure = true;
1498
- }
1499
- }
1500
- }
1501
- if (!needsMeasure)
1502
- return;
1503
- frame.read(() => {
1504
- updateSVGDimensions(current, renderState);
1505
- frame.render(() => {
1506
- buildSVGAttrs(renderState, latestValues, isSVGTag(current.tagName), props.transformTemplate);
1507
- renderSVG(current, renderState);
1508
- });
1509
- });
1510
- },
1511
1379
  }),
1512
1380
  };
1513
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;