motion 12.11.4 → 12.12.1

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 (38) hide show
  1. package/dist/cjs/index.js +110 -16
  2. package/dist/cjs/react-client.js +141 -120
  3. package/dist/cjs/react-m.js +108 -108
  4. package/dist/es/framer-motion/dist/es/animation/animate/single-value.mjs +1 -1
  5. package/dist/es/framer-motion/dist/es/animation/animate/subject.mjs +1 -1
  6. package/dist/es/framer-motion/dist/es/animation/sequence/create.mjs +1 -1
  7. package/dist/es/framer-motion/dist/es/animation/utils/create-visual-element.mjs +3 -2
  8. package/dist/es/framer-motion/dist/es/components/AnimatePresence/PopChild.mjs +4 -1
  9. package/dist/es/framer-motion/dist/es/components/Reorder/Item.mjs +1 -1
  10. package/dist/es/framer-motion/dist/es/projection/node/create-projection-node.mjs +3 -2
  11. package/dist/es/framer-motion/dist/es/render/VisualElement.mjs +1 -1
  12. package/dist/es/framer-motion/dist/es/render/dom/DOMVisualElement.mjs +1 -1
  13. package/dist/es/framer-motion/dist/es/render/dom/resize/handle-element.mjs +2 -1
  14. package/dist/es/framer-motion/dist/es/render/dom/scroll/offsets/inset.mjs +3 -1
  15. package/dist/es/framer-motion/dist/es/render/dom/use-render.mjs +2 -2
  16. package/dist/es/framer-motion/dist/es/render/html/use-props.mjs +1 -1
  17. package/dist/es/framer-motion/dist/es/render/html/utils/scrape-motion-values.mjs +1 -1
  18. package/dist/es/framer-motion/dist/es/render/svg/utils/scrape-motion-values.mjs +1 -1
  19. package/dist/es/framer-motion/dist/es/render/utils/motion-values.mjs +1 -1
  20. package/dist/es/framer-motion/dist/es/value/use-motion-template.mjs +1 -1
  21. package/dist/es/framer-motion/dist/es/value/use-spring.mjs +13 -53
  22. package/dist/es/framer-motion/dist/es/value/use-will-change/is.mjs +1 -1
  23. package/dist/es/framer-motion/dist/es/value/utils/resolve-motion-value.mjs +1 -1
  24. package/dist/es/motion/lib/index.mjs +6 -0
  25. package/dist/es/motion/lib/react.mjs +6 -1
  26. package/dist/es/motion-dom/dist/es/animation/waapi/supports/waapi.mjs +3 -5
  27. package/dist/es/motion-dom/dist/es/gestures/press/index.mjs +2 -1
  28. package/dist/es/motion-dom/dist/es/utils/interpolate.mjs +1 -1
  29. package/dist/es/motion-dom/dist/es/utils/is-html-element.mjs +11 -0
  30. package/dist/es/motion-dom/dist/es/utils/is-svg-element.mjs +11 -0
  31. package/dist/es/motion-dom/dist/es/utils/is-svg-svg-element.mjs +11 -0
  32. package/dist/es/motion-dom/dist/es/value/spring-value.mjs +72 -0
  33. package/dist/es/motion-utils/dist/es/is-object.mjs +5 -0
  34. package/dist/motion.dev.js +110 -16
  35. package/dist/motion.js +1 -1
  36. package/package.json +3 -3
  37. package/dist/es/framer-motion/dist/es/render/dom/utils/is-svg-element.mjs +0 -5
  38. /package/dist/es/{framer-motion → motion-dom}/dist/es/value/utils/is-motion-value.mjs +0 -0
@@ -497,6 +497,8 @@ const getValueAsType = (value, type) => {
497
497
  const { schedule: microtask, cancel: cancelMicrotask } =
498
498
  /* @__PURE__ */ createRenderBatcher(queueMicrotask, false);
499
499
 
500
+ const isMotionValue = (value) => Boolean(value && value.getVelocity);
501
+
500
502
  /**
501
503
  * Convert camelCase to dash-case properties.
502
504
  */
@@ -732,8 +734,6 @@ function isForcedMotionValue(key, { layout, layoutId }) {
732
734
  (!!scaleCorrectors[key] || key === "opacity")));
733
735
  }
734
736
 
735
- const isMotionValue = (value) => Boolean(value && value.getVelocity);
736
-
737
737
  const translateAlias = {
738
738
  x: "translateX",
739
739
  y: "translateY",
@@ -906,6 +906,112 @@ function useHTMLProps(props, visualState) {
906
906
  return htmlProps;
907
907
  }
908
908
 
909
+ const dashKeys = {
910
+ offset: "stroke-dashoffset",
911
+ array: "stroke-dasharray",
912
+ };
913
+ const camelKeys = {
914
+ offset: "strokeDashoffset",
915
+ array: "strokeDasharray",
916
+ };
917
+ /**
918
+ * Build SVG path properties. Uses the path's measured length to convert
919
+ * our custom pathLength, pathSpacing and pathOffset into stroke-dashoffset
920
+ * and stroke-dasharray attributes.
921
+ *
922
+ * This function is mutative to reduce per-frame GC.
923
+ */
924
+ function buildSVGPath(attrs, length, spacing = 1, offset = 0, useDashCase = true) {
925
+ // Normalise path length by setting SVG attribute pathLength to 1
926
+ attrs.pathLength = 1;
927
+ // We use dash case when setting attributes directly to the DOM node and camel case
928
+ // when defining props on a React component.
929
+ const keys = useDashCase ? dashKeys : camelKeys;
930
+ // Build the dash offset
931
+ attrs[keys.offset] = px.transform(-offset);
932
+ // Build the dash array
933
+ const pathLength = px.transform(length);
934
+ const pathSpacing = px.transform(spacing);
935
+ attrs[keys.array] = `${pathLength} ${pathSpacing}`;
936
+ }
937
+
938
+ /**
939
+ * Build SVG visual attrbutes, like cx and style.transform
940
+ */
941
+ function buildSVGAttrs(state, { attrX, attrY, attrScale, pathLength, pathSpacing = 1, pathOffset = 0,
942
+ // This is object creation, which we try to avoid per-frame.
943
+ ...latest }, isSVGTag, transformTemplate, styleProp) {
944
+ buildHTMLStyles(state, latest, transformTemplate);
945
+ /**
946
+ * For svg tags we just want to make sure viewBox is animatable and treat all the styles
947
+ * as normal HTML tags.
948
+ */
949
+ if (isSVGTag) {
950
+ if (state.style.viewBox) {
951
+ state.attrs.viewBox = state.style.viewBox;
952
+ }
953
+ return;
954
+ }
955
+ state.attrs = state.style;
956
+ state.style = {};
957
+ const { attrs, style } = state;
958
+ /**
959
+ * However, we apply transforms as CSS transforms.
960
+ * So if we detect a transform, transformOrigin we take it from attrs and copy it into style.
961
+ */
962
+ if (attrs.transform) {
963
+ style.transform = attrs.transform;
964
+ delete attrs.transform;
965
+ }
966
+ if (style.transform || attrs.transformOrigin) {
967
+ style.transformOrigin = attrs.transformOrigin ?? "50% 50%";
968
+ delete attrs.transformOrigin;
969
+ }
970
+ if (style.transform) {
971
+ /**
972
+ * SVG's element transform-origin uses its own median as a reference.
973
+ * Therefore, transformBox becomes a fill-box
974
+ */
975
+ style.transformBox = styleProp?.transformBox ?? "fill-box";
976
+ delete attrs.transformBox;
977
+ }
978
+ // Render attrX/attrY/attrScale as attributes
979
+ if (attrX !== undefined)
980
+ attrs.x = attrX;
981
+ if (attrY !== undefined)
982
+ attrs.y = attrY;
983
+ if (attrScale !== undefined)
984
+ attrs.scale = attrScale;
985
+ // Build SVG path if one has been defined
986
+ if (pathLength !== undefined) {
987
+ buildSVGPath(attrs, pathLength, pathSpacing, pathOffset, false);
988
+ }
989
+ }
990
+
991
+ const createSvgRenderState = () => ({
992
+ ...createHtmlRenderState(),
993
+ attrs: {},
994
+ });
995
+
996
+ const isSVGTag = (tag) => typeof tag === "string" && tag.toLowerCase() === "svg";
997
+
998
+ function useSVGProps(props, visualState, _isStatic, Component) {
999
+ const visualProps = react.useMemo(() => {
1000
+ const state = createSvgRenderState();
1001
+ buildSVGAttrs(state, visualState, isSVGTag(Component), props.transformTemplate, props.style);
1002
+ return {
1003
+ ...state.attrs,
1004
+ style: { ...state.style },
1005
+ };
1006
+ }, [visualState]);
1007
+ if (props.style) {
1008
+ const rawStyles = {};
1009
+ copyRawValuesOnly(rawStyles, props.style, props);
1010
+ visualProps.style = { ...rawStyles, ...visualProps.style };
1011
+ }
1012
+ return visualProps;
1013
+ }
1014
+
909
1015
  /**
910
1016
  * A list of all valid MotionProps.
911
1017
  *
@@ -1077,112 +1183,6 @@ function isSVGComponent(Component) {
1077
1183
  return false;
1078
1184
  }
1079
1185
 
1080
- const dashKeys = {
1081
- offset: "stroke-dashoffset",
1082
- array: "stroke-dasharray",
1083
- };
1084
- const camelKeys = {
1085
- offset: "strokeDashoffset",
1086
- array: "strokeDasharray",
1087
- };
1088
- /**
1089
- * Build SVG path properties. Uses the path's measured length to convert
1090
- * our custom pathLength, pathSpacing and pathOffset into stroke-dashoffset
1091
- * and stroke-dasharray attributes.
1092
- *
1093
- * This function is mutative to reduce per-frame GC.
1094
- */
1095
- function buildSVGPath(attrs, length, spacing = 1, offset = 0, useDashCase = true) {
1096
- // Normalise path length by setting SVG attribute pathLength to 1
1097
- attrs.pathLength = 1;
1098
- // We use dash case when setting attributes directly to the DOM node and camel case
1099
- // when defining props on a React component.
1100
- const keys = useDashCase ? dashKeys : camelKeys;
1101
- // Build the dash offset
1102
- attrs[keys.offset] = px.transform(-offset);
1103
- // Build the dash array
1104
- const pathLength = px.transform(length);
1105
- const pathSpacing = px.transform(spacing);
1106
- attrs[keys.array] = `${pathLength} ${pathSpacing}`;
1107
- }
1108
-
1109
- /**
1110
- * Build SVG visual attrbutes, like cx and style.transform
1111
- */
1112
- function buildSVGAttrs(state, { attrX, attrY, attrScale, pathLength, pathSpacing = 1, pathOffset = 0,
1113
- // This is object creation, which we try to avoid per-frame.
1114
- ...latest }, isSVGTag, transformTemplate, styleProp) {
1115
- buildHTMLStyles(state, latest, transformTemplate);
1116
- /**
1117
- * For svg tags we just want to make sure viewBox is animatable and treat all the styles
1118
- * as normal HTML tags.
1119
- */
1120
- if (isSVGTag) {
1121
- if (state.style.viewBox) {
1122
- state.attrs.viewBox = state.style.viewBox;
1123
- }
1124
- return;
1125
- }
1126
- state.attrs = state.style;
1127
- state.style = {};
1128
- const { attrs, style } = state;
1129
- /**
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.
1132
- */
1133
- if (attrs.transform) {
1134
- style.transform = attrs.transform;
1135
- delete attrs.transform;
1136
- }
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 = styleProp?.transformBox ?? "fill-box";
1147
- delete attrs.transformBox;
1148
- }
1149
- // Render attrX/attrY/attrScale as attributes
1150
- if (attrX !== undefined)
1151
- attrs.x = attrX;
1152
- if (attrY !== undefined)
1153
- attrs.y = attrY;
1154
- if (attrScale !== undefined)
1155
- attrs.scale = attrScale;
1156
- // Build SVG path if one has been defined
1157
- if (pathLength !== undefined) {
1158
- buildSVGPath(attrs, pathLength, pathSpacing, pathOffset, false);
1159
- }
1160
- }
1161
-
1162
- const createSvgRenderState = () => ({
1163
- ...createHtmlRenderState(),
1164
- attrs: {},
1165
- });
1166
-
1167
- const isSVGTag = (tag) => typeof tag === "string" && tag.toLowerCase() === "svg";
1168
-
1169
- function useSVGProps(props, visualState, _isStatic, Component) {
1170
- const visualProps = react.useMemo(() => {
1171
- const state = createSvgRenderState();
1172
- buildSVGAttrs(state, visualState, isSVGTag(Component), props.transformTemplate, props.style);
1173
- return {
1174
- ...state.attrs,
1175
- style: { ...state.style },
1176
- };
1177
- }, [visualState]);
1178
- if (props.style) {
1179
- const rawStyles = {};
1180
- copyRawValuesOnly(rawStyles, props.style, props);
1181
- visualProps.style = { ...rawStyles, ...visualProps.style };
1182
- }
1183
- return visualProps;
1184
- }
1185
-
1186
1186
  function createUseRender(forwardMotionProps = false) {
1187
1187
  const useRender = (Component, props, ref, { latestValues }, isStatic) => {
1188
1188
  const useVisualProps = isSVGComponent(Component)
@@ -1,5 +1,5 @@
1
- import { isMotionValue } from '../../value/utils/is-motion-value.mjs';
2
1
  import { animateMotionValue } from '../interfaces/motion-value.mjs';
2
+ import { isMotionValue } from '../../../../../motion-dom/dist/es/value/utils/is-motion-value.mjs';
3
3
  import { motionValue } from '../../../../../motion-dom/dist/es/value/index.mjs';
4
4
 
5
5
  function animateSingleValue(value, keyframes, options) {
@@ -1,11 +1,11 @@
1
1
  import { visualElementStore } from '../../render/store.mjs';
2
- import { isMotionValue } from '../../value/utils/is-motion-value.mjs';
3
2
  import { animateTarget } from '../interfaces/visual-element-target.mjs';
4
3
  import { createDOMVisualElement, createObjectVisualElement } from '../utils/create-visual-element.mjs';
5
4
  import { isDOMKeyframes } from '../utils/is-dom-keyframes.mjs';
6
5
  import { resolveSubjects } from './resolve-subjects.mjs';
7
6
  import { animateSingleValue } from './single-value.mjs';
8
7
  import { invariant } from '../../../../../motion-utils/dist/es/errors.mjs';
8
+ import { isMotionValue } from '../../../../../motion-dom/dist/es/value/utils/is-motion-value.mjs';
9
9
 
10
10
  function isSingleValue(subject, keyframes) {
11
11
  return (isMotionValue(subject) ||
@@ -1,10 +1,10 @@
1
- import { isMotionValue } from '../../value/utils/is-motion-value.mjs';
2
1
  import { resolveSubjects } from '../animate/resolve-subjects.mjs';
3
2
  import { calculateRepeatDuration } from './utils/calc-repeat-duration.mjs';
4
3
  import { calcNextTime } from './utils/calc-time.mjs';
5
4
  import { addKeyframes } from './utils/edit.mjs';
6
5
  import { normalizeTimes } from './utils/normalize-times.mjs';
7
6
  import { compareByTime } from './utils/sort.mjs';
7
+ import { isMotionValue } from '../../../../../motion-dom/dist/es/value/utils/is-motion-value.mjs';
8
8
  import { defaultOffset } from '../../../../../motion-dom/dist/es/animation/keyframes/offsets/default.mjs';
9
9
  import { isGenerator } from '../../../../../motion-dom/dist/es/animation/generators/utils/is-generator.mjs';
10
10
  import { createGeneratorEasing } from '../../../../../motion-dom/dist/es/animation/generators/utils/create-generator-easing.mjs';
@@ -1,8 +1,9 @@
1
- import { isSVGElement } from '../../render/dom/utils/is-svg-element.mjs';
2
1
  import { HTMLVisualElement } from '../../render/html/HTMLVisualElement.mjs';
3
2
  import { ObjectVisualElement } from '../../render/object/ObjectVisualElement.mjs';
4
3
  import { visualElementStore } from '../../render/store.mjs';
5
4
  import { SVGVisualElement } from '../../render/svg/SVGVisualElement.mjs';
5
+ import { isSVGElement } from '../../../../../motion-dom/dist/es/utils/is-svg-element.mjs';
6
+ import { isSVGSVGElement } from '../../../../../motion-dom/dist/es/utils/is-svg-svg-element.mjs';
6
7
 
7
8
  function createDOMVisualElement(element) {
8
9
  const options = {
@@ -19,7 +20,7 @@ function createDOMVisualElement(element) {
19
20
  latestValues: {},
20
21
  },
21
22
  };
22
- const node = isSVGElement(element)
23
+ const node = isSVGElement(element) && !isSVGSVGElement(element)
23
24
  ? new SVGVisualElement(options)
24
25
  : new HTMLVisualElement(options);
25
26
  node.mount(element);
@@ -3,6 +3,7 @@ import { jsx } from 'react/jsx-runtime';
3
3
  import * as React from 'react';
4
4
  import { useId, useRef, useContext, useInsertionEffect } from 'react';
5
5
  import { MotionConfigContext } from '../../context/MotionConfigContext.mjs';
6
+ import { isHTMLElement } from '../../../../../motion-dom/dist/es/utils/is-html-element.mjs';
6
7
 
7
8
  /**
8
9
  * Measurement functionality has to be within a separate component
@@ -13,7 +14,9 @@ class PopChildMeasure extends React.Component {
13
14
  const element = this.props.childRef.current;
14
15
  if (element && prevProps.isPresent && !this.props.isPresent) {
15
16
  const parent = element.offsetParent;
16
- const parentWidth = parent instanceof HTMLElement ? parent.offsetWidth || 0 : 0;
17
+ const parentWidth = isHTMLElement(parent)
18
+ ? parent.offsetWidth || 0
19
+ : 0;
17
20
  const size = this.props.sizeRef.current;
18
21
  size.height = element.offsetHeight || 0;
19
22
  size.width = element.offsetWidth || 0;
@@ -6,8 +6,8 @@ import { motion } from '../../render/components/motion/proxy.mjs';
6
6
  import { useConstant } from '../../utils/use-constant.mjs';
7
7
  import { useMotionValue } from '../../value/use-motion-value.mjs';
8
8
  import { useTransform } from '../../value/use-transform.mjs';
9
- import { isMotionValue } from '../../value/utils/is-motion-value.mjs';
10
9
  import { invariant } from '../../../../../motion-utils/dist/es/errors.mjs';
10
+ import { isMotionValue } from '../../../../../motion-dom/dist/es/value/utils/is-motion-value.mjs';
11
11
 
12
12
  function useDefaultMotionValue(value, defaultValue = 0) {
13
13
  return isMotionValue(value) ? value : useMotionValue(defaultValue);
@@ -1,6 +1,5 @@
1
1
  import { animateSingleValue } from '../../animation/animate/single-value.mjs';
2
2
  import { getOptimisedAppearId } from '../../animation/optimized-appear/get-appear-id.mjs';
3
- import { isSVGElement } from '../../render/dom/utils/is-svg-element.mjs';
4
3
  import { FlatTree } from '../../render/utils/flat-tree.mjs';
5
4
  import { delay } from '../../utils/delay.mjs';
6
5
  import { resolveMotionValue } from '../../value/utils/resolve-motion-value.mjs';
@@ -19,6 +18,8 @@ import { hasTransform, hasScale, has2DTranslate } from '../utils/has-transform.m
19
18
  import { globalProjectionState } from './state.mjs';
20
19
  import { statsBuffer } from '../../../../../motion-dom/dist/es/stats/buffer.mjs';
21
20
  import { SubscriptionManager } from '../../../../../motion-utils/dist/es/subscription-manager.mjs';
21
+ import { isSVGElement } from '../../../../../motion-dom/dist/es/utils/is-svg-element.mjs';
22
+ import { isSVGSVGElement } from '../../../../../motion-dom/dist/es/utils/is-svg-svg-element.mjs';
22
23
  import { getValueTransition } from '../../../../../motion-dom/dist/es/animation/utils/get-value-transition.mjs';
23
24
  import { cancelFrame, frameData, frameSteps, frame } from '../../../../../motion-dom/dist/es/frameloop/frame.mjs';
24
25
  import { time } from '../../../../../motion-dom/dist/es/frameloop/sync-time.mjs';
@@ -243,7 +244,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
243
244
  mount(instance) {
244
245
  if (this.instance)
245
246
  return;
246
- this.isSVG = isSVGElement(instance);
247
+ this.isSVG = isSVGElement(instance) && !isSVGSVGElement(instance);
247
248
  this.instance = instance;
248
249
  const { layoutId, layout, visualElement } = this.options;
249
250
  if (visualElement && !visualElement.current) {
@@ -2,7 +2,6 @@ import { featureDefinitions } from '../motion/features/definitions.mjs';
2
2
  import { createBox } from '../projection/geometry/models.mjs';
3
3
  import { initPrefersReducedMotion } from '../utils/reduced-motion/index.mjs';
4
4
  import { hasReducedMotionListener, prefersReducedMotion } from '../utils/reduced-motion/state.mjs';
5
- import { isMotionValue } from '../value/utils/is-motion-value.mjs';
6
5
  import { visualElementStore } from './store.mjs';
7
6
  import { isControllingVariants, isVariantNode } from './utils/is-controlling-variants.mjs';
8
7
  import { updateMotionValuesFromProps } from './utils/motion-values.mjs';
@@ -10,6 +9,7 @@ import { resolveVariantFromProps } from './utils/resolve-variants.mjs';
10
9
  import { KeyframeResolver } from '../../../../motion-dom/dist/es/animation/keyframes/KeyframesResolver.mjs';
11
10
  import { time } from '../../../../motion-dom/dist/es/frameloop/sync-time.mjs';
12
11
  import { frame, cancelFrame } from '../../../../motion-dom/dist/es/frameloop/frame.mjs';
12
+ import { isMotionValue } from '../../../../motion-dom/dist/es/value/utils/is-motion-value.mjs';
13
13
  import { warnOnce } from '../../../../motion-utils/dist/es/warn-once.mjs';
14
14
  import { transformProps } from '../../../../motion-dom/dist/es/render/utils/keys-transform.mjs';
15
15
  import { motionValue } from '../../../../motion-dom/dist/es/value/index.mjs';
@@ -1,6 +1,6 @@
1
- import { isMotionValue } from '../../value/utils/is-motion-value.mjs';
2
1
  import { VisualElement } from '../VisualElement.mjs';
3
2
  import { DOMKeyframesResolver } from '../../../../../motion-dom/dist/es/animation/keyframes/DOMKeyframesResolver.mjs';
3
+ import { isMotionValue } from '../../../../../motion-dom/dist/es/value/utils/is-motion-value.mjs';
4
4
 
5
5
  class DOMVisualElement extends VisualElement {
6
6
  constructor() {
@@ -1,4 +1,5 @@
1
1
  import { resolveElements } from '../../../../../../motion-dom/dist/es/utils/resolve-elements.mjs';
2
+ import { isSVGElement } from '../../../../../../motion-dom/dist/es/utils/is-svg-element.mjs';
2
3
 
3
4
  const resizeHandlers = new WeakMap();
4
5
  let observer;
@@ -7,7 +8,7 @@ function getElementSize(target, borderBoxSize) {
7
8
  const { inlineSize, blockSize } = borderBoxSize[0];
8
9
  return { width: inlineSize, height: blockSize };
9
10
  }
10
- else if (target instanceof SVGElement && "getBBox" in target) {
11
+ else if (isSVGElement(target) && "getBBox" in target) {
11
12
  return target.getBBox();
12
13
  }
13
14
  else {
@@ -1,8 +1,10 @@
1
+ import { isHTMLElement } from '../../../../../../../motion-dom/dist/es/utils/is-html-element.mjs';
2
+
1
3
  function calcInset(element, container) {
2
4
  const inset = { x: 0, y: 0 };
3
5
  let current = element;
4
6
  while (current && current !== container) {
5
- if (current instanceof HTMLElement) {
7
+ if (isHTMLElement(current)) {
6
8
  inset.x += current.offsetLeft;
7
9
  inset.y += current.offsetTop;
8
10
  current = current.offsetParent;
@@ -1,9 +1,9 @@
1
1
  import { Fragment, useMemo, createElement } from 'react';
2
2
  import { useHTMLProps } from '../html/use-props.mjs';
3
+ import { useSVGProps } from '../svg/use-props.mjs';
3
4
  import { filterProps } from './utils/filter-props.mjs';
4
5
  import { isSVGComponent } from './utils/is-svg-component.mjs';
5
- import { useSVGProps } from '../svg/use-props.mjs';
6
- import { isMotionValue } from '../../value/utils/is-motion-value.mjs';
6
+ import { isMotionValue } from '../../../../../motion-dom/dist/es/value/utils/is-motion-value.mjs';
7
7
 
8
8
  function createUseRender(forwardMotionProps = false) {
9
9
  const useRender = (Component, props, ref, { latestValues }, isStatic) => {
@@ -1,8 +1,8 @@
1
1
  import { useMemo } from 'react';
2
2
  import { isForcedMotionValue } from '../../motion/utils/is-forced-motion-value.mjs';
3
- import { isMotionValue } from '../../value/utils/is-motion-value.mjs';
4
3
  import { buildHTMLStyles } from './utils/build-styles.mjs';
5
4
  import { createHtmlRenderState } from './utils/create-render-state.mjs';
5
+ import { isMotionValue } from '../../../../../motion-dom/dist/es/value/utils/is-motion-value.mjs';
6
6
 
7
7
  function copyRawValuesOnly(target, source, props) {
8
8
  for (const key in source) {
@@ -1,5 +1,5 @@
1
1
  import { isForcedMotionValue } from '../../../motion/utils/is-forced-motion-value.mjs';
2
- import { isMotionValue } from '../../../value/utils/is-motion-value.mjs';
2
+ import { isMotionValue } from '../../../../../../motion-dom/dist/es/value/utils/is-motion-value.mjs';
3
3
 
4
4
  function scrapeMotionValuesFromProps(props, prevProps, visualElement) {
5
5
  const { style } = props;
@@ -1,5 +1,5 @@
1
- import { isMotionValue } from '../../../value/utils/is-motion-value.mjs';
2
1
  import { scrapeMotionValuesFromProps as scrapeMotionValuesFromProps$1 } from '../../html/utils/scrape-motion-values.mjs';
2
+ import { isMotionValue } from '../../../../../../motion-dom/dist/es/value/utils/is-motion-value.mjs';
3
3
  import { transformPropOrder } from '../../../../../../motion-dom/dist/es/render/utils/keys-transform.mjs';
4
4
 
5
5
  function scrapeMotionValuesFromProps(props, prevProps, visualElement) {
@@ -1,4 +1,4 @@
1
- import { isMotionValue } from '../../value/utils/is-motion-value.mjs';
1
+ import { isMotionValue } from '../../../../../motion-dom/dist/es/value/utils/is-motion-value.mjs';
2
2
  import { motionValue } from '../../../../../motion-dom/dist/es/value/index.mjs';
3
3
 
4
4
  function updateMotionValuesFromProps(element, next, prev) {
@@ -1,5 +1,5 @@
1
1
  import { useCombineMotionValues } from './use-combine-values.mjs';
2
- import { isMotionValue } from './utils/is-motion-value.mjs';
2
+ import { isMotionValue } from '../../../../motion-dom/dist/es/value/utils/is-motion-value.mjs';
3
3
 
4
4
  /**
5
5
  * Combine multiple motion values into a new one using a string template literal.
@@ -1,62 +1,22 @@
1
- import { useContext, useRef, useInsertionEffect } from 'react';
1
+ import { useContext, useInsertionEffect } from 'react';
2
2
  import { MotionConfigContext } from '../context/MotionConfigContext.mjs';
3
- import { useConstant } from '../utils/use-constant.mjs';
4
- import { useIsomorphicLayoutEffect } from '../utils/use-isomorphic-effect.mjs';
5
3
  import { useMotionValue } from './use-motion-value.mjs';
6
- import { isMotionValue } from './utils/is-motion-value.mjs';
7
- import { noop } from '../../../../motion-utils/dist/es/noop.mjs';
8
- import { frame } from '../../../../motion-dom/dist/es/frameloop/frame.mjs';
9
- import { JSAnimation } from '../../../../motion-dom/dist/es/animation/JSAnimation.mjs';
4
+ import { useTransform } from './use-transform.mjs';
5
+ import { attachSpring } from '../../../../motion-dom/dist/es/value/spring-value.mjs';
6
+ import { isMotionValue } from '../../../../motion-dom/dist/es/value/utils/is-motion-value.mjs';
10
7
 
11
- function useSpring(source, config = {}) {
8
+ function useSpring(source, options = {}) {
12
9
  const { isStatic } = useContext(MotionConfigContext);
13
- const activeSpringAnimation = useRef(null);
14
- const initialValue = useConstant(() => isMotionValue(source) ? source.get() : source);
15
- const unit = useConstant(() => typeof initialValue === "string"
16
- ? initialValue.replace(/[\d.-]/g, "")
17
- : undefined);
18
- const value = useMotionValue(initialValue);
19
- const latestValue = useRef(initialValue);
20
- const latestSetter = useRef(noop);
21
- const startAnimation = () => {
22
- stopAnimation();
23
- activeSpringAnimation.current = new JSAnimation({
24
- keyframes: [asNumber(value.get()), asNumber(latestValue.current)],
25
- velocity: value.getVelocity(),
26
- type: "spring",
27
- restDelta: 0.001,
28
- restSpeed: 0.01,
29
- ...config,
30
- onUpdate: latestSetter.current,
31
- });
32
- };
33
- const stopAnimation = () => {
34
- if (activeSpringAnimation.current) {
35
- activeSpringAnimation.current.stop();
36
- }
37
- };
10
+ const getFromSource = () => (isMotionValue(source) ? source.get() : source);
11
+ // isStatic will never change, allowing early hooks return
12
+ if (isStatic) {
13
+ return useTransform(getFromSource);
14
+ }
15
+ const value = useMotionValue(getFromSource());
38
16
  useInsertionEffect(() => {
39
- return value.attach((v, set) => {
40
- if (isStatic)
41
- return set(v);
42
- latestValue.current = v;
43
- latestSetter.current = (latest) => set(parseValue(latest, unit));
44
- frame.postRender(startAnimation);
45
- return value.get();
46
- }, stopAnimation);
47
- }, [JSON.stringify(config)]);
48
- useIsomorphicLayoutEffect(() => {
49
- if (isMotionValue(source)) {
50
- return source.on("change", (v) => value.set(parseValue(v, unit)));
51
- }
52
- }, [value, unit]);
17
+ return attachSpring(value, source, options);
18
+ }, [value, JSON.stringify(options)]);
53
19
  return value;
54
20
  }
55
- function parseValue(v, unit) {
56
- return unit ? v + unit : v;
57
- }
58
- function asNumber(v) {
59
- return typeof v === "number" ? v : parseFloat(v);
60
- }
61
21
 
62
22
  export { useSpring };
@@ -1,4 +1,4 @@
1
- import { isMotionValue } from '../utils/is-motion-value.mjs';
1
+ import { isMotionValue } from '../../../../../motion-dom/dist/es/value/utils/is-motion-value.mjs';
2
2
 
3
3
  function isWillChangeMotionValue(value) {
4
4
  return Boolean(isMotionValue(value) && value.add);
@@ -1,4 +1,4 @@
1
- import { isMotionValue } from './is-motion-value.mjs';
1
+ import { isMotionValue } from '../../../../../motion-dom/dist/es/value/utils/is-motion-value.mjs';
2
2
 
3
3
  /**
4
4
  * If the provided value is a MotionValue, this returns the actual value, otherwise just the value itself
@@ -59,6 +59,9 @@ export { recordStats } from '../../motion-dom/dist/es/stats/index.mjs';
59
59
  export { activeAnimations } from '../../motion-dom/dist/es/stats/animation-count.mjs';
60
60
  export { statsBuffer } from '../../motion-dom/dist/es/stats/buffer.mjs';
61
61
  export { interpolate } from '../../motion-dom/dist/es/utils/interpolate.mjs';
62
+ export { isHTMLElement } from '../../motion-dom/dist/es/utils/is-html-element.mjs';
63
+ export { isSVGElement } from '../../motion-dom/dist/es/utils/is-svg-element.mjs';
64
+ export { isSVGSVGElement } from '../../motion-dom/dist/es/utils/is-svg-svg-element.mjs';
62
65
  export { mix } from '../../motion-dom/dist/es/utils/mix/index.mjs';
63
66
  export { mixColor, mixLinearColor } from '../../motion-dom/dist/es/utils/mix/color.mjs';
64
67
  export { getMixer, mixArray, mixComplex, mixObject } from '../../motion-dom/dist/es/utils/mix/complex.mjs';
@@ -72,6 +75,7 @@ export { supportsScrollTimeline } from '../../motion-dom/dist/es/utils/supports/
72
75
  export { transform } from '../../motion-dom/dist/es/utils/transform.mjs';
73
76
  export { MotionValue, collectMotionValues, motionValue } from '../../motion-dom/dist/es/value/index.mjs';
74
77
  export { mapValue } from '../../motion-dom/dist/es/value/map-value.mjs';
78
+ export { attachSpring, springValue } from '../../motion-dom/dist/es/value/spring-value.mjs';
75
79
  export { transformValue } from '../../motion-dom/dist/es/value/transform-value.mjs';
76
80
  export { color } from '../../motion-dom/dist/es/value/types/color/index.mjs';
77
81
  export { hex } from '../../motion-dom/dist/es/value/types/color/hex.mjs';
@@ -89,6 +93,7 @@ export { testValueType } from '../../motion-dom/dist/es/value/types/test.mjs';
89
93
  export { getAnimatableNone } from '../../motion-dom/dist/es/value/types/utils/animatable-none.mjs';
90
94
  export { findValueType } from '../../motion-dom/dist/es/value/types/utils/find.mjs';
91
95
  export { getValueAsType } from '../../motion-dom/dist/es/value/types/utils/get-as-type.mjs';
96
+ export { isMotionValue } from '../../motion-dom/dist/es/value/utils/is-motion-value.mjs';
92
97
  export { ViewTransitionBuilder, animateView } from '../../motion-dom/dist/es/view/index.mjs';
93
98
  export { cancelSync, sync } from '../../motion-dom/dist/es/frameloop/index-legacy.mjs';
94
99
  export { cancelFrame, frame, frameData, frameSteps } from '../../motion-dom/dist/es/frameloop/frame.mjs';
@@ -97,6 +102,7 @@ export { clamp } from '../../motion-utils/dist/es/clamp.mjs';
97
102
  export { invariant, warning } from '../../motion-utils/dist/es/errors.mjs';
98
103
  export { MotionGlobalConfig } from '../../motion-utils/dist/es/global-config.mjs';
99
104
  export { isNumericalString } from '../../motion-utils/dist/es/is-numerical-string.mjs';
105
+ export { isObject } from '../../motion-utils/dist/es/is-object.mjs';
100
106
  export { isZeroValueString } from '../../motion-utils/dist/es/is-zero-value-string.mjs';
101
107
  export { memo } from '../../motion-utils/dist/es/memo.mjs';
102
108
  export { noop } from '../../motion-utils/dist/es/noop.mjs';
@@ -16,7 +16,6 @@ export { isBrowser } from '../../framer-motion/dist/es/utils/is-browser.mjs';
16
16
  export { useForceUpdate } from '../../framer-motion/dist/es/utils/use-force-update.mjs';
17
17
  export { useIsomorphicLayoutEffect } from '../../framer-motion/dist/es/utils/use-isomorphic-effect.mjs';
18
18
  export { useUnmountEffect } from '../../framer-motion/dist/es/utils/use-unmount-effect.mjs';
19
- export { isMotionValue } from '../../framer-motion/dist/es/value/utils/is-motion-value.mjs';
20
19
  export { domAnimation } from '../../framer-motion/dist/es/render/dom/features-animation.mjs';
21
20
  export { domMax } from '../../framer-motion/dist/es/render/dom/features-max.mjs';
22
21
  export { domMin } from '../../framer-motion/dist/es/render/dom/features-min.mjs';
@@ -83,6 +82,7 @@ export { addUniqueItem, moveItem, removeItem } from '../../motion-utils/dist/es/
83
82
  export { clamp } from '../../motion-utils/dist/es/clamp.mjs';
84
83
  export { invariant, warning } from '../../motion-utils/dist/es/errors.mjs';
85
84
  export { isNumericalString } from '../../motion-utils/dist/es/is-numerical-string.mjs';
85
+ export { isObject } from '../../motion-utils/dist/es/is-object.mjs';
86
86
  export { isZeroValueString } from '../../motion-utils/dist/es/is-zero-value-string.mjs';
87
87
  export { memo } from '../../motion-utils/dist/es/memo.mjs';
88
88
  export { noop } from '../../motion-utils/dist/es/noop.mjs';
@@ -158,6 +158,9 @@ export { recordStats } from '../../motion-dom/dist/es/stats/index.mjs';
158
158
  export { activeAnimations } from '../../motion-dom/dist/es/stats/animation-count.mjs';
159
159
  export { statsBuffer } from '../../motion-dom/dist/es/stats/buffer.mjs';
160
160
  export { interpolate } from '../../motion-dom/dist/es/utils/interpolate.mjs';
161
+ export { isHTMLElement } from '../../motion-dom/dist/es/utils/is-html-element.mjs';
162
+ export { isSVGElement } from '../../motion-dom/dist/es/utils/is-svg-element.mjs';
163
+ export { isSVGSVGElement } from '../../motion-dom/dist/es/utils/is-svg-svg-element.mjs';
161
164
  export { mix } from '../../motion-dom/dist/es/utils/mix/index.mjs';
162
165
  export { mixColor, mixLinearColor } from '../../motion-dom/dist/es/utils/mix/color.mjs';
163
166
  export { getMixer, mixArray, mixComplex, mixObject } from '../../motion-dom/dist/es/utils/mix/complex.mjs';
@@ -171,6 +174,7 @@ export { supportsScrollTimeline } from '../../motion-dom/dist/es/utils/supports/
171
174
  export { transform } from '../../motion-dom/dist/es/utils/transform.mjs';
172
175
  export { MotionValue, collectMotionValues, motionValue } from '../../motion-dom/dist/es/value/index.mjs';
173
176
  export { mapValue } from '../../motion-dom/dist/es/value/map-value.mjs';
177
+ export { attachSpring, springValue } from '../../motion-dom/dist/es/value/spring-value.mjs';
174
178
  export { transformValue } from '../../motion-dom/dist/es/value/transform-value.mjs';
175
179
  export { color } from '../../motion-dom/dist/es/value/types/color/index.mjs';
176
180
  export { hex } from '../../motion-dom/dist/es/value/types/color/hex.mjs';
@@ -188,6 +192,7 @@ export { testValueType } from '../../motion-dom/dist/es/value/types/test.mjs';
188
192
  export { getAnimatableNone } from '../../motion-dom/dist/es/value/types/utils/animatable-none.mjs';
189
193
  export { findValueType } from '../../motion-dom/dist/es/value/types/utils/find.mjs';
190
194
  export { getValueAsType } from '../../motion-dom/dist/es/value/types/utils/get-as-type.mjs';
195
+ export { isMotionValue } from '../../motion-dom/dist/es/value/utils/is-motion-value.mjs';
191
196
  export { ViewTransitionBuilder, animateView } from '../../motion-dom/dist/es/view/index.mjs';
192
197
  export { cancelSync, sync } from '../../motion-dom/dist/es/frameloop/index-legacy.mjs';
193
198
  export { cancelFrame, frame, frameData, frameSteps } from '../../motion-dom/dist/es/frameloop/frame.mjs';