motion-start 0.0.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 (233) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +39 -0
  3. package/package.json +64 -0
  4. package/src/animation/UseAnimatedState.svelte +86 -0
  5. package/src/animation/UseAnimation.svelte +61 -0
  6. package/src/animation/animate.ts +78 -0
  7. package/src/animation/animation-controls.ts +101 -0
  8. package/src/animation/types.ts +83 -0
  9. package/src/animation/use-animated-state.ts +1 -0
  10. package/src/animation/use-animation.ts +74 -0
  11. package/src/animation/utils/default-transitions.ts +70 -0
  12. package/src/animation/utils/easing.ts +55 -0
  13. package/src/animation/utils/is-animatable.ts +42 -0
  14. package/src/animation/utils/is-animation-controls.ts +17 -0
  15. package/src/animation/utils/is-keyframes-target.ts +17 -0
  16. package/src/animation/utils/transitions.ts +218 -0
  17. package/src/animation/utils/variant-resolvers.ts +15 -0
  18. package/src/components/AnimatePresence/AnimatePresence.svelte +180 -0
  19. package/src/components/AnimatePresence/PresenceChild/PresenceChild.svelte +78 -0
  20. package/src/components/AnimatePresence/PresenceChild/index.ts +7 -0
  21. package/src/components/AnimatePresence/PresenceChild/types.ts +10 -0
  22. package/src/components/AnimatePresence/index.ts +46 -0
  23. package/src/components/AnimatePresence/types.ts +79 -0
  24. package/src/components/AnimatePresence/use-presence.ts +90 -0
  25. package/src/components/AnimateSharedLayout/AnimateSharedLayout.svelte +239 -0
  26. package/src/components/AnimateSharedLayout/index.ts +11 -0
  27. package/src/components/AnimateSharedLayout/types.ts +111 -0
  28. package/src/components/AnimateSharedLayout/utils/batcher.ts +96 -0
  29. package/src/components/AnimateSharedLayout/utils/crossfader.ts +260 -0
  30. package/src/components/AnimateSharedLayout/utils/rotate.ts +48 -0
  31. package/src/components/AnimateSharedLayout/utils/stack.ts +160 -0
  32. package/src/components/LazyMotion/LazyMotion.svelte +82 -0
  33. package/src/components/LazyMotion/index.ts +42 -0
  34. package/src/components/LazyMotion/types.ts +58 -0
  35. package/src/components/MotionConfig/MotionConfig.svelte +56 -0
  36. package/src/components/MotionConfig/MotionConfigScaleCorrection.ts +47 -0
  37. package/src/components/MotionConfig/index.ts +20 -0
  38. package/src/components/MotionDiv.svelte +8 -0
  39. package/src/context/DOMcontext.ts +21 -0
  40. package/src/context/LayoutGroupContext.ts +13 -0
  41. package/src/context/LazyContext.ts +18 -0
  42. package/src/context/MotionConfigContext.ts +48 -0
  43. package/src/context/MotionContext/MotionContext.svelte +27 -0
  44. package/src/context/MotionContext/MotionContextProvider.svelte +22 -0
  45. package/src/context/MotionContext/UseCreateMotionContext.svelte +34 -0
  46. package/src/context/MotionContext/create.ts +1 -0
  47. package/src/context/MotionContext/index.ts +14 -0
  48. package/src/context/MotionContext/utils.ts +29 -0
  49. package/src/context/PresenceContext.ts +26 -0
  50. package/src/context/ScaleCorrectionProvider.svelte +27 -0
  51. package/src/context/SharedLayoutContext.ts +29 -0
  52. package/src/events/UseDomEvent.svelte +67 -0
  53. package/src/events/UsePointerEvent.svelte +76 -0
  54. package/src/events/event-info.ts +69 -0
  55. package/src/events/types.ts +15 -0
  56. package/src/events/use-dom-event.ts +48 -0
  57. package/src/events/use-pointer-event.ts +29 -0
  58. package/src/events/utils.ts +25 -0
  59. package/src/gestures/PanSession.ts +298 -0
  60. package/src/gestures/UseFocusGesture.svelte +31 -0
  61. package/src/gestures/UseGestures.svelte +17 -0
  62. package/src/gestures/UseHoverGesture.svelte +40 -0
  63. package/src/gestures/UsePanGesture.svelte +58 -0
  64. package/src/gestures/UseTapGesture.svelte +77 -0
  65. package/src/gestures/drag/UseDrag.svelte +55 -0
  66. package/src/gestures/drag/UseDragControls.svelte +145 -0
  67. package/src/gestures/drag/VisualElementDragControls.ts +632 -0
  68. package/src/gestures/drag/types.ts +307 -0
  69. package/src/gestures/drag/use-drag-controls.ts +148 -0
  70. package/src/gestures/drag/use-drag.ts +15 -0
  71. package/src/gestures/drag/utils/constraints.ts +157 -0
  72. package/src/gestures/drag/utils/lock.ts +69 -0
  73. package/src/gestures/types.ts +257 -0
  74. package/src/gestures/use-focus-gesture.ts +16 -0
  75. package/src/gestures/use-gestures.ts +2 -0
  76. package/src/gestures/use-hover-gesture.ts +10 -0
  77. package/src/gestures/use-pan-gesture.ts +22 -0
  78. package/src/gestures/use-tap-gesture.ts +14 -0
  79. package/src/gestures/utils/event-type.ts +24 -0
  80. package/src/gestures/utils/is-node-or-child.ts +31 -0
  81. package/src/index.ts +104 -0
  82. package/src/motion/Motion.svelte +246 -0
  83. package/src/motion/MotionSSR.svelte +244 -0
  84. package/src/motion/features/AnimationState.svelte +29 -0
  85. package/src/motion/features/Exit.svelte +32 -0
  86. package/src/motion/features/UseFeatures.svelte +39 -0
  87. package/src/motion/features/animations.ts +22 -0
  88. package/src/motion/features/definitions.ts +49 -0
  89. package/src/motion/features/drag.ts +24 -0
  90. package/src/motion/features/gestures.ts +24 -0
  91. package/src/motion/features/layout/Animate.svelte +314 -0
  92. package/src/motion/features/layout/Animate.ts +9 -0
  93. package/src/motion/features/layout/AnimateLayoutContextProvider.svelte +14 -0
  94. package/src/motion/features/layout/Measure.svelte +98 -0
  95. package/src/motion/features/layout/Measure.ts +9 -0
  96. package/src/motion/features/layout/MeasureContextProvider.svelte +32 -0
  97. package/src/motion/features/layout/index.ts +20 -0
  98. package/src/motion/features/layout/types.ts +71 -0
  99. package/src/motion/features/layout/utils.ts +40 -0
  100. package/src/motion/features/types.ts +53 -0
  101. package/src/motion/features/use-features.ts +16 -0
  102. package/src/motion/index.ts +64 -0
  103. package/src/motion/types.ts +278 -0
  104. package/src/motion/utils/UseLayoutId.svelte +18 -0
  105. package/src/motion/utils/UseVisualElement.svelte +104 -0
  106. package/src/motion/utils/UseVisualState.svelte +137 -0
  107. package/src/motion/utils/is-forced-motion-value.ts +23 -0
  108. package/src/motion/utils/make-renderless-component.ts +17 -0
  109. package/src/motion/utils/should-inhert-variant.ts +6 -0
  110. package/src/motion/utils/use-motion-ref.ts +41 -0
  111. package/src/motion/utils/use-visual-element.ts +13 -0
  112. package/src/motion/utils/use-visual-state.ts +24 -0
  113. package/src/motion/utils/valid-prop.ts +80 -0
  114. package/src/render/dom/M.svelte +16 -0
  115. package/src/render/dom/UseRender.svelte +37 -0
  116. package/src/render/dom/create-motion-class.ts +12 -0
  117. package/src/render/dom/create-visual-element.ts +22 -0
  118. package/src/render/dom/featureBundle.ts +22 -0
  119. package/src/render/dom/motion-minimal.ts +22 -0
  120. package/src/render/dom/motion-proxy.ts +107 -0
  121. package/src/render/dom/motion.ts +62 -0
  122. package/src/render/dom/projection/convert-to-relative.ts +40 -0
  123. package/src/render/dom/projection/default-scale-correctors.ts +138 -0
  124. package/src/render/dom/projection/measure.ts +28 -0
  125. package/src/render/dom/projection/relative-set.ts +27 -0
  126. package/src/render/dom/projection/scale-correction.ts +22 -0
  127. package/src/render/dom/projection/types.ts +13 -0
  128. package/src/render/dom/projection/utils.ts +69 -0
  129. package/src/render/dom/svg-visual-element.ts +114 -0
  130. package/src/render/dom/types.ts +32 -0
  131. package/src/render/dom/use-render.ts +11 -0
  132. package/src/render/dom/utils/UseInitialMotionProps.svelte +26 -0
  133. package/src/render/dom/utils/batch-layout.ts +77 -0
  134. package/src/render/dom/utils/camel-to-dash.ts +20 -0
  135. package/src/render/dom/utils/create-config.ts +33 -0
  136. package/src/render/dom/utils/css-variables-conversion.ts +121 -0
  137. package/src/render/dom/utils/filter-props.ts +55 -0
  138. package/src/render/dom/utils/is-css-variable.ts +18 -0
  139. package/src/render/dom/utils/is-svg-component.ts +41 -0
  140. package/src/render/dom/utils/parse-dom-variant.ts +26 -0
  141. package/src/render/dom/utils/unit-conversion.ts +258 -0
  142. package/src/render/dom/utils/use-html-props.ts +2 -0
  143. package/src/render/dom/utils/use-svg-props.ts +1 -0
  144. package/src/render/dom/value-types/animatable-none.ts +24 -0
  145. package/src/render/dom/value-types/defaults.ts +30 -0
  146. package/src/render/dom/value-types/dimensions.ts +27 -0
  147. package/src/render/dom/value-types/find.ts +31 -0
  148. package/src/render/dom/value-types/get-as-type.ts +21 -0
  149. package/src/render/dom/value-types/number.ts +83 -0
  150. package/src/render/dom/value-types/test.ts +17 -0
  151. package/src/render/dom/value-types/type-auto.ts +21 -0
  152. package/src/render/dom/value-types/type-int.ts +23 -0
  153. package/src/render/dom/value-types/types.ts +8 -0
  154. package/src/render/html/UseHTMLProps.svelte +33 -0
  155. package/src/render/html/UseInitialMotionValues.svelte +27 -0
  156. package/src/render/html/UseStyle.svelte +47 -0
  157. package/src/render/html/config-motion.ts +23 -0
  158. package/src/render/html/supported-elements.ts +10 -0
  159. package/src/render/html/types.ts +64 -0
  160. package/src/render/html/use-props.ts +14 -0
  161. package/src/render/html/utils/build-projection-transform.ts +53 -0
  162. package/src/render/html/utils/build-styles.ts +121 -0
  163. package/src/render/html/utils/build-transform.ts +79 -0
  164. package/src/render/html/utils/create-render-state.ts +18 -0
  165. package/src/render/html/utils/render.ts +22 -0
  166. package/src/render/html/utils/scrape-motion-values.ts +26 -0
  167. package/src/render/html/utils/transform.ts +51 -0
  168. package/src/render/html/visual-element.ts +129 -0
  169. package/src/render/index.ts +703 -0
  170. package/src/render/svg/UseSVGProps.svelte +34 -0
  171. package/src/render/svg/config-motion.ts +51 -0
  172. package/src/render/svg/lowercase-elements.ts +35 -0
  173. package/src/render/svg/supported-elements.ts +10 -0
  174. package/src/render/svg/types.ts +51 -0
  175. package/src/render/svg/use-props.ts +14 -0
  176. package/src/render/svg/utils/build-attrs.ts +58 -0
  177. package/src/render/svg/utils/camel-case-attrs.ts +27 -0
  178. package/src/render/svg/utils/create-render-state.ts +17 -0
  179. package/src/render/svg/utils/path.ts +49 -0
  180. package/src/render/svg/utils/render.ts +22 -0
  181. package/src/render/svg/utils/scrape-motion-values.ts +26 -0
  182. package/src/render/svg/utils/transform-origin.ts +30 -0
  183. package/src/render/svg/visual-element.ts +44 -0
  184. package/src/render/types.ts +148 -0
  185. package/src/render/utils/animation-state.ts +375 -0
  186. package/src/render/utils/animation.ts +167 -0
  187. package/src/render/utils/compare-by-depth.ts +18 -0
  188. package/src/render/utils/flat-tree.ts +35 -0
  189. package/src/render/utils/is-draggable.ts +17 -0
  190. package/src/render/utils/lifecycles.ts +172 -0
  191. package/src/render/utils/motion-values.ts +59 -0
  192. package/src/render/utils/projection.ts +38 -0
  193. package/src/render/utils/setters.ts +910 -0
  194. package/src/render/utils/state.ts +113 -0
  195. package/src/render/utils/types.ts +12 -0
  196. package/src/render/utils/variants.ts +76 -0
  197. package/src/types/geometry.ts +91 -0
  198. package/src/types.ts +1088 -0
  199. package/src/utils/UseUnmountEffect.svelte +11 -0
  200. package/src/utils/array.ts +18 -0
  201. package/src/utils/each-axis.ts +15 -0
  202. package/src/utils/errors.ts +22 -0
  203. package/src/utils/fix-process-env.ts +22 -0
  204. package/src/utils/geometry/delta-apply.ts +162 -0
  205. package/src/utils/geometry/delta-calc.ts +89 -0
  206. package/src/utils/geometry/index.ts +83 -0
  207. package/src/utils/is-browser.ts +12 -0
  208. package/src/utils/is-numerical-string.ts +15 -0
  209. package/src/utils/is-ref-object.ts +16 -0
  210. package/src/utils/noop.ts +15 -0
  211. package/src/utils/resolve-value.ts +23 -0
  212. package/src/utils/shallow-compare.ts +23 -0
  213. package/src/utils/subscription-manager.ts +49 -0
  214. package/src/utils/time-conversion.ts +18 -0
  215. package/src/utils/transform.ts +120 -0
  216. package/src/utils/use-constant.ts +23 -0
  217. package/src/utils/use-cycle.ts +78 -0
  218. package/src/utils/use-force-update.ts +7 -0
  219. package/src/utils/use-isomorphic-effect.ts +8 -0
  220. package/src/utils/use-reduced-motion.ts +70 -0
  221. package/src/utils/use-unmount-effect.ts +8 -0
  222. package/src/value/index.ts +409 -0
  223. package/src/value/scroll/use-element-scroll.ts +73 -0
  224. package/src/value/scroll/use-viewport-scroll.ts +81 -0
  225. package/src/value/scroll/utils.ts +76 -0
  226. package/src/value/use-combine-values.ts +53 -0
  227. package/src/value/use-motion-template.ts +57 -0
  228. package/src/value/use-motion-value.ts +27 -0
  229. package/src/value/use-spring.ts +84 -0
  230. package/src/value/use-transform.ts +216 -0
  231. package/src/value/use-velocity.ts +44 -0
  232. package/src/value/utils/is-motion-value.ts +15 -0
  233. package/src/value/utils/resolve-motion-value.ts +29 -0
@@ -0,0 +1,172 @@
1
+ /**
2
+ based on framer-motion@4.1.17,
3
+ Copyright (c) 2018 Framer B.V.
4
+ */
5
+ import type { SharedLayoutAnimationConfig } from "../../components/AnimateSharedLayout/types";
6
+ import type { MotionProps } from "../../motion/types";
7
+ import type { AxisBox2D, BoxDelta } from "../../types/geometry";
8
+ import type { ResolvedValues } from "../types";
9
+ import type { AnimationDefinition } from "./animation";
10
+ export type LayoutMeasureListener = (layout: AxisBox2D, prevLayout: AxisBox2D) => void;
11
+ export type BeforeLayoutMeasureListener = (layout: AxisBox2D) => void;
12
+ export type LayoutUpdateListener = (layout: AxisBox2D, prevLayout: AxisBox2D, config?: SharedLayoutAnimationConfig) => void;
13
+ export type UpdateListener = (latest: ResolvedValues) => void;
14
+ export type AnimationStartListener = () => void;
15
+ export type AnimationCompleteListener = (definition: AnimationDefinition) => void;
16
+ export type LayoutAnimationCompleteListener = () => void;
17
+ export type SetAxisTargetListener = () => void;
18
+ export type RenderListener = () => void;
19
+ export type OnViewportBoxUpdate = (box: AxisBox2D, delta: BoxDelta) => void;
20
+ /**
21
+ * TODO: Make more of these lifecycle events available as props
22
+ */
23
+ export interface VisualElementLifecycles {
24
+ /**
25
+ * A callback that fires whenever the viewport-relative bounding box updates.
26
+ *
27
+ * @public
28
+ */
29
+ onViewportBoxUpdate?(box: AxisBox2D, delta: BoxDelta): void;
30
+ onBeforeLayoutMeasure?(box: AxisBox2D): void;
31
+ onLayoutMeasure?(box: AxisBox2D, prevBox: AxisBox2D): void;
32
+ /**
33
+ * Callback with latest motion values, fired max once per frame.
34
+ *
35
+ * @motion
36
+ *
37
+ * ```jsx
38
+ * function onUpdate(latest) {
39
+ * console.log(latest.x, latest.opacity)
40
+ * }
41
+ *
42
+ * <MotionDiv animate={{ x: 100, opacity: 0 }} onUpdate={onUpdate} />
43
+ * ```
44
+ */
45
+ onUpdate?(latest: ResolvedValues): void;
46
+ /**
47
+ * Callback when animation defined in `animate` begins.
48
+ *
49
+ * @motion
50
+ *
51
+ * ```jsx
52
+ * function onStart() {
53
+ * console.log("Animation started")
54
+ * }
55
+ *
56
+ * <MotionDiv animate={{ x: 100 }} onAnimationStart={onStart} />
57
+ * ```
58
+ */
59
+ onAnimationStart?(): void;
60
+ /**
61
+ * Callback when animation defined in `animate` is complete.
62
+ *
63
+ * The provided callback will be called the triggering animation definition.
64
+ * If this is a variant, it'll be the variant name, and if a target object
65
+ * then it'll be the target object.
66
+ *
67
+ * This way, it's possible to figure out which animation has completed.
68
+ *
69
+ * @motion
70
+ *
71
+ * ```jsx
72
+ * function onComplete() {
73
+ * console.log("Animation completed")
74
+ * }
75
+ *
76
+ * <MotionDiv
77
+ * animate={{ x: 100 }}
78
+ * onAnimationComplete={definition => {
79
+ * console.log('Completed animating', definition)
80
+ * }}
81
+ * />
82
+ * ```
83
+ */
84
+ onAnimationComplete?(definition: AnimationDefinition): void;
85
+ /**
86
+ * @internal
87
+ */
88
+ onLayoutAnimationComplete?(): void;
89
+ /**
90
+ * @internal
91
+ */
92
+ onUnmount?(): void;
93
+ }
94
+ export interface LifecycleManager {
95
+ onLayoutMeasure: (callback: LayoutMeasureListener) => () => void;
96
+ notifyLayoutMeasure: LayoutMeasureListener;
97
+ onBeforeLayoutMeasure: (callback: BeforeLayoutMeasureListener) => () => void;
98
+ notifyBeforeLayoutMeasure: BeforeLayoutMeasureListener;
99
+ onLayoutUpdate: (callback: LayoutUpdateListener) => () => void;
100
+ notifyLayoutUpdate: LayoutUpdateListener;
101
+ onViewportBoxUpdate: (callback: OnViewportBoxUpdate) => () => void;
102
+ notifyViewportBoxUpdate: OnViewportBoxUpdate;
103
+ onUpdate: (callback: UpdateListener) => () => void;
104
+ notifyUpdate: UpdateListener;
105
+ onAnimationStart: (callback: AnimationStartListener) => () => void;
106
+ notifyAnimationStart: AnimationStartListener;
107
+ onAnimationComplete: (callback: AnimationCompleteListener) => () => void;
108
+ notifyAnimationComplete: AnimationCompleteListener;
109
+ onLayoutAnimationComplete: (callback: LayoutAnimationCompleteListener) => () => void;
110
+ notifyLayoutAnimationComplete: LayoutAnimationCompleteListener;
111
+ onSetAxisTarget: (callback: SetAxisTargetListener) => () => void;
112
+ notifySetAxisTarget: SetAxisTargetListener;
113
+ onRender: (callback: RenderListener) => () => void;
114
+ notifyRender: RenderListener;
115
+ onUnmount: (callback: () => void) => () => void;
116
+ notifyUnmount: () => void;
117
+ clearAllListeners: () => void;
118
+ updatePropListeners: (props: MotionProps) => void;
119
+ }
120
+
121
+
122
+ /**
123
+ based on framer-motion@4.0.3,
124
+ Copyright (c) 2018 Framer B.V.
125
+ */
126
+ import { __spreadArray, __read } from 'tslib';
127
+ import { SubscriptionManager } from '../../utils/subscription-manager.js';
128
+
129
+ var names = [
130
+ "LayoutMeasure",
131
+ "BeforeLayoutMeasure",
132
+ "LayoutUpdate",
133
+ "ViewportBoxUpdate",
134
+ "Update",
135
+ "Render",
136
+ "AnimationComplete",
137
+ "LayoutAnimationComplete",
138
+ "AnimationStart",
139
+ "SetAxisTarget",
140
+ "Unmount",
141
+ ];
142
+ function createLifecycles() {
143
+ var managers = names.map(function () { return new SubscriptionManager(); });
144
+ var propSubscriptions = {};
145
+ var lifecycles = {
146
+ clearAllListeners: function () { return managers.forEach(function (manager) { return manager.clear(); }); },
147
+ updatePropListeners: function (props) {
148
+ return names.forEach(function (name) {
149
+ var _a;
150
+ (_a = propSubscriptions[name]) === null || _a === void 0 ? void 0 : _a.call(propSubscriptions);
151
+ var on = "on" + name;
152
+ var propListener = props[on];
153
+ if (propListener) {
154
+ propSubscriptions[name] = lifecycles[on](propListener);
155
+ }
156
+ });
157
+ },
158
+ };
159
+ managers.forEach(function (manager, i) {
160
+ lifecycles["on" + names[i]] = function (handler) { return manager.add(handler); };
161
+ lifecycles["notify" + names[i]] = function () {
162
+ var args = [];
163
+ for (var _i = 0; _i < arguments.length; _i++) {
164
+ args[_i] = arguments[_i];
165
+ }
166
+ return manager.notify.apply(manager, __spreadArray([], __read(args)));
167
+ };
168
+ });
169
+ return lifecycles as LifecycleManager;
170
+ }
171
+
172
+ export { createLifecycles };
@@ -0,0 +1,59 @@
1
+ /**
2
+ based on framer-motion@4.1.17,
3
+ Copyright (c) 2018 Framer B.V.
4
+ */
5
+ import type { MotionStyle } from "../../motion/types";
6
+ import type { VisualElement } from "../types";
7
+
8
+
9
+ /**
10
+ based on framer-motion@4.0.3,
11
+ Copyright (c) 2018 Framer B.V.
12
+ */
13
+ import { motionValue } from '../../value/index.js';
14
+ import { isMotionValue } from '../../value/utils/is-motion-value.js';
15
+
16
+ function updateMotionValuesFromProps(element: VisualElement, next: MotionStyle, prev: MotionStyle) {
17
+ var _a;
18
+ for (var key in next) {
19
+ var nextValue = next[key];
20
+ var prevValue = prev[key];
21
+ if (isMotionValue(nextValue)) {
22
+ /**
23
+ * If this is a motion value found in props or style, we want to add it
24
+ * to our visual element's motion value map.
25
+ */
26
+ element.addValue(key, nextValue);
27
+ }
28
+ else if (isMotionValue(prevValue)) {
29
+ /**
30
+ * If we're swapping to a new motion value, create a new motion value
31
+ * from that
32
+ */
33
+ element.addValue(key, motionValue(nextValue));
34
+ }
35
+ else if (prevValue !== nextValue) {
36
+ /**
37
+ * If this is a flat value that has changed, update the motion value
38
+ * or create one if it doesn't exist. We only want to do this if we're
39
+ * not handling the value with our animation state.
40
+ */
41
+ if (element.hasValue(key)) {
42
+ var existingValue = element.getValue(key);
43
+ // TODO: Only update values that aren't being animated or even looked at
44
+ !existingValue.hasAnimated && existingValue.set(nextValue);
45
+ }
46
+ else {
47
+ element.addValue(key, motionValue((_a = element.getStaticValue(key)) !== null && _a !== void 0 ? _a : nextValue));
48
+ }
49
+ }
50
+ }
51
+ // Handle removed values
52
+ for (var key in prev) {
53
+ if (next[key] === undefined)
54
+ element.removeValue(key);
55
+ }
56
+ return next;
57
+ }
58
+
59
+ export { updateMotionValuesFromProps };
@@ -0,0 +1,38 @@
1
+ /**
2
+ based on framer-motion@4.1.17,
3
+ Copyright (c) 2018 Framer B.V.
4
+ */
5
+ import type { ResolvedValues, VisualElement } from "../types";
6
+ import type { LayoutState, TargetProjection } from "./state";
7
+
8
+ /**
9
+ based on framer-motion@4.0.3,
10
+ Copyright (c) 2018 Framer B.V.
11
+ */
12
+ import { resetBox, applyTreeDeltas } from '../../utils/geometry/delta-apply.js';
13
+ import { updateBoxDelta } from '../../utils/geometry/delta-calc.js';
14
+
15
+ function updateLayoutDeltas({ delta, layout, layoutCorrected, treeScale }: LayoutState, { target }: TargetProjection, treePath: VisualElement[], transformOrigin: ResolvedValues) {
16
+ /**
17
+ * Reset the corrected box with the latest values from box, as we're then going
18
+ * to perform mutative operations on it.
19
+ */
20
+ resetBox(layoutCorrected, layout);
21
+ /**
22
+ * Apply all the parent deltas to this box to produce the corrected box. This
23
+ * is the layout box, as it will appear on screen as a result of the transforms of its parents.
24
+ */
25
+ applyTreeDeltas(layoutCorrected, treeScale, treePath);
26
+ /**
27
+ * Update the delta between the corrected box and the target box before user-set transforms were applied.
28
+ * This will allow us to calculate the corrected borderRadius and boxShadow to compensate
29
+ * for our layout reprojection, but still allow them to be scaled correctly by the user.
30
+ * It might be that to simplify this we may want to accept that user-set scale1 is also corrected
31
+ * and we wouldn't have to keep and calc both deltas, OR we could support a user setting
32
+ * to allow people to choose whether these styles are corrected based on just the
33
+ * layout reprojection or the final bounding box.
34
+ */
35
+ updateBoxDelta(delta, layoutCorrected, target, transformOrigin);
36
+ }
37
+
38
+ export { updateLayoutDeltas };