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
package/src/types.ts ADDED
@@ -0,0 +1,1088 @@
1
+ /**
2
+ based on framer-motion@4.1.17,
3
+ Copyright (c) 2018 Framer B.V.
4
+ */
5
+ import type { CSSProperties, SVGAttributes } from "react";
6
+ import type { SVGPathProperties, TransformProperties } from "./motion/types.js";
7
+ /**
8
+ * @public
9
+ */
10
+ export type ResolvedKeyframesTarget = [null, ...number[]] | number[] | [null, ...string[]] | string[];
11
+ /**
12
+ * @public
13
+ */
14
+ export type KeyframesTarget = ResolvedKeyframesTarget | [null, ...CustomValueType[]] | CustomValueType[];
15
+ /**
16
+ * @public
17
+ */
18
+ export type ResolvedSingleTarget = string | number;
19
+ /**
20
+ * @public
21
+ */
22
+ export type SingleTarget = ResolvedSingleTarget | CustomValueType;
23
+ /**
24
+ * @public
25
+ */
26
+ export type ResolvedValueTarget = ResolvedSingleTarget | ResolvedKeyframesTarget;
27
+ /**
28
+ * @public
29
+ */
30
+ export type ValueTarget = SingleTarget | KeyframesTarget;
31
+ /**
32
+ * @public
33
+ */
34
+ export type Props = {
35
+ [key: string]: any;
36
+ };
37
+ /**
38
+ * A function that accepts a progress value between `0` and `1` and returns a
39
+ * new one.
40
+ *
41
+ * @library
42
+ *
43
+ * ```jsx
44
+ * const transition = {
45
+ * ease: progress => progress * progress
46
+ * }
47
+ *
48
+ * <Frame
49
+ * animate={{ opacity: 0 }}
50
+ * transition={transition}
51
+ * />
52
+ * ```
53
+ *
54
+ * @motion
55
+ *
56
+ * ```jsx
57
+ * <MotionDiv
58
+ * animate={{ opacity: 0 }}
59
+ * transition={{
60
+ * duration: 1,
61
+ * ease: progress => progress * progress
62
+ * }}
63
+ * />
64
+ * ```
65
+ *
66
+ * @public
67
+ */
68
+ export type EasingFunction = (v: number) => number;
69
+ /**
70
+ * The easing function to use. Set as one of:
71
+ *
72
+ * - The name of an in-built easing function.
73
+ * - An array of four numbers to define a cubic bezier curve.
74
+ * - An easing function, that accepts and returns a progress value between `0` and `1`.
75
+ *
76
+ * @public
77
+ */
78
+ export type Easing = [number, number, number, number] | "linear" | "easeIn" | "easeOut" | "easeInOut" | "circIn" | "circOut" | "circInOut" | "backIn" | "backOut" | "backInOut" | "anticipate" | EasingFunction;
79
+ /**
80
+ * Options for orchestrating the timing of animations.
81
+ *
82
+ * @public
83
+ */
84
+ export interface Orchestration {
85
+ /**
86
+ * Delay the animation by this duration (in seconds). Defaults to `0`.
87
+ *
88
+ * @remarks
89
+ * ```javascript
90
+ * const transition = {
91
+ * delay: 0.2
92
+ * }
93
+ * ```
94
+ *
95
+ * @public
96
+ */
97
+ delay?: number;
98
+ /**
99
+ * Describes the relationship between the transition and its children. Set
100
+ * to `false` by default.
101
+ *
102
+ * @remarks
103
+ * When using variants, the transition can be scheduled in relation to its
104
+ * children with either `"beforeChildren"` to finish this transition before
105
+ * starting children transitions, `"afterChildren"` to finish children
106
+ * transitions before starting this transition.
107
+ *
108
+ * @motion
109
+ *
110
+ * ```jsx
111
+ * const list = {
112
+ * hidden: {
113
+ * opacity: 0,
114
+ * transition: { when: "afterChildren" }
115
+ * }
116
+ * }
117
+ *
118
+ * const item = {
119
+ * hidden: {
120
+ * opacity: 0,
121
+ * transition: { duration: 2 }
122
+ * }
123
+ * }
124
+ *
125
+ * <Motion let:motion={ul} variants={list} animate="hidden">
126
+ * <ul use:ul>
127
+ * <Motion let:motion variants={item}>
128
+ * <li use:motion />
129
+ * </Motion>
130
+ * <Motion let:motion variants={item}>
131
+ * <li use:motion />
132
+ * </Motion>
133
+ * </ul>
134
+ * </Motion>
135
+ * )
136
+ * ```
137
+ *
138
+ * @public
139
+ */
140
+ when?: false | "beforeChildren" | "afterChildren" | string;
141
+ /**
142
+ * When using variants, children animations will start after this duration
143
+ * (in seconds). You can add the `transition` property to both the `Frame` and the `variant` directly. Adding it to the `variant` generally offers more flexibility, as it allows you to customize the delay per visual state.
144
+ *
145
+ * @motion
146
+ *
147
+ * ```jsx
148
+ * const container = {
149
+ * hidden: { opacity: 0 },
150
+ * show: {
151
+ * opacity: 1,
152
+ * transition: {
153
+ * delayChildren: 0.5
154
+ * }
155
+ * }
156
+ * }
157
+ *
158
+ * const item = {
159
+ * hidden: { opacity: 0 },
160
+ * show: { opacity: 1 }
161
+ * }
162
+ *
163
+ * <Motion let:motion={ul}
164
+ * variants={container}
165
+ * initial="hidden"
166
+ * animate="show">
167
+ * <ul use:ul>
168
+ * <Motion let:motion variants={item}>
169
+ * <li use:motion />
170
+ * </Motion>
171
+ * <Motion let:motion variants={item}>
172
+ * <li use:motion />
173
+ * </Motion>
174
+ * </ul>
175
+ * </Motion>
176
+ * ```
177
+ *
178
+ * @public
179
+ */
180
+ delayChildren?: number;
181
+ /**
182
+ * When using variants, animations of child components can be staggered by this
183
+ * duration (in seconds).
184
+ *
185
+ * For instance, if `staggerChildren` is `0.01`, the first child will be
186
+ * delayed by `0` seconds, the second by `0.01`, the third by `0.02` and so
187
+ * on.
188
+ *
189
+ * The calculated stagger delay will be added to `delayChildren`.
190
+ *
191
+ * @motion
192
+ *
193
+ * ```jsx
194
+ * const container = {
195
+ * hidden: { opacity: 0 },
196
+ * show: {
197
+ * opacity: 1,
198
+ * transition: {
199
+ * staggerChildren: 0.5
200
+ * }
201
+ * }
202
+ * }
203
+ *
204
+ * const item = {
205
+ * hidden: { opacity: 0 },
206
+ * show: { opacity: 1 }
207
+ * }
208
+ *
209
+ * return (
210
+ * <Motion let:motion={ul}
211
+ * variants={container}
212
+ * initial="hidden"
213
+ * animate="show">
214
+ * <ol use:ul>
215
+ * <Motion let:motion variants={item}>
216
+ * <li use:motion />
217
+ * </Motion>
218
+ * <Motion let:motion variants={item}>
219
+ * <li use:motion />
220
+ * </Motion>
221
+ * </ol>
222
+ * </Motion>
223
+ * )
224
+ * ```
225
+ *
226
+ * @public
227
+ */
228
+ staggerChildren?: number;
229
+ /**
230
+ * The direction in which to stagger children.
231
+ *
232
+ * A value of `1` staggers from the first to the last while `-1`
233
+ * staggers from the last to the first.
234
+ *
235
+ * @motion
236
+ *
237
+ * ```jsx
238
+ * const container = {
239
+ * hidden: { opacity: 0 },
240
+ * show: {
241
+ * opacity: 1,
242
+ * transition: {
243
+ * delayChildren: 0.5,
244
+ * staggerDirection: -1
245
+ * }
246
+ * }
247
+ * }
248
+ *
249
+ * const item = {
250
+ * hidden: { opacity: 0 },
251
+ * show: { opacity: 1 }
252
+ * }
253
+ *
254
+ * <Motion let:motion={ul}
255
+ * variants={container}
256
+ * initial="hidden"
257
+ * animate="show">
258
+ * <ul use:ul>
259
+ * <Motion let:motion
260
+ * variants={item}
261
+ * size={50}/>
262
+ * <li use:motion/>
263
+ * </Motion>
264
+ * <Motion let:motion
265
+ * variants={item}
266
+ * size={50}/>
267
+ * <li use:motion/>
268
+ * </Motion>*
269
+ * </ul>
270
+ * </Motion>
271
+ * ```
272
+ *
273
+ * @public
274
+ */
275
+ staggerDirection?: number;
276
+ }
277
+ export interface Repeat {
278
+ /**
279
+ * The number of times to repeat the transition. Set to `Infinity` for perpetual repeating.
280
+ *
281
+ * Without setting `repeatType`, this will loop the animation.
282
+ *
283
+ * @motion
284
+ *
285
+ * ```jsx
286
+ * <MotionDiv
287
+ * animate={{ rotate: 180 }}
288
+ * transition={{ repeat: Infinity, duration: 2 }}
289
+ * />
290
+ * ```
291
+ *
292
+ * @public
293
+ */
294
+ repeat?: number;
295
+ /**
296
+ * How to repeat the animation. This can be either:
297
+ *
298
+ * "loop": Repeats the animation from the start
299
+ *
300
+ * "reverse": Alternates between forward and backwards playback
301
+ *
302
+ * "mirror": Switches `from` and `to` alternately
303
+ *
304
+ * @motion
305
+ *
306
+ * ```jsx
307
+ * <MotionDiv
308
+ * animate={{ rotate: 180 }}
309
+ * transition={{
310
+ * repeat: 1,
311
+ * repeatType: "reverse",
312
+ * duration: 2
313
+ * }}
314
+ * />
315
+ * ```
316
+ *
317
+ * @public
318
+ */
319
+ repeatType?: "loop" | "reverse" | "mirror";
320
+ /**
321
+ * When repeating an animation, `repeatDelay` will set the
322
+ * duration of the time to wait, in seconds, between each repetition.
323
+ *
324
+ * @motion
325
+ *
326
+ * ```jsx
327
+ * <MotionDiv
328
+ * animate={{ rotate: 180 }}
329
+ * transition={{ repeat: Infinity, repeatDelay: 1 }}
330
+ * />
331
+ * ```
332
+ *
333
+ * @public
334
+ */
335
+ repeatDelay?: number;
336
+ }
337
+ /**
338
+ * An animation that animates between two or more values over a specific duration of time.
339
+ * This is the default animation for non-physical values like `color` and `opacity`.
340
+ *
341
+ * @public
342
+ */
343
+ export interface Tween extends Repeat {
344
+ /**
345
+ * Set `type` to `"tween"` to use a duration-based tween animation.
346
+ * If any non-orchestration `transition` values are set without a `type` property,
347
+ * this is used as the default animation.
348
+ *
349
+ * @motion
350
+ *
351
+ * ```jsx
352
+ * <Motion let:motion isSVG={true}
353
+ * animate={{ pathLength: 1 }}
354
+ * transition={{ duration: 2, type: "tween" }}>
355
+ * <path use:motion/>
356
+ * </Motion> *
357
+ * />
358
+ * ```
359
+ *
360
+ * @public
361
+ */
362
+ type?: "tween";
363
+ /**
364
+ * The duration of the tween animation. Set to `0.3` by default, 0r `0.8` if animating a series of keyframes.
365
+ *
366
+ * @motion
367
+ *
368
+ * ```jsx
369
+ * const variants = {
370
+ * visible: {
371
+ * opacity: 1,
372
+ * transition: { duration: 2 }
373
+ * }
374
+ * }
375
+ * ```
376
+ *
377
+ * @public
378
+ */
379
+ duration?: number;
380
+ /**
381
+ * The easing function to use. Set as one of the below.
382
+ *
383
+ * - The name of an existing easing function.
384
+ *
385
+ * - An array of four numbers to define a cubic bezier curve.
386
+ *
387
+ * - An easing function, that accepts and returns a value `0-1`.
388
+ *
389
+ * If the animating value is set as an array of multiple values for a keyframes
390
+ * animation, `ease` can be set as an array of easing functions to set different easings between
391
+ * each of those values.
392
+ *
393
+ * @motion
394
+ *
395
+ * ```jsx
396
+ * <MotionDiv
397
+ * animate={{ opacity: 0 }}
398
+ * transition={{ ease: [0.17, 0.67, 0.83, 0.67] }}
399
+ * />
400
+ * ```
401
+ *
402
+ * @public
403
+ */
404
+ ease?: Easing | Easing[];
405
+ /**
406
+ * The duration of time already elapsed in the animation. Set to `0` by
407
+ * default.
408
+ *
409
+ * @internal
410
+ */
411
+ elapsed?: number;
412
+ /**
413
+ * When animating keyframes, `times` can be used to determine where in the animation each keyframe is reached.
414
+ * Each value in `times` is a value between `0` and `1`, representing `duration`.
415
+ *
416
+ * There must be the same number of `times` as there are keyframes.
417
+ * Defaults to an array of evenly-spread durations.
418
+ *
419
+ * @motion
420
+ *
421
+ * ```jsx
422
+ * <MotionDiv
423
+ * animate={{ scale: [0, 1, 0.5, 1] }}
424
+ * transition={{ times: [0, 0.1, 0.9, 1] }}
425
+ * />
426
+ * ```
427
+ *
428
+ * @public
429
+ */
430
+ times?: number[];
431
+ /**
432
+ * When animating keyframes, `easings` can be used to define easing functions between each keyframe. This array should be one item fewer than the number of keyframes, as these easings apply to the transitions between the keyframes.
433
+ *
434
+ * @motion
435
+ *
436
+ * ```jsx
437
+ * <MotionDiv
438
+ * animate={{ backgroundColor: ["#0f0", "#00f", "#f00"] }}
439
+ * transition={{ easings: ["easeIn", "easeOut"] }}
440
+ * />
441
+ * ```
442
+ *
443
+ * @public
444
+ */
445
+ easings?: Easing[];
446
+ /**
447
+ * The value to animate from.
448
+ * By default, this is the current state of the animating value.
449
+ *
450
+ * @motion
451
+ *
452
+ * ```jsx
453
+ * <MotionDiv
454
+ * animate={{ rotate: 180 }}
455
+ * transition={{ from: 90, duration: 2 }}
456
+ * />
457
+ * ```
458
+ *
459
+ * @public
460
+ */
461
+ from?: number | string;
462
+ /**
463
+ * @internal
464
+ */
465
+ to?: number | string | ValueTarget;
466
+ /**
467
+ * @internal
468
+ */
469
+ velocity?: number;
470
+ /**
471
+ * @internal
472
+ */
473
+ delay?: number;
474
+ }
475
+ /**
476
+ * An animation that simulates spring physics for realistic motion.
477
+ * This is the default animation for physical values like `x`, `y`, `scale` and `rotate`.
478
+ *
479
+ * @public
480
+ */
481
+ export interface Spring extends Repeat {
482
+ /**
483
+ * Set `type` to `"spring"` to animate using spring physics for natural
484
+ * movement. Type is set to `"spring"` by default.
485
+ *
486
+ * @motion
487
+ *
488
+ * ```jsx
489
+ * <MotionDiv
490
+ * animate={{ rotate: 180 }}
491
+ * transition={{ type: 'spring' }}
492
+ * />
493
+ * ```
494
+ *
495
+ * @public
496
+ */
497
+ type: "spring";
498
+ /**
499
+ * Stiffness of the spring. Higher values will create more sudden movement.
500
+ * Set to `100` by default.
501
+ *
502
+ * @motion
503
+ *
504
+ * ```jsx
505
+ * <MotionDiv
506
+ * animate={{ rotate: 180 }}
507
+ * transition={{ type: 'spring', stiffness: 50 }}
508
+ * />
509
+ * ```
510
+ *
511
+ * @public
512
+ */
513
+ stiffness?: number;
514
+ /**
515
+ * Strength of opposing force. If set to 0, spring will oscillate
516
+ * indefinitely. Set to `10` by default.
517
+ *
518
+ * @motion
519
+ *
520
+ * ```jsx
521
+ * <MotionDiv
522
+ * animate={{ rotate: 180 }}
523
+ * transition={{ type: 'spring', damping: 300 }}
524
+ * />
525
+ * ```
526
+ *
527
+ * @public
528
+ */
529
+ damping?: number;
530
+ /**
531
+ * Mass of the moving object. Higher values will result in more lethargic
532
+ * movement. Set to `1` by default.
533
+ *
534
+ * @motion
535
+ *
536
+ * ```jsx
537
+ * <motion.feTurbulence
538
+ * animate={{ baseFrequency: 0.5 } as any}
539
+ * transition={{ type: "spring", mass: 0.5 }}
540
+ * />
541
+ * ```
542
+ *
543
+ * @public
544
+ */
545
+ mass?: number;
546
+ /**
547
+ * The duration of the animation, defined in seconds. Spring animations can be a maximum of 10 seconds.
548
+ *
549
+ * If `bounce` is set, this defaults to `0.8`.
550
+ *
551
+ * Note: `duration` and `bounce` will be overridden if `stiffness`, `damping` or `mass` are set.
552
+ *
553
+ * @motion
554
+ *
555
+ * ```jsx
556
+ * <MotionDiv
557
+ * animate={{ x: 100 }}
558
+ * transition={{ type: "spring", duration: 0.8 }}
559
+ * />
560
+ * ```
561
+ *
562
+ * @public
563
+ */
564
+ duration?: number;
565
+ /**
566
+ * `bounce` determines the "bounciness" of a spring animation.
567
+ *
568
+ * `0` is no bounce, and `1` is extremely bouncy.
569
+ *
570
+ * If `duration` is set, this defaults to `0.25`.
571
+ *
572
+ * Note: `bounce` and `duration` will be overridden if `stiffness`, `damping` or `mass` are set.
573
+ *
574
+ * @motion
575
+ *
576
+ * ```jsx
577
+ * <MotionDiv
578
+ * animate={{ x: 100 }}
579
+ * transition={{ type: "spring", bounce: 0.25 }}
580
+ * />
581
+ * ```
582
+ *
583
+ * @public
584
+ */
585
+ bounce?: number;
586
+ /**
587
+ * End animation if absolute speed (in units per second) drops below this
588
+ * value and delta is smaller than `restDelta`. Set to `0.01` by default.
589
+ *
590
+ * @motion
591
+ *
592
+ * ```jsx
593
+ * <MotionDiv
594
+ * animate={{ rotate: 180 }}
595
+ * transition={{ type: 'spring', restSpeed: 0.5 }}
596
+ * />
597
+ * ```
598
+ *
599
+ * @public
600
+ */
601
+ restSpeed?: number;
602
+ /**
603
+ * End animation if distance is below this value and speed is below
604
+ * `restSpeed`. When animation ends, spring gets “snapped” to. Set to
605
+ * `0.01` by default.
606
+ *
607
+ * @motion
608
+ *
609
+ * ```jsx
610
+ * <MotionDiv
611
+ * animate={{ rotate: 180 }}
612
+ * transition={{ type: 'spring', restDelta: 0.5 }}
613
+ * />
614
+ * ```
615
+ *
616
+ * @public
617
+ */
618
+ restDelta?: number;
619
+ /**
620
+ * The value to animate from.
621
+ * By default, this is the initial state of the animating value.
622
+ *
623
+ * @motion
624
+ *
625
+ * ```jsx
626
+ * <MotionDiv
627
+ * animate={{ rotate: 180 }}
628
+ * transition={{ type: 'spring', from: 90 }}
629
+ * />
630
+ * ```
631
+ *
632
+ * @public
633
+ */
634
+ from?: number | string;
635
+ /**
636
+ * @internal
637
+ */
638
+ to?: number | string | ValueTarget;
639
+ /**
640
+ * The initial velocity of the spring. By default this is the current velocity of the component.
641
+ *
642
+ * @motion
643
+ *
644
+ * ```jsx
645
+ * <MotionDiv
646
+ * animate={{ rotate: 180 }}
647
+ * transition={{ type: 'spring', velocity: 2 }}
648
+ * />
649
+ * ```
650
+ *
651
+ * @public
652
+ */
653
+ velocity?: number;
654
+ /**
655
+ * @internal
656
+ */
657
+ delay?: number;
658
+ }
659
+ /**
660
+ * An animation that decelerates a value based on its initial velocity,
661
+ * usually used to implement inertial scrolling.
662
+ *
663
+ * Optionally, `min` and `max` boundaries can be defined, and inertia
664
+ * will snap to these with a spring animation.
665
+ *
666
+ * This animation will automatically precalculate a target value,
667
+ * which can be modified with the `modifyTarget` property.
668
+ *
669
+ * This allows you to add snap-to-grid or similar functionality.
670
+ *
671
+ * Inertia is also the animation used for `dragTransition`, and can be configured via that prop.
672
+ *
673
+ * @public
674
+ */
675
+ export interface Inertia {
676
+ /**
677
+ * Set `type` to animate using the inertia animation. Set to `"tween"` by
678
+ * default. This can be used for natural deceleration, like momentum scrolling.
679
+ *
680
+ * @motion
681
+ *
682
+ * ```jsx
683
+ * <MotionDiv
684
+ * animate={{ rotate: 180 }}
685
+ * transition={{ type: "inertia", velocity: 50 }}
686
+ * />
687
+ * ```
688
+ *
689
+ * @public
690
+ */
691
+ type: "inertia";
692
+ /**
693
+ * A function that receives the automatically-calculated target and returns a new one. Useful for snapping the target to a grid.
694
+ *
695
+ * @motion
696
+ *
697
+ * ```jsx
698
+ * <MotionDiv
699
+ * drag
700
+ * dragTransition={{
701
+ * power: 0,
702
+ * // Snap calculated target to nearest 50 pixels
703
+ * modifyTarget: target => Math.round(target / 50) * 50
704
+ * }}
705
+ * />
706
+ * ```
707
+ *
708
+ * @public
709
+ */
710
+ modifyTarget?(v: number): number;
711
+ /**
712
+ * If `min` or `max` is set, this affects the stiffness of the bounce
713
+ * spring. Higher values will create more sudden movement. Set to `500` by
714
+ * default.
715
+ *
716
+ * @motion
717
+ *
718
+ * ```jsx
719
+ * <MotionDiv
720
+ * drag
721
+ * dragTransition={{
722
+ * min: 0,
723
+ * max: 100,
724
+ * bounceStiffness: 100
725
+ * }}
726
+ * />
727
+ * ```
728
+ *
729
+ * @public
730
+ */
731
+ bounceStiffness?: number;
732
+ /**
733
+ * If `min` or `max` is set, this affects the damping of the bounce spring.
734
+ * If set to `0`, spring will oscillate indefinitely. Set to `10` by
735
+ * default.
736
+ *
737
+ * @motion
738
+ *
739
+ * ```jsx
740
+ * <MotionDiv
741
+ * drag
742
+ * dragTransition={{
743
+ * min: 0,
744
+ * max: 100,
745
+ * bounceDamping: 8
746
+ * }}
747
+ * />
748
+ * ```
749
+ *
750
+ * @public
751
+ */
752
+ bounceDamping?: number;
753
+ /**
754
+ * A higher power value equals a further target. Set to `0.8` by default.
755
+ *
756
+ * @motion
757
+ *
758
+ * ```jsx
759
+ * <MotionDiv
760
+ * drag
761
+ * dragTransition={{ power: 0.2 }}
762
+ * />
763
+ * ```
764
+ *
765
+ * @public
766
+ */
767
+ power?: number;
768
+ /**
769
+ * Adjusting the time constant will change the duration of the
770
+ * deceleration, thereby affecting its feel. Set to `700` by default.
771
+ *
772
+ * @motion
773
+ *
774
+ * ```jsx
775
+ * <MotionDiv
776
+ * drag
777
+ * dragTransition={{ timeConstant: 200 }}
778
+ * />
779
+ * ```
780
+ *
781
+ * @public
782
+ */
783
+ timeConstant?: number;
784
+ /**
785
+ * End the animation if the distance to the animation target is below this value, and the absolute speed is below `restSpeed`.
786
+ * When the animation ends, the value gets snapped to the animation target. Set to `0.01` by default.
787
+ * Generally the default values provide smooth animation endings, only in rare cases should you need to customize these.
788
+ *
789
+ * @motion
790
+ *
791
+ * ```jsx
792
+ * <MotionDiv
793
+ * drag
794
+ * dragTransition={{ restDelta: 10 }}
795
+ * />
796
+ * ```
797
+ *
798
+ * @public
799
+ */
800
+ restDelta?: number;
801
+ /**
802
+ * Minimum constraint. If set, the value will "bump" against this value (or immediately spring to it if the animation starts as less than this value).
803
+ *
804
+ * @motion
805
+ *
806
+ * ```jsx
807
+ * <MotionDiv
808
+ * drag
809
+ * dragTransition={{ min: 0, max: 100 }}
810
+ * />
811
+ * ```
812
+ *
813
+ * @public
814
+ */
815
+ min?: number;
816
+ /**
817
+ * Maximum constraint. If set, the value will "bump" against this value (or immediately snap to it, if the initial animation value exceeds this value).
818
+ *
819
+ * @motion
820
+ *
821
+ * ```jsx
822
+ * <MotionDiv
823
+ * drag
824
+ * dragTransition={{ min: 0, max: 100 }}
825
+ * />
826
+ * ```
827
+ *
828
+ * @public
829
+ */
830
+ max?: number;
831
+ /**
832
+ * The value to animate from. By default, this is the current state of the animating value.
833
+ *
834
+ * @motion
835
+ *
836
+ * ```jsx
837
+ * <MotionDiv
838
+ * drag
839
+ * dragTransition={{ from: 50 }}
840
+ * />
841
+ * ```
842
+ *
843
+ * @public
844
+ */
845
+ from?: number | string;
846
+ /**
847
+ * The initial velocity of the animation.
848
+ * By default this is the current velocity of the component.
849
+ *
850
+ * @motion
851
+ *
852
+ * ```jsx
853
+ * <MotionDiv
854
+ * animate={{ rotate: 180 }}
855
+ * transition={{ type: 'inertia', velocity: 200 }}
856
+ * />
857
+ * ```
858
+ *
859
+ * @public
860
+ */
861
+ velocity?: number;
862
+ /**
863
+ * @internal
864
+ */
865
+ delay?: number;
866
+ }
867
+ /**
868
+ * Keyframes tweens between multiple `values`.
869
+ *
870
+ * These tweens can be arranged using the `duration`, `easings`, and `times` properties.
871
+ *
872
+ * @internalremarks
873
+ * We could possibly make the `type` property redundant, if not for all animations
874
+ * then for this one quite easily.
875
+ *
876
+ * @internal
877
+ */
878
+ export interface Keyframes {
879
+ /**
880
+ * Set `type` to `"keyframes"` to animate using the keyframes animation.
881
+ * Set to `"tween"` by default. This can be used to animate between a series of values.
882
+ *
883
+ * @public
884
+ */
885
+ type: "keyframes";
886
+ /**
887
+ * An array of values to animate between.
888
+ *
889
+ * @internal
890
+ */
891
+ values: KeyframesTarget;
892
+ /**
893
+ * An array of numbers between 0 and 1, where `1` represents the `total` duration.
894
+ *
895
+ * Each value represents at which point during the animation each item in the animation target should be hit, so the array should be the same length as `values`.
896
+ *
897
+ * Defaults to an array of evenly-spread durations.
898
+ *
899
+ * @public
900
+ */
901
+ times?: number[];
902
+ /**
903
+ * An array of easing functions for each generated tween, or a single easing function applied to all tweens.
904
+ *
905
+ * This array should be one item less than `values`, as these easings apply to the transitions *between* the `values`.
906
+ *
907
+ * ```jsx
908
+ * const transition = {
909
+ * backgroundColor: {
910
+ * type: 'keyframes',
911
+ * easings: ['circIn', 'circOut']
912
+ * }
913
+ * }
914
+ * ```
915
+ *
916
+ * @public
917
+ */
918
+ ease?: Easing | Easing[];
919
+ /**
920
+ * Popmotion's easing prop to define individual easings. `ease` will be mapped to this prop in keyframes animations.
921
+ *
922
+ * @internal
923
+ */
924
+ easings?: Easing | Easing[];
925
+ /**
926
+ * @internal
927
+ */
928
+ elapsed?: number;
929
+ /**
930
+ * The total duration of the animation. Set to `0.3` by default.
931
+ *
932
+ * ```jsx
933
+ * const transition = {
934
+ * type: "keyframes",
935
+ * duration: 2
936
+ * }
937
+ *
938
+ * <MotionDiv
939
+ * animate={{ opacity: 0 }}
940
+ * transition={transition}
941
+ * />
942
+ * ```
943
+ *
944
+ * @public
945
+ */
946
+ duration?: number;
947
+ /**
948
+ * @public
949
+ */
950
+ repeatDelay?: number;
951
+ /**
952
+ * @internal
953
+ */
954
+ from?: number | string;
955
+ /**
956
+ * @internal
957
+ */
958
+ to?: number | string | ValueTarget;
959
+ /**
960
+ * @internal
961
+ */
962
+ velocity?: number;
963
+ /**
964
+ * @internal
965
+ */
966
+ delay?: number;
967
+ }
968
+ /**
969
+ * @internal
970
+ */
971
+ export interface Just {
972
+ type: "just";
973
+ to?: number | string | ValueTarget;
974
+ from?: number | string;
975
+ delay?: number;
976
+ velocity?: number;
977
+ }
978
+ /**
979
+ * @public
980
+ */
981
+ export interface None {
982
+ /**
983
+ * Set `type` to `false` for an instant transition.
984
+ *
985
+ * @public
986
+ */
987
+ type: false;
988
+ /**
989
+ * @internal
990
+ */
991
+ from?: number | string;
992
+ /**
993
+ * @internal
994
+ */
995
+ delay?: number;
996
+ /**
997
+ * @internal
998
+ */
999
+ velocity?: number;
1000
+ }
1001
+ /**
1002
+ * @public
1003
+ */
1004
+ export type PopmotionTransitionProps = Tween | Spring | Keyframes | Inertia | Just;
1005
+ /**
1006
+ * @public
1007
+ */
1008
+ export type PermissiveTransitionDefinition = {
1009
+ [key: string]: any;
1010
+ };
1011
+ /**
1012
+ * @public
1013
+ */
1014
+ export type TransitionDefinition = Tween | Spring | Keyframes | Inertia | Just | None | PermissiveTransitionDefinition;
1015
+ export type TransitionMap = Orchestration & {
1016
+ [key: string]: TransitionDefinition;
1017
+ };
1018
+ /**
1019
+ * Transition props
1020
+ *
1021
+ * @public
1022
+ */
1023
+ export type Transition = (Orchestration & Repeat & TransitionDefinition) | (Orchestration & Repeat & TransitionMap);
1024
+ export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
1025
+ type CSSPropertiesWithoutTransitionOrSingleTransforms = Omit<CSSProperties, "transition" | "rotate" | "scale" | "perspective">;
1026
+ type TargetProperties = CSSPropertiesWithoutTransitionOrSingleTransforms & SVGAttributes<SVGElement> & TransformProperties /*& CustomStyles*/ & SVGPathProperties;
1027
+ /**
1028
+ * @public
1029
+ */
1030
+ export type MakeCustomValueType<T> = {
1031
+ [K in keyof T]: T[K] | CustomValueType;
1032
+ };
1033
+ /**
1034
+ * @public
1035
+ */
1036
+ export type Target = MakeCustomValueType<TargetProperties>;
1037
+ /**
1038
+ * @public
1039
+ */
1040
+ export type MakeKeyframes<T> = {
1041
+ [K in keyof T]: T[K] | T[K][] | [null, ...T[K][]];
1042
+ };
1043
+ /**
1044
+ * @public
1045
+ */
1046
+ export type TargetWithKeyframes = MakeKeyframes<Target>;
1047
+ /**
1048
+ * An object that specifies values to animate to. Each value may be set either as
1049
+ * a single value, or an array of values.
1050
+ *
1051
+ * It may also option contain these properties:
1052
+ *
1053
+ * - `transition`: Specifies transitions for all or individual values.
1054
+ * - `transitionEnd`: Specifies values to set when the animation finishes.
1055
+ *
1056
+ * ```jsx
1057
+ * const target = {
1058
+ * x: "0%",
1059
+ * opacity: 0,
1060
+ * transition: { duration: 1 },
1061
+ * transitionEnd: { display: "none" }
1062
+ * }
1063
+ * ```
1064
+ *
1065
+ * @public
1066
+ */
1067
+ export type TargetAndTransition = TargetWithKeyframes & {
1068
+ transition?: Transition;
1069
+ transitionEnd?: Target;
1070
+ };
1071
+ export type TargetResolver = (custom: any, current: Target, velocity: Target) => TargetAndTransition;
1072
+ /**
1073
+ * @public
1074
+ */
1075
+ export type Variant = TargetAndTransition | TargetResolver;
1076
+ /**
1077
+ * @public
1078
+ */
1079
+ export type Variants = {
1080
+ [key: string]: Variant;
1081
+ };
1082
+ /**
1083
+ * @public
1084
+ */
1085
+ export interface CustomValueType {
1086
+ mix: (from: any, to: any) => (p: number) => number | string;
1087
+ toValue: () => number | string;
1088
+ }