framer-motion 12.4.13 → 12.6.0

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 (100) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/client.js +1 -1
  3. package/dist/cjs/{create-DkTZDHiS.js → create-CgwP8YNL.js} +4234 -4792
  4. package/dist/cjs/debug.js +5 -281
  5. package/dist/cjs/dom-mini.js +9 -7
  6. package/dist/cjs/dom.js +81 -639
  7. package/dist/cjs/index.js +1555 -1553
  8. package/dist/cjs/m.js +11 -179
  9. package/dist/cjs/mini.js +8 -0
  10. package/dist/debug.d.ts +2 -35
  11. package/dist/dom-mini.d.ts +1 -181
  12. package/dist/dom-mini.js +1 -1
  13. package/dist/dom.d.ts +3 -242
  14. package/dist/dom.js +1 -1
  15. package/dist/es/animation/animate/single-value.mjs +1 -1
  16. package/dist/es/animation/animators/BaseAnimation.mjs +1 -1
  17. package/dist/es/animation/animators/MainThreadAnimation.mjs +1 -2
  18. package/dist/es/animation/animators/drivers/driver-frameloop.mjs +1 -2
  19. package/dist/es/animation/animators/waapi/index.mjs +1 -3
  20. package/dist/es/animation/generators/utils/velocity.mjs +1 -1
  21. package/dist/es/animation/interfaces/motion-value.mjs +2 -4
  22. package/dist/es/animation/interfaces/visual-element-target.mjs +1 -2
  23. package/dist/es/animation/optimized-appear/start.mjs +3 -3
  24. package/dist/es/animation/sequence/utils/edit.mjs +1 -1
  25. package/dist/es/components/AnimatePresence/index.mjs +1 -1
  26. package/dist/es/components/Reorder/utils/check-reorder.mjs +1 -1
  27. package/dist/es/debug.mjs +1 -1
  28. package/dist/es/dom.mjs +1 -5
  29. package/dist/es/gestures/drag/VisualElementDragControls.mjs +1 -2
  30. package/dist/es/gestures/hover.mjs +1 -2
  31. package/dist/es/gestures/pan/PanSession.mjs +1 -2
  32. package/dist/es/gestures/pan/index.mjs +1 -1
  33. package/dist/es/gestures/press.mjs +1 -2
  34. package/dist/es/index.mjs +14 -19
  35. package/dist/es/motion/features/layout/MeasureLayout.mjs +1 -2
  36. package/dist/es/motion/utils/use-visual-element.mjs +6 -6
  37. package/dist/es/projection/node/create-projection-node.mjs +2 -8
  38. package/dist/es/projection/shared/stack.mjs +1 -1
  39. package/dist/es/projection.mjs +1 -3
  40. package/dist/es/render/VisualElement.mjs +2 -5
  41. package/dist/es/render/components/create-proxy.mjs +1 -1
  42. package/dist/es/render/dom/DOMVisualElement.mjs +1 -1
  43. package/dist/es/render/dom/scroll/info.mjs +1 -2
  44. package/dist/es/render/dom/scroll/observe.mjs +1 -1
  45. package/dist/es/render/dom/scroll/on-scroll-handler.mjs +1 -1
  46. package/dist/es/render/dom/scroll/track.mjs +1 -1
  47. package/dist/es/render/svg/SVGVisualElement.mjs +1 -1
  48. package/dist/es/render/svg/config-motion.mjs +1 -1
  49. package/dist/es/render/utils/KeyframesResolver.mjs +1 -1
  50. package/dist/es/render/utils/flat-tree.mjs +1 -1
  51. package/dist/es/render/utils/motion-values.mjs +3 -3
  52. package/dist/es/render/utils/setters.mjs +1 -1
  53. package/dist/es/utils/delay.mjs +1 -2
  54. package/dist/es/utils/reduced-motion/use-reduced-motion.mjs +1 -1
  55. package/dist/es/utils/use-animation-frame.mjs +1 -1
  56. package/dist/es/utils/use-force-update.mjs +1 -1
  57. package/dist/es/utils/use-instant-transition.mjs +1 -1
  58. package/dist/es/value/scroll/use-element-scroll.mjs +1 -1
  59. package/dist/es/value/scroll/use-viewport-scroll.mjs +1 -1
  60. package/dist/es/value/use-combine-values.mjs +2 -2
  61. package/dist/es/value/use-computed.mjs +1 -1
  62. package/dist/es/value/use-inverted-scale.mjs +3 -3
  63. package/dist/es/value/use-motion-value.mjs +1 -1
  64. package/dist/es/value/use-scroll.mjs +4 -4
  65. package/dist/es/value/use-spring.mjs +1 -1
  66. package/dist/es/value/use-transform.mjs +1 -1
  67. package/dist/es/value/use-velocity.mjs +1 -1
  68. package/dist/es/value/use-will-change/WillChangeMotionValue.mjs +2 -2
  69. package/dist/framer-motion.dev.js +8227 -8251
  70. package/dist/framer-motion.js +1 -1
  71. package/dist/m.d.ts +49 -241
  72. package/dist/size-rollup-animate.js +1 -1
  73. package/dist/size-rollup-dom-animation-assets.js +1 -1
  74. package/dist/size-rollup-dom-animation.js +1 -1
  75. package/dist/size-rollup-dom-max-assets.js +1 -1
  76. package/dist/size-rollup-dom-max.js +1 -1
  77. package/dist/size-rollup-m.js +1 -1
  78. package/dist/size-rollup-motion.js +1 -1
  79. package/dist/size-rollup-scroll.js +1 -1
  80. package/dist/types/client.d.ts +2 -2
  81. package/dist/types/index.d.ts +43 -79
  82. package/dist/{types.d-6pKw1mTI.d.ts → types.d-B50aGbjN.d.ts} +81 -289
  83. package/package.json +4 -6
  84. package/dist/es/frameloop/batcher.mjs +0 -69
  85. package/dist/es/frameloop/frame.mjs +0 -6
  86. package/dist/es/frameloop/index-legacy.mjs +0 -20
  87. package/dist/es/frameloop/microtask.mjs +0 -5
  88. package/dist/es/frameloop/order.mjs +0 -10
  89. package/dist/es/frameloop/render-step.mjs +0 -92
  90. package/dist/es/frameloop/sync-time.mjs +0 -31
  91. package/dist/es/stats/animation-count.mjs +0 -7
  92. package/dist/es/stats/buffer.mjs +0 -6
  93. package/dist/es/stats/index.mjs +0 -113
  94. package/dist/es/utils/GlobalConfig.mjs +0 -6
  95. package/dist/es/utils/array.mjs +0 -21
  96. package/dist/es/utils/subscription-manager.mjs +0 -40
  97. package/dist/es/utils/velocity-per-second.mjs +0 -11
  98. package/dist/es/utils/warn-once.mjs +0 -11
  99. package/dist/es/value/index.mjs +0 -319
  100. package/dist/three.d.ts +0 -2833
package/dist/three.d.ts DELETED
@@ -1,2833 +0,0 @@
1
- /// <reference types="react" />
2
- import { Easing, TransformProperties, SVGPathProperties, VariableKeyframesDefinition, AnimationPlaybackControls, Transition as Transition$1 } from 'motion-dom';
3
- import * as React$1 from 'react';
4
- import { SVGAttributes, CSSProperties, useEffect } from 'react';
5
- import * as react_jsx_runtime from 'react/jsx-runtime';
6
-
7
- type RefObject<T> = {
8
- current: T | null;
9
- };
10
-
11
- interface Point {
12
- x: number;
13
- y: number;
14
- }
15
- interface Axis {
16
- min: number;
17
- max: number;
18
- }
19
- interface Box {
20
- x: Axis;
21
- y: Axis;
22
- }
23
- interface BoundingBox {
24
- top: number;
25
- right: number;
26
- bottom: number;
27
- left: number;
28
- }
29
- interface AxisDelta {
30
- translate: number;
31
- scale: number;
32
- origin: number;
33
- originPoint: number;
34
- }
35
- interface Delta {
36
- x: AxisDelta;
37
- y: AxisDelta;
38
- }
39
- type TransformPoint = (point: Point) => Point;
40
-
41
- /**
42
- * Passed in to pan event handlers like `onPan` the `PanInfo` object contains
43
- * information about the current state of the tap gesture such as its
44
- * `point`, `delta`, `offset` and `velocity`.
45
- *
46
- * ```jsx
47
- * <motion.div onPan={(event, info) => {
48
- * console.log(info.point.x, info.point.y)
49
- * }} />
50
- * ```
51
- *
52
- * @public
53
- */
54
- interface PanInfo {
55
- /**
56
- * Contains `x` and `y` values for the current pan position relative
57
- * to the device or page.
58
- *
59
- * ```jsx
60
- * function onPan(event, info) {
61
- * console.log(info.point.x, info.point.y)
62
- * }
63
- *
64
- * <motion.div onPan={onPan} />
65
- * ```
66
- *
67
- * @public
68
- */
69
- point: Point;
70
- /**
71
- * Contains `x` and `y` values for the distance moved since
72
- * the last event.
73
- *
74
- * ```jsx
75
- * function onPan(event, info) {
76
- * console.log(info.delta.x, info.delta.y)
77
- * }
78
- *
79
- * <motion.div onPan={onPan} />
80
- * ```
81
- *
82
- * @public
83
- */
84
- delta: Point;
85
- /**
86
- * Contains `x` and `y` values for the distance moved from
87
- * the first pan event.
88
- *
89
- * ```jsx
90
- * function onPan(event, info) {
91
- * console.log(info.offset.x, info.offset.y)
92
- * }
93
- *
94
- * <motion.div onPan={onPan} />
95
- * ```
96
- *
97
- * @public
98
- */
99
- offset: Point;
100
- /**
101
- * Contains `x` and `y` values for the current velocity of the pointer, in px/ms.
102
- *
103
- * ```jsx
104
- * function onPan(event, info) {
105
- * console.log(info.velocity.x, info.velocity.y)
106
- * }
107
- *
108
- * <motion.div onPan={onPan} />
109
- * ```
110
- *
111
- * @public
112
- */
113
- velocity: Point;
114
- }
115
-
116
- /**
117
- * Options for orchestrating the timing of animations.
118
- *
119
- * @public
120
- */
121
- interface Orchestration {
122
- /**
123
- * Delay the animation by this duration (in seconds). Defaults to `0`.
124
- *
125
- * @remarks
126
- * ```javascript
127
- * const transition = {
128
- * delay: 0.2
129
- * }
130
- * ```
131
- *
132
- * @public
133
- */
134
- delay?: number;
135
- /**
136
- * Describes the relationship between the transition and its children. Set
137
- * to `false` by default.
138
- *
139
- * @remarks
140
- * When using variants, the transition can be scheduled in relation to its
141
- * children with either `"beforeChildren"` to finish this transition before
142
- * starting children transitions, `"afterChildren"` to finish children
143
- * transitions before starting this transition.
144
- *
145
- * ```jsx
146
- * const list = {
147
- * hidden: {
148
- * opacity: 0,
149
- * transition: { when: "afterChildren" }
150
- * }
151
- * }
152
- *
153
- * const item = {
154
- * hidden: {
155
- * opacity: 0,
156
- * transition: { duration: 2 }
157
- * }
158
- * }
159
- *
160
- * return (
161
- * <motion.ul variants={list} animate="hidden">
162
- * <motion.li variants={item} />
163
- * <motion.li variants={item} />
164
- * </motion.ul>
165
- * )
166
- * ```
167
- *
168
- * @public
169
- */
170
- when?: false | "beforeChildren" | "afterChildren" | string;
171
- /**
172
- * When using variants, children animations will start after this duration
173
- * (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.
174
- *
175
- * ```jsx
176
- * const container = {
177
- * hidden: { opacity: 0 },
178
- * show: {
179
- * opacity: 1,
180
- * transition: {
181
- * delayChildren: 0.5
182
- * }
183
- * }
184
- * }
185
- *
186
- * const item = {
187
- * hidden: { opacity: 0 },
188
- * show: { opacity: 1 }
189
- * }
190
- *
191
- * return (
192
- * <motion.ul
193
- * variants={container}
194
- * initial="hidden"
195
- * animate="show"
196
- * >
197
- * <motion.li variants={item} />
198
- * <motion.li variants={item} />
199
- * </motion.ul>
200
- * )
201
- * ```
202
- *
203
- * @public
204
- */
205
- delayChildren?: number;
206
- /**
207
- * When using variants, animations of child components can be staggered by this
208
- * duration (in seconds).
209
- *
210
- * For instance, if `staggerChildren` is `0.01`, the first child will be
211
- * delayed by `0` seconds, the second by `0.01`, the third by `0.02` and so
212
- * on.
213
- *
214
- * The calculated stagger delay will be added to `delayChildren`.
215
- *
216
- * ```jsx
217
- * const container = {
218
- * hidden: { opacity: 0 },
219
- * show: {
220
- * opacity: 1,
221
- * transition: {
222
- * staggerChildren: 0.5
223
- * }
224
- * }
225
- * }
226
- *
227
- * const item = {
228
- * hidden: { opacity: 0 },
229
- * show: { opacity: 1 }
230
- * }
231
- *
232
- * return (
233
- * <motion.ol
234
- * variants={container}
235
- * initial="hidden"
236
- * animate="show"
237
- * >
238
- * <motion.li variants={item} />
239
- * <motion.li variants={item} />
240
- * </motion.ol>
241
- * )
242
- * ```
243
- *
244
- * @public
245
- */
246
- staggerChildren?: number;
247
- /**
248
- * The direction in which to stagger children.
249
- *
250
- * A value of `1` staggers from the first to the last while `-1`
251
- * staggers from the last to the first.
252
- *
253
- * ```jsx
254
- * const container = {
255
- * hidden: { opacity: 0 },
256
- * show: {
257
- * opacity: 1,
258
- * transition: {
259
- * staggerChildren: 0.5,
260
- * staggerDirection: -1
261
- * }
262
- * }
263
- * }
264
- *
265
- * const item = {
266
- * hidden: { opacity: 0 },
267
- * show: { opacity: 1 }
268
- * }
269
- *
270
- * return (
271
- * <motion.ul
272
- * variants={container}
273
- * initial="hidden"
274
- * animate="show"
275
- * >
276
- * <motion.li variants={item} size={50} />
277
- * <motion.li variants={item} size={50} />
278
- * </motion.ul>
279
- * )
280
- * ```
281
- *
282
- * @public
283
- */
284
- staggerDirection?: number;
285
- }
286
- interface Repeat {
287
- /**
288
- * The number of times to repeat the transition. Set to `Infinity` for perpetual repeating.
289
- *
290
- * Without setting `repeatType`, this will loop the animation.
291
- *
292
- * ```jsx
293
- * <motion.div
294
- * animate={{ rotate: 180 }}
295
- * transition={{ repeat: Infinity, duration: 2 }}
296
- * />
297
- * ```
298
- *
299
- * @public
300
- */
301
- repeat?: number;
302
- /**
303
- * How to repeat the animation. This can be either:
304
- *
305
- * "loop": Repeats the animation from the start
306
- *
307
- * "reverse": Alternates between forward and backwards playback
308
- *
309
- * "mirror": Switches `from` and `to` alternately
310
- *
311
- * ```jsx
312
- * <motion.div
313
- * animate={{ rotate: 180 }}
314
- * transition={{
315
- * repeat: 1,
316
- * repeatType: "reverse",
317
- * duration: 2
318
- * }}
319
- * />
320
- * ```
321
- *
322
- * @public
323
- */
324
- repeatType?: "loop" | "reverse" | "mirror";
325
- /**
326
- * When repeating an animation, `repeatDelay` will set the
327
- * duration of the time to wait, in seconds, between each repetition.
328
- *
329
- * ```jsx
330
- * <motion.div
331
- * animate={{ rotate: 180 }}
332
- * transition={{ repeat: Infinity, repeatDelay: 1 }}
333
- * />
334
- * ```
335
- *
336
- * @public
337
- */
338
- repeatDelay?: number;
339
- }
340
- /**
341
- * An animation that animates between two or more values over a specific duration of time.
342
- * This is the default animation for non-physical values like `color` and `opacity`.
343
- *
344
- * @public
345
- */
346
- interface Tween extends Repeat {
347
- /**
348
- * Set `type` to `"tween"` to use a duration-based tween animation.
349
- * If any non-orchestration `transition` values are set without a `type` property,
350
- * this is used as the default animation.
351
- *
352
- * ```jsx
353
- * <motion.path
354
- * animate={{ pathLength: 1 }}
355
- * transition={{ duration: 2, type: "tween" }}
356
- * />
357
- * ```
358
- *
359
- * @public
360
- */
361
- type?: "tween";
362
- /**
363
- * The duration of the tween animation. Set to `0.3` by default, 0r `0.8` if animating a series of keyframes.
364
- *
365
- * ```jsx
366
- * const variants = {
367
- * visible: {
368
- * opacity: 1,
369
- * transition: { duration: 2 }
370
- * }
371
- * }
372
- * ```
373
- *
374
- * @public
375
- */
376
- duration?: number;
377
- /**
378
- * The easing function to use. Set as one of the below.
379
- *
380
- * - The name of an existing easing function.
381
- *
382
- * - An array of four numbers to define a cubic bezier curve.
383
- *
384
- * - An easing function, that accepts and returns a value `0-1`.
385
- *
386
- * If the animating value is set as an array of multiple values for a keyframes
387
- * animation, `ease` can be set as an array of easing functions to set different easings between
388
- * each of those values.
389
- *
390
- *
391
- * ```jsx
392
- * <motion.div
393
- * animate={{ opacity: 0 }}
394
- * transition={{ ease: [0.17, 0.67, 0.83, 0.67] }}
395
- * />
396
- * ```
397
- *
398
- * @public
399
- */
400
- ease?: Easing | Easing[];
401
- /**
402
- * When animating keyframes, `times` can be used to determine where in the animation each keyframe is reached.
403
- * Each value in `times` is a value between `0` and `1`, representing `duration`.
404
- *
405
- * There must be the same number of `times` as there are keyframes.
406
- * Defaults to an array of evenly-spread durations.
407
- *
408
- * ```jsx
409
- * <motion.div
410
- * animate={{ scale: [0, 1, 0.5, 1] }}
411
- * transition={{ times: [0, 0.1, 0.9, 1] }}
412
- * />
413
- * ```
414
- *
415
- * @public
416
- */
417
- times?: number[];
418
- /**
419
- * 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.
420
- *
421
- * ```jsx
422
- * <motion.div
423
- * animate={{ backgroundColor: ["#0f0", "#00f", "#f00"] }}
424
- * transition={{ easings: ["easeIn", "easeOut"] }}
425
- * />
426
- * ```
427
- *
428
- * @public
429
- */
430
- easings?: Easing[];
431
- /**
432
- * The value to animate from.
433
- * By default, this is the current state of the animating value.
434
- *
435
- * ```jsx
436
- * <motion.div
437
- * animate={{ rotate: 180 }}
438
- * transition={{ from: 90, duration: 2 }}
439
- * />
440
- * ```
441
- *
442
- * @public
443
- */
444
- from?: number | string;
445
- }
446
- /**
447
- * An animation that simulates spring physics for realistic motion.
448
- * This is the default animation for physical values like `x`, `y`, `scale` and `rotate`.
449
- *
450
- * @public
451
- */
452
- interface Spring extends Repeat {
453
- /**
454
- * Set `type` to `"spring"` to animate using spring physics for natural
455
- * movement. Type is set to `"spring"` by default.
456
- *
457
- * ```jsx
458
- * <motion.div
459
- * animate={{ rotate: 180 }}
460
- * transition={{ type: 'spring' }}
461
- * />
462
- * ```
463
- *
464
- * @public
465
- */
466
- type: "spring";
467
- /**
468
- * Stiffness of the spring. Higher values will create more sudden movement.
469
- * Set to `100` by default.
470
- *
471
- * ```jsx
472
- * <motion.section
473
- * animate={{ rotate: 180 }}
474
- * transition={{ type: 'spring', stiffness: 50 }}
475
- * />
476
- * ```
477
- *
478
- * @public
479
- */
480
- stiffness?: number;
481
- /**
482
- * Strength of opposing force. If set to 0, spring will oscillate
483
- * indefinitely. Set to `10` by default.
484
- *
485
- * ```jsx
486
- * <motion.a
487
- * animate={{ rotate: 180 }}
488
- * transition={{ type: 'spring', damping: 300 }}
489
- * />
490
- * ```
491
- *
492
- * @public
493
- */
494
- damping?: number;
495
- /**
496
- * Mass of the moving object. Higher values will result in more lethargic
497
- * movement. Set to `1` by default.
498
- *
499
- * ```jsx
500
- * <motion.feTurbulence
501
- * animate={{ baseFrequency: 0.5 } as any}
502
- * transition={{ type: "spring", mass: 0.5 }}
503
- * />
504
- * ```
505
- *
506
- * @public
507
- */
508
- mass?: number;
509
- /**
510
- * The duration of the animation, defined in seconds. Spring animations can be a maximum of 10 seconds.
511
- *
512
- * If `bounce` is set, this defaults to `0.8`.
513
- *
514
- * Note: `duration` and `bounce` will be overridden if `stiffness`, `damping` or `mass` are set.
515
- *
516
- * ```jsx
517
- * <motion.div
518
- * animate={{ x: 100 }}
519
- * transition={{ type: "spring", duration: 0.8 }}
520
- * />
521
- * ```
522
- *
523
- * @public
524
- */
525
- duration?: number;
526
- /**
527
- * If visualDuration is set, this will override duration.
528
- *
529
- * The visual duration is a time, set in seconds, that the animation will take to visually appear to reach its target.
530
- *
531
- * In other words, the bulk of the transition will occur before this time, and the "bouncy bit" will mostly happen after.
532
- *
533
- * This makes it easier to edit a spring, as well as visually coordinate it with other time-based animations.
534
- *
535
- * ```jsx
536
- * <motion.div
537
- * animate={{ x: 100 }}
538
- * transition={{ type: "spring", visualDuration: 0.5 }}
539
- * />
540
- * ```
541
- *
542
- * @public
543
- */
544
- visualDuration?: number;
545
- /**
546
- * `bounce` determines the "bounciness" of a spring animation.
547
- *
548
- * `0` is no bounce, and `1` is extremely bouncy.
549
- *
550
- * If `duration` is set, this defaults to `0.25`.
551
- *
552
- * Note: `bounce` and `duration` will be overridden if `stiffness`, `damping` or `mass` are set.
553
- *
554
- * ```jsx
555
- * <motion.div
556
- * animate={{ x: 100 }}
557
- * transition={{ type: "spring", bounce: 0.25 }}
558
- * />
559
- * ```
560
- *
561
- * @public
562
- */
563
- bounce?: number;
564
- /**
565
- * End animation if absolute speed (in units per second) drops below this
566
- * value and delta is smaller than `restDelta`. Set to `0.01` by default.
567
- *
568
- * ```jsx
569
- * <motion.div
570
- * animate={{ rotate: 180 }}
571
- * transition={{ type: 'spring', restSpeed: 0.5 }}
572
- * />
573
- * ```
574
- *
575
- * @public
576
- */
577
- restSpeed?: number;
578
- /**
579
- * End animation if distance is below this value and speed is below
580
- * `restSpeed`. When animation ends, spring gets “snapped” to. Set to
581
- * `0.01` by default.
582
- *
583
- * ```jsx
584
- * <motion.div
585
- * animate={{ rotate: 180 }}
586
- * transition={{ type: 'spring', restDelta: 0.5 }}
587
- * />
588
- * ```
589
- *
590
- * @public
591
- */
592
- restDelta?: number;
593
- /**
594
- * The value to animate from.
595
- * By default, this is the initial state of the animating value.
596
- *
597
- * ```jsx
598
- * <motion.div
599
- * animate={{ rotate: 180 }}
600
- * transition={{ type: 'spring', from: 90 }}
601
- * />
602
- * ```
603
- *
604
- * @public
605
- */
606
- from?: number | string;
607
- /**
608
- * The initial velocity of the spring. By default this is the current velocity of the component.
609
- *
610
- * ```jsx
611
- * <motion.div
612
- * animate={{ rotate: 180 }}
613
- * transition={{ type: 'spring', velocity: 2 }}
614
- * />
615
- * ```
616
- *
617
- * @public
618
- */
619
- velocity?: number;
620
- }
621
- /**
622
- * An animation that decelerates a value based on its initial velocity,
623
- * usually used to implement inertial scrolling.
624
- *
625
- * Optionally, `min` and `max` boundaries can be defined, and inertia
626
- * will snap to these with a spring animation.
627
- *
628
- * This animation will automatically precalculate a target value,
629
- * which can be modified with the `modifyTarget` property.
630
- *
631
- * This allows you to add snap-to-grid or similar functionality.
632
- *
633
- * Inertia is also the animation used for `dragTransition`, and can be configured via that prop.
634
- *
635
- * @public
636
- */
637
- interface Inertia {
638
- /**
639
- * Set `type` to animate using the inertia animation. Set to `"tween"` by
640
- * default. This can be used for natural deceleration, like momentum scrolling.
641
- *
642
- * ```jsx
643
- * <motion.div
644
- * animate={{ rotate: 180 }}
645
- * transition={{ type: "inertia", velocity: 50 }}
646
- * />
647
- * ```
648
- *
649
- * @public
650
- */
651
- type: "inertia";
652
- /**
653
- * A function that receives the automatically-calculated target and returns a new one. Useful for snapping the target to a grid.
654
- *
655
- * ```jsx
656
- * <motion.div
657
- * drag
658
- * dragTransition={{
659
- * power: 0,
660
- * // Snap calculated target to nearest 50 pixels
661
- * modifyTarget: target => Math.round(target / 50) * 50
662
- * }}
663
- * />
664
- * ```
665
- *
666
- * @public
667
- */
668
- modifyTarget?(v: number): number;
669
- /**
670
- * If `min` or `max` is set, this affects the stiffness of the bounce
671
- * spring. Higher values will create more sudden movement. Set to `500` by
672
- * default.
673
- *
674
- * ```jsx
675
- * <motion.div
676
- * drag
677
- * dragTransition={{
678
- * min: 0,
679
- * max: 100,
680
- * bounceStiffness: 100
681
- * }}
682
- * />
683
- * ```
684
- *
685
- * @public
686
- */
687
- bounceStiffness?: number;
688
- /**
689
- * If `min` or `max` is set, this affects the damping of the bounce spring.
690
- * If set to `0`, spring will oscillate indefinitely. Set to `10` by
691
- * default.
692
- *
693
- * ```jsx
694
- * <motion.div
695
- * drag
696
- * dragTransition={{
697
- * min: 0,
698
- * max: 100,
699
- * bounceDamping: 8
700
- * }}
701
- * />
702
- * ```
703
- *
704
- * @public
705
- */
706
- bounceDamping?: number;
707
- /**
708
- * A higher power value equals a further target. Set to `0.8` by default.
709
- *
710
- * ```jsx
711
- * <motion.div
712
- * drag
713
- * dragTransition={{ power: 0.2 }}
714
- * />
715
- * ```
716
- *
717
- * @public
718
- */
719
- power?: number;
720
- /**
721
- * Adjusting the time constant will change the duration of the
722
- * deceleration, thereby affecting its feel. Set to `700` by default.
723
- *
724
- * ```jsx
725
- * <motion.div
726
- * drag
727
- * dragTransition={{ timeConstant: 200 }}
728
- * />
729
- * ```
730
- *
731
- * @public
732
- */
733
- timeConstant?: number;
734
- /**
735
- * End the animation if the distance to the animation target is below this value, and the absolute speed is below `restSpeed`.
736
- * When the animation ends, the value gets snapped to the animation target. Set to `0.01` by default.
737
- * Generally the default values provide smooth animation endings, only in rare cases should you need to customize these.
738
- *
739
- * ```jsx
740
- * <motion.div
741
- * drag
742
- * dragTransition={{ restDelta: 10 }}
743
- * />
744
- * ```
745
- *
746
- * @public
747
- */
748
- restDelta?: number;
749
- /**
750
- * 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).
751
- *
752
- * ```jsx
753
- * <motion.div
754
- * drag
755
- * dragTransition={{ min: 0, max: 100 }}
756
- * />
757
- * ```
758
- *
759
- * @public
760
- */
761
- min?: number;
762
- /**
763
- * Maximum constraint. If set, the value will "bump" against this value (or immediately snap to it, if the initial animation value exceeds this value).
764
- *
765
- * ```jsx
766
- * <motion.div
767
- * drag
768
- * dragTransition={{ min: 0, max: 100 }}
769
- * />
770
- * ```
771
- *
772
- * @public
773
- */
774
- max?: number;
775
- /**
776
- * The value to animate from. By default, this is the current state of the animating value.
777
- *
778
- * ```jsx
779
- * <Frame
780
- * drag
781
- * dragTransition={{ from: 50 }}
782
- * />
783
- * ```
784
- *
785
- * @public
786
- */
787
- from?: number | string;
788
- /**
789
- * The initial velocity of the animation.
790
- * By default this is the current velocity of the component.
791
- *
792
- * ```jsx
793
- * <motion.div
794
- * animate={{ rotate: 180 }}
795
- * transition={{ type: 'inertia', velocity: 200 }}
796
- * />
797
- * ```
798
- *
799
- * @public
800
- */
801
- velocity?: number;
802
- }
803
- /**
804
- * Keyframes tweens between multiple `values`.
805
- *
806
- * These tweens can be arranged using the `duration`, `easings`, and `times` properties.
807
- */
808
- interface Keyframes {
809
- /**
810
- * Set `type` to `"keyframes"` to animate using the keyframes animation.
811
- * Set to `"tween"` by default. This can be used to animate between a series of values.
812
- *
813
- * @public
814
- */
815
- type: "keyframes";
816
- /**
817
- * An array of numbers between 0 and 1, where `1` represents the `total` duration.
818
- *
819
- * 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`.
820
- *
821
- * Defaults to an array of evenly-spread durations.
822
- *
823
- * @public
824
- */
825
- times?: number[];
826
- /**
827
- * An array of easing functions for each generated tween, or a single easing function applied to all tweens.
828
- *
829
- * This array should be one item less than `values`, as these easings apply to the transitions *between* the `values`.
830
- *
831
- * ```jsx
832
- * const transition = {
833
- * backgroundColor: {
834
- * type: 'keyframes',
835
- * easings: ['circIn', 'circOut']
836
- * }
837
- * }
838
- * ```
839
- *
840
- * @public
841
- */
842
- ease?: Easing | Easing[];
843
- /**
844
- * The total duration of the animation. Set to `0.3` by default.
845
- *
846
- * ```jsx
847
- * const transition = {
848
- * type: "keyframes",
849
- * duration: 2
850
- * }
851
- *
852
- * <Frame
853
- * animate={{ opacity: 0 }}
854
- * transition={transition}
855
- * />
856
- * ```
857
- *
858
- * @public
859
- */
860
- duration?: number;
861
- /**
862
- * @public
863
- */
864
- repeatDelay?: number;
865
- }
866
- /**
867
- * @public
868
- */
869
- interface None {
870
- /**
871
- * Set `type` to `false` for an instant transition.
872
- *
873
- * @public
874
- */
875
- type: false;
876
- }
877
- /**
878
- * @public
879
- */
880
- type PermissiveTransitionDefinition = {
881
- [key: string]: any;
882
- };
883
- /**
884
- * @public
885
- */
886
- type TransitionDefinition = Tween | Spring | Keyframes | Inertia | None | PermissiveTransitionDefinition;
887
- type TransitionMap = Orchestration & TransitionDefinition & {
888
- [key: string]: TransitionDefinition;
889
- };
890
- /**
891
- * Transition props
892
- *
893
- * @public
894
- */
895
- type Transition = (Orchestration & Repeat & TransitionDefinition) | (Orchestration & Repeat & TransitionMap);
896
- type Omit$1<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
897
- type CSSPropertiesWithoutTransitionOrSingleTransforms = Omit$1<CSSProperties, "transition" | "rotate" | "scale" | "perspective">;
898
- type SVGTransformAttributes = {
899
- attrX?: number;
900
- attrY?: number;
901
- attrScale?: number;
902
- };
903
- type TargetProperties = CSSPropertiesWithoutTransitionOrSingleTransforms & SVGAttributes<SVGElement> & SVGTransformAttributes & TransformProperties & CustomStyles & SVGPathProperties & VariableKeyframesDefinition;
904
- /**
905
- * @public
906
- */
907
- type MakeCustomValueType<T> = {
908
- [K in keyof T]: T[K] | CustomValueType;
909
- };
910
- /**
911
- * @public
912
- */
913
- type Target = MakeCustomValueType<TargetProperties>;
914
- /**
915
- * @public
916
- */
917
- type MakeKeyframes<T> = {
918
- [K in keyof T]: T[K] | T[K][] | [null, ...T[K][]];
919
- };
920
- /**
921
- * @public
922
- */
923
- type TargetWithKeyframes = MakeKeyframes<Target>;
924
- /**
925
- * An object that specifies values to animate to. Each value may be set either as
926
- * a single value, or an array of values.
927
- *
928
- * It may also option contain these properties:
929
- *
930
- * - `transition`: Specifies transitions for all or individual values.
931
- * - `transitionEnd`: Specifies values to set when the animation finishes.
932
- *
933
- * ```jsx
934
- * const target = {
935
- * x: "0%",
936
- * opacity: 0,
937
- * transition: { duration: 1 },
938
- * transitionEnd: { display: "none" }
939
- * }
940
- * ```
941
- *
942
- * @public
943
- */
944
- type TargetAndTransition = TargetWithKeyframes & {
945
- transition?: Transition;
946
- transitionEnd?: Target;
947
- };
948
- type TargetResolver = (custom: any, current: Target, velocity: Target) => TargetAndTransition | string;
949
- /**
950
- * @public
951
- */
952
- type Variant = TargetAndTransition | TargetResolver;
953
- /**
954
- * @public
955
- */
956
- type Variants = {
957
- [key: string]: Variant;
958
- };
959
- /**
960
- * @public
961
- */
962
- interface CustomValueType {
963
- mix: (from: any, to: any) => (p: number) => number | string;
964
- toValue: () => number | string;
965
- }
966
-
967
- type ReducedMotionConfig = "always" | "never" | "user";
968
- /**
969
- * @public
970
- */
971
- interface MotionConfigContext {
972
- /**
973
- * Internal, exported only for usage in Framer
974
- */
975
- transformPagePoint: TransformPoint;
976
- /**
977
- * Internal. Determines whether this is a static context ie the Framer canvas. If so,
978
- * it'll disable all dynamic functionality.
979
- */
980
- isStatic: boolean;
981
- /**
982
- * Defines a new default transition for the entire tree.
983
- *
984
- * @public
985
- */
986
- transition?: Transition;
987
- /**
988
- * If true, will respect the device prefersReducedMotion setting by switching
989
- * transform animations off.
990
- *
991
- * @public
992
- */
993
- reducedMotion?: ReducedMotionConfig;
994
- /**
995
- * A custom `nonce` attribute used when wanting to enforce a Content Security Policy (CSP).
996
- * For more details see:
997
- * https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/style-src#unsafe_inline_styles
998
- *
999
- * @public
1000
- */
1001
- nonce?: string;
1002
- }
1003
- /**
1004
- * @public
1005
- */
1006
- declare const MotionConfigContext: React$1.Context<MotionConfigContext>;
1007
-
1008
- /**
1009
- * @public
1010
- */
1011
- interface PresenceContextProps {
1012
- id: string;
1013
- isPresent: boolean;
1014
- register: (id: string | number) => () => void;
1015
- onExitComplete?: (id: string | number) => void;
1016
- initial?: false | VariantLabels;
1017
- custom?: any;
1018
- }
1019
-
1020
- type InitialPromotionConfig = {
1021
- /**
1022
- * The initial transition to use when the elements in this group mount (and automatically promoted).
1023
- * Subsequent updates should provide a transition in the promote method.
1024
- */
1025
- transition?: Transition;
1026
- /**
1027
- * If the follow tree should preserve its opacity when the lead is promoted on mount
1028
- */
1029
- shouldPreserveFollowOpacity?: (member: IProjectionNode) => boolean;
1030
- };
1031
-
1032
- interface WithDepth {
1033
- depth: number;
1034
- }
1035
-
1036
- declare class FlatTree {
1037
- private children;
1038
- private isDirty;
1039
- add(child: WithDepth): void;
1040
- remove(child: WithDepth): void;
1041
- forEach(callback: (child: WithDepth) => void): void;
1042
- }
1043
-
1044
- declare class NodeStack {
1045
- lead?: IProjectionNode;
1046
- prevLead?: IProjectionNode;
1047
- members: IProjectionNode[];
1048
- add(node: IProjectionNode): void;
1049
- remove(node: IProjectionNode): void;
1050
- relegate(node: IProjectionNode): boolean;
1051
- promote(node: IProjectionNode, preserveFollowOpacity?: boolean): void;
1052
- exitAnimationComplete(): void;
1053
- scheduleRender(): void;
1054
- /**
1055
- * Clear any leads that have been removed this render to prevent them from being
1056
- * used in future animations and to prevent memory leaks
1057
- */
1058
- removeLeadSnapshot(): void;
1059
- }
1060
-
1061
- interface Measurements {
1062
- animationId: number;
1063
- measuredBox: Box;
1064
- layoutBox: Box;
1065
- latestValues: ResolvedValues;
1066
- source: number;
1067
- }
1068
- type Phase = "snapshot" | "measure";
1069
- interface ScrollMeasurements {
1070
- animationId: number;
1071
- phase: Phase;
1072
- offset: Point;
1073
- isRoot: boolean;
1074
- wasRoot: boolean;
1075
- }
1076
- type LayoutEvents = "willUpdate" | "didUpdate" | "beforeMeasure" | "measure" | "projectionUpdate" | "animationStart" | "animationComplete";
1077
- interface IProjectionNode<I = unknown> {
1078
- id: number;
1079
- animationId: number;
1080
- parent?: IProjectionNode;
1081
- relativeParent?: IProjectionNode;
1082
- root?: IProjectionNode;
1083
- children: Set<IProjectionNode>;
1084
- path: IProjectionNode[];
1085
- nodes?: FlatTree;
1086
- depth: number;
1087
- instance: I;
1088
- mount: (node: I, isLayoutDirty?: boolean) => void;
1089
- unmount: () => void;
1090
- options: ProjectionNodeOptions;
1091
- setOptions(options: ProjectionNodeOptions): void;
1092
- layout?: Measurements;
1093
- snapshot?: Measurements;
1094
- target?: Box;
1095
- relativeTarget?: Box;
1096
- relativeTargetOrigin?: Box;
1097
- targetDelta?: Delta;
1098
- targetWithTransforms?: Box;
1099
- scroll?: ScrollMeasurements;
1100
- treeScale?: Point;
1101
- projectionDelta?: Delta;
1102
- projectionDeltaWithTransform?: Delta;
1103
- latestValues: ResolvedValues;
1104
- isLayoutDirty: boolean;
1105
- isProjectionDirty: boolean;
1106
- isSharedProjectionDirty: boolean;
1107
- isTransformDirty: boolean;
1108
- resolvedRelativeTargetAt?: number;
1109
- shouldResetTransform: boolean;
1110
- prevTransformTemplateValue: string | undefined;
1111
- isUpdateBlocked(): boolean;
1112
- updateManuallyBlocked: boolean;
1113
- updateBlockedByResize: boolean;
1114
- blockUpdate(): void;
1115
- unblockUpdate(): void;
1116
- isUpdating: boolean;
1117
- needsReset: boolean;
1118
- startUpdate(): void;
1119
- willUpdate(notifyListeners?: boolean): void;
1120
- didUpdate(): void;
1121
- measure(removeTransform?: boolean): Measurements;
1122
- measurePageBox(): Box;
1123
- updateLayout(): void;
1124
- updateSnapshot(): void;
1125
- clearSnapshot(): void;
1126
- updateScroll(phase?: Phase): void;
1127
- scheduleUpdateProjection(): void;
1128
- scheduleCheckAfterUnmount(): void;
1129
- checkUpdateFailed(): void;
1130
- sharedNodes: Map<string, NodeStack>;
1131
- registerSharedNode(id: string, node: IProjectionNode): void;
1132
- getStack(): NodeStack | undefined;
1133
- isVisible: boolean;
1134
- hide(): void;
1135
- show(): void;
1136
- scheduleRender(notifyAll?: boolean): void;
1137
- getClosestProjectingParent(): IProjectionNode | undefined;
1138
- setTargetDelta(delta: Delta): void;
1139
- resetTransform(): void;
1140
- resetSkewAndRotation(): void;
1141
- applyTransform(box: Box, transformOnly?: boolean): Box;
1142
- resolveTargetDelta(force?: boolean): void;
1143
- calcProjection(): void;
1144
- getProjectionStyles(styleProp?: MotionStyle): MotionStyle | undefined;
1145
- clearMeasurements(): void;
1146
- resetTree(): void;
1147
- isProjecting(): boolean;
1148
- animationValues?: ResolvedValues;
1149
- currentAnimation?: AnimationPlaybackControls;
1150
- isTreeAnimating?: boolean;
1151
- isAnimationBlocked?: boolean;
1152
- isTreeAnimationBlocked: () => boolean;
1153
- setAnimationOrigin(delta: Delta): void;
1154
- startAnimation(transition: Transition): void;
1155
- finishAnimation(): void;
1156
- hasCheckedOptimisedAppear: boolean;
1157
- isLead(): boolean;
1158
- promote(options?: {
1159
- needsReset?: boolean;
1160
- transition?: Transition;
1161
- preserveFollowOpacity?: boolean;
1162
- }): void;
1163
- relegate(): boolean;
1164
- resumeFrom?: IProjectionNode;
1165
- resumingFrom?: IProjectionNode;
1166
- isPresent?: boolean;
1167
- addEventListener(name: LayoutEvents, handler: any): VoidFunction;
1168
- notifyListeners(name: LayoutEvents, ...args: any): void;
1169
- hasListeners(name: LayoutEvents): boolean;
1170
- hasTreeAnimated: boolean;
1171
- preserveOpacity?: boolean;
1172
- }
1173
- interface ProjectionNodeOptions {
1174
- animate?: boolean;
1175
- layoutScroll?: boolean;
1176
- layoutRoot?: boolean;
1177
- alwaysMeasureLayout?: boolean;
1178
- onExitComplete?: VoidFunction;
1179
- animationType?: "size" | "position" | "both" | "preserve-aspect";
1180
- layoutId?: string;
1181
- layout?: boolean | string;
1182
- visualElement?: VisualElement;
1183
- crossfade?: boolean;
1184
- transition?: Transition;
1185
- initialPromotionConfig?: InitialPromotionConfig;
1186
- }
1187
-
1188
- /**
1189
- * @public
1190
- */
1191
- type Subscriber<T> = (v: T) => void;
1192
- interface MotionValueEventCallbacks<V> {
1193
- animationStart: () => void;
1194
- animationComplete: () => void;
1195
- animationCancel: () => void;
1196
- change: (latestValue: V) => void;
1197
- renderRequest: () => void;
1198
- }
1199
- interface ResolvedValues$1 {
1200
- [key: string]: string | number;
1201
- }
1202
- interface Owner {
1203
- current: HTMLElement | unknown;
1204
- getProps: () => {
1205
- onUpdate?: (latest: ResolvedValues$1) => void;
1206
- transformTemplate?: (transform: TransformProperties, generatedTransform: string) => string;
1207
- };
1208
- }
1209
- /**
1210
- * `MotionValue` is used to track the state and velocity of motion values.
1211
- *
1212
- * @public
1213
- */
1214
- declare class MotionValue<V = any> {
1215
- /**
1216
- * This will be replaced by the build step with the latest version number.
1217
- * When MotionValues are provided to motion components, warn if versions are mixed.
1218
- */
1219
- version: string;
1220
- /**
1221
- * If a MotionValue has an owner, it was created internally within Motion
1222
- * and therefore has no external listeners. It is therefore safe to animate via WAAPI.
1223
- */
1224
- owner?: Owner;
1225
- /**
1226
- * The current state of the `MotionValue`.
1227
- */
1228
- private current;
1229
- /**
1230
- * The previous state of the `MotionValue`.
1231
- */
1232
- private prev;
1233
- /**
1234
- * The previous state of the `MotionValue` at the end of the previous frame.
1235
- */
1236
- private prevFrameValue;
1237
- /**
1238
- * The last time the `MotionValue` was updated.
1239
- */
1240
- updatedAt: number;
1241
- /**
1242
- * The time `prevFrameValue` was updated.
1243
- */
1244
- prevUpdatedAt: number | undefined;
1245
- private stopPassiveEffect?;
1246
- /**
1247
- * A reference to the currently-controlling animation.
1248
- */
1249
- animation?: AnimationPlaybackControls;
1250
- setCurrent(current: V): void;
1251
- setPrevFrameValue(prevFrameValue?: V | undefined): void;
1252
- /**
1253
- * Adds a function that will be notified when the `MotionValue` is updated.
1254
- *
1255
- * It returns a function that, when called, will cancel the subscription.
1256
- *
1257
- * When calling `onChange` inside a React component, it should be wrapped with the
1258
- * `useEffect` hook. As it returns an unsubscribe function, this should be returned
1259
- * from the `useEffect` function to ensure you don't add duplicate subscribers..
1260
- *
1261
- * ```jsx
1262
- * export const MyComponent = () => {
1263
- * const x = useMotionValue(0)
1264
- * const y = useMotionValue(0)
1265
- * const opacity = useMotionValue(1)
1266
- *
1267
- * useEffect(() => {
1268
- * function updateOpacity() {
1269
- * const maxXY = Math.max(x.get(), y.get())
1270
- * const newOpacity = transform(maxXY, [0, 100], [1, 0])
1271
- * opacity.set(newOpacity)
1272
- * }
1273
- *
1274
- * const unsubscribeX = x.on("change", updateOpacity)
1275
- * const unsubscribeY = y.on("change", updateOpacity)
1276
- *
1277
- * return () => {
1278
- * unsubscribeX()
1279
- * unsubscribeY()
1280
- * }
1281
- * }, [])
1282
- *
1283
- * return <motion.div style={{ x }} />
1284
- * }
1285
- * ```
1286
- *
1287
- * @param subscriber - A function that receives the latest value.
1288
- * @returns A function that, when called, will cancel this subscription.
1289
- *
1290
- * @deprecated
1291
- */
1292
- onChange(subscription: Subscriber<V>): () => void;
1293
- /**
1294
- * An object containing a SubscriptionManager for each active event.
1295
- */
1296
- private events;
1297
- on<EventName extends keyof MotionValueEventCallbacks<V>>(eventName: EventName, callback: MotionValueEventCallbacks<V>[EventName]): VoidFunction;
1298
- clearListeners(): void;
1299
- /**
1300
- * Sets the state of the `MotionValue`.
1301
- *
1302
- * @remarks
1303
- *
1304
- * ```jsx
1305
- * const x = useMotionValue(0)
1306
- * x.set(10)
1307
- * ```
1308
- *
1309
- * @param latest - Latest value to set.
1310
- * @param render - Whether to notify render subscribers. Defaults to `true`
1311
- *
1312
- * @public
1313
- */
1314
- set(v: V, render?: boolean): void;
1315
- setWithVelocity(prev: V, current: V, delta: number): void;
1316
- /**
1317
- * Set the state of the `MotionValue`, stopping any active animations,
1318
- * effects, and resets velocity to `0`.
1319
- */
1320
- jump(v: V, endAnimation?: boolean): void;
1321
- updateAndNotify: (v: V, render?: boolean) => void;
1322
- /**
1323
- * Returns the latest state of `MotionValue`
1324
- *
1325
- * @returns - The latest state of `MotionValue`
1326
- *
1327
- * @public
1328
- */
1329
- get(): NonNullable<V>;
1330
- /**
1331
- * @public
1332
- */
1333
- getPrevious(): V | undefined;
1334
- /**
1335
- * Returns the latest velocity of `MotionValue`
1336
- *
1337
- * @returns - The latest velocity of `MotionValue`. Returns `0` if the state is non-numerical.
1338
- *
1339
- * @public
1340
- */
1341
- getVelocity(): number;
1342
- hasAnimated: boolean;
1343
- /**
1344
- * Stop the currently active animation.
1345
- *
1346
- * @public
1347
- */
1348
- stop(): void;
1349
- /**
1350
- * Returns `true` if this value is currently animating.
1351
- *
1352
- * @public
1353
- */
1354
- isAnimating(): boolean;
1355
- private clearAnimation;
1356
- /**
1357
- * Destroy and clean up subscribers to this `MotionValue`.
1358
- *
1359
- * The `MotionValue` hooks like `useMotionValue` and `useTransform` automatically
1360
- * handle the lifecycle of the returned `MotionValue`, so this method is only necessary if you've manually
1361
- * created a `MotionValue` via the `motionValue` function.
1362
- *
1363
- * @public
1364
- */
1365
- destroy(): void;
1366
- }
1367
-
1368
- type AnimationType = "animate" | "whileHover" | "whileTap" | "whileDrag" | "whileFocus" | "whileInView" | "exit";
1369
-
1370
- type VisualElementAnimationOptions = {
1371
- delay?: number;
1372
- transitionOverride?: Transition;
1373
- custom?: any;
1374
- type?: AnimationType;
1375
- };
1376
-
1377
- interface AnimationState {
1378
- animateChanges: (type?: AnimationType) => Promise<any>;
1379
- setActive: (type: AnimationType, isActive: boolean, options?: VisualElementAnimationOptions) => Promise<any>;
1380
- setAnimateFunction: (fn: any) => void;
1381
- getState: () => {
1382
- [key: string]: AnimationTypeState;
1383
- };
1384
- reset: () => void;
1385
- }
1386
- interface AnimationTypeState {
1387
- isActive: boolean;
1388
- protectedKeys: {
1389
- [key: string]: true;
1390
- };
1391
- needsAnimating: {
1392
- [key: string]: boolean;
1393
- };
1394
- prevResolvedValues: {
1395
- [key: string]: any;
1396
- };
1397
- prevProp?: VariantLabels | TargetAndTransition;
1398
- }
1399
-
1400
- type UnresolvedKeyframes<T extends string | number> = Array<T | null>;
1401
- type ResolvedKeyframes<T extends string | number> = Array<T>;
1402
- type OnKeyframesResolved<T extends string | number> = (resolvedKeyframes: ResolvedKeyframes<T>, finalKeyframe: T) => void;
1403
- declare class KeyframeResolver<T extends string | number = any> {
1404
- name?: string;
1405
- element?: VisualElement<any>;
1406
- finalKeyframe?: T;
1407
- suspendedScrollY?: number;
1408
- protected unresolvedKeyframes: UnresolvedKeyframes<string | number>;
1409
- private motionValue?;
1410
- private onComplete;
1411
- /**
1412
- * Track whether this resolver has completed. Once complete, it never
1413
- * needs to attempt keyframe resolution again.
1414
- */
1415
- private isComplete;
1416
- /**
1417
- * Track whether this resolver is async. If it is, it'll be added to the
1418
- * resolver queue and flushed in the next frame. Resolvers that aren't going
1419
- * to trigger read/write thrashing don't need to be async.
1420
- */
1421
- private isAsync;
1422
- /**
1423
- * Track whether this resolver needs to perform a measurement
1424
- * to resolve its keyframes.
1425
- */
1426
- needsMeasurement: boolean;
1427
- /**
1428
- * Track whether this resolver is currently scheduled to resolve
1429
- * to allow it to be cancelled and resumed externally.
1430
- */
1431
- isScheduled: boolean;
1432
- constructor(unresolvedKeyframes: UnresolvedKeyframes<string | number>, onComplete: OnKeyframesResolved<T>, name?: string, motionValue?: MotionValue<T>, element?: VisualElement<any>, isAsync?: boolean);
1433
- scheduleResolve(): void;
1434
- readKeyframes(): void;
1435
- setFinalKeyframe(): void;
1436
- measureInitialState(): void;
1437
- renderEndStyles(): void;
1438
- measureEndState(): void;
1439
- complete(): void;
1440
- cancel(): void;
1441
- resume(): void;
1442
- }
1443
-
1444
- /**
1445
- * A VisualElement is an imperative abstraction around UI elements such as
1446
- * HTMLElement, SVGElement, Three.Object3D etc.
1447
- */
1448
- declare abstract class VisualElement<Instance = unknown, RenderState = unknown, Options extends {} = {}> {
1449
- /**
1450
- * VisualElements are arranged in trees mirroring that of the React tree.
1451
- * Each type of VisualElement has a unique name, to detect when we're crossing
1452
- * type boundaries within that tree.
1453
- */
1454
- abstract type: string;
1455
- /**
1456
- * An `Array.sort` compatible function that will compare two Instances and
1457
- * compare their respective positions within the tree.
1458
- */
1459
- abstract sortInstanceNodePosition(a: Instance, b: Instance): number;
1460
- /**
1461
- * Measure the viewport-relative bounding box of the Instance.
1462
- */
1463
- abstract measureInstanceViewportBox(instance: Instance, props: MotionProps & Partial<MotionConfigContext>): Box;
1464
- /**
1465
- * When a value has been removed from all animation props we need to
1466
- * pick a target to animate back to. For instance, for HTMLElements
1467
- * we can look in the style prop.
1468
- */
1469
- abstract getBaseTargetFromProps(props: MotionProps, key: string): string | number | undefined | MotionValue;
1470
- /**
1471
- * When we first animate to a value we need to animate it *from* a value.
1472
- * Often this have been specified via the initial prop but it might be
1473
- * that the value needs to be read from the Instance.
1474
- */
1475
- abstract readValueFromInstance(instance: Instance, key: string, options: Options): string | number | null | undefined;
1476
- /**
1477
- * When a value has been removed from the VisualElement we use this to remove
1478
- * it from the inherting class' unique render state.
1479
- */
1480
- abstract removeValueFromRenderState(key: string, renderState: RenderState): void;
1481
- /**
1482
- * Run before a React or VisualElement render, builds the latest motion
1483
- * values into an Instance-specific format. For example, HTMLVisualElement
1484
- * will use this step to build `style` and `var` values.
1485
- */
1486
- abstract build(renderState: RenderState, latestValues: ResolvedValues, props: MotionProps): void;
1487
- /**
1488
- * Apply the built values to the Instance. For example, HTMLElements will have
1489
- * styles applied via `setProperty` and the style attribute, whereas SVGElements
1490
- * will have values applied to attributes.
1491
- */
1492
- abstract renderInstance(instance: Instance, renderState: RenderState, styleProp?: MotionStyle, projection?: IProjectionNode): void;
1493
- /**
1494
- * This method is called when a transform property is bound to a motion value.
1495
- * It's currently used to measure SVG elements when a new transform property is bound.
1496
- */
1497
- onBindTransform?(): void;
1498
- /**
1499
- * If the component child is provided as a motion value, handle subscriptions
1500
- * with the renderer-specific VisualElement.
1501
- */
1502
- handleChildMotionValue?(): void;
1503
- /**
1504
- * This method takes React props and returns found MotionValues. For example, HTML
1505
- * MotionValues will be found within the style prop, whereas for Three.js within attribute arrays.
1506
- *
1507
- * This isn't an abstract method as it needs calling in the constructor, but it is
1508
- * intended to be one.
1509
- */
1510
- scrapeMotionValuesFromProps(_props: MotionProps, _prevProps: MotionProps, _visualElement: VisualElement): {
1511
- [key: string]: MotionValue | string | number;
1512
- };
1513
- /**
1514
- * A reference to the current underlying Instance, e.g. a HTMLElement
1515
- * or Three.Mesh etc.
1516
- */
1517
- current: Instance | null;
1518
- /**
1519
- * A reference to the parent VisualElement (if exists).
1520
- */
1521
- parent: VisualElement | undefined;
1522
- /**
1523
- * A set containing references to this VisualElement's children.
1524
- */
1525
- children: Set<VisualElement<unknown, unknown, {}>>;
1526
- /**
1527
- * The depth of this VisualElement within the overall VisualElement tree.
1528
- */
1529
- depth: number;
1530
- /**
1531
- * The current render state of this VisualElement. Defined by inherting VisualElements.
1532
- */
1533
- renderState: RenderState;
1534
- /**
1535
- * An object containing the latest static values for each of this VisualElement's
1536
- * MotionValues.
1537
- */
1538
- latestValues: ResolvedValues;
1539
- /**
1540
- * Determine what role this visual element should take in the variant tree.
1541
- */
1542
- isVariantNode: boolean;
1543
- isControllingVariants: boolean;
1544
- /**
1545
- * If this component is part of the variant tree, it should track
1546
- * any children that are also part of the tree. This is essentially
1547
- * a shadow tree to simplify logic around how to stagger over children.
1548
- */
1549
- variantChildren?: Set<VisualElement>;
1550
- /**
1551
- * Decides whether this VisualElement should animate in reduced motion
1552
- * mode.
1553
- *
1554
- * TODO: This is currently set on every individual VisualElement but feels
1555
- * like it could be set globally.
1556
- */
1557
- shouldReduceMotion: boolean | null;
1558
- /**
1559
- * Normally, if a component is controlled by a parent's variants, it can
1560
- * rely on that ancestor to trigger animations further down the tree.
1561
- * However, if a component is created after its parent is mounted, the parent
1562
- * won't trigger that mount animation so the child needs to.
1563
- *
1564
- * TODO: This might be better replaced with a method isParentMounted
1565
- */
1566
- manuallyAnimateOnMount: boolean;
1567
- /**
1568
- * This can be set by AnimatePresence to force components that mount
1569
- * at the same time as it to mount as if they have initial={false} set.
1570
- */
1571
- blockInitialAnimation: boolean;
1572
- /**
1573
- * A reference to this VisualElement's projection node, used in layout animations.
1574
- */
1575
- projection?: IProjectionNode;
1576
- /**
1577
- * A map of all motion values attached to this visual element. Motion
1578
- * values are source of truth for any given animated value. A motion
1579
- * value might be provided externally by the component via props.
1580
- */
1581
- values: Map<string, MotionValue<any>>;
1582
- /**
1583
- * The AnimationState, this is hydrated by the animation Feature.
1584
- */
1585
- animationState?: AnimationState;
1586
- KeyframeResolver: typeof KeyframeResolver;
1587
- /**
1588
- * The options used to create this VisualElement. The Options type is defined
1589
- * by the inheriting VisualElement and is passed straight through to the render functions.
1590
- */
1591
- readonly options: Options;
1592
- /**
1593
- * A reference to the latest props provided to the VisualElement's host React component.
1594
- */
1595
- props: MotionProps;
1596
- prevProps?: MotionProps;
1597
- presenceContext: PresenceContextProps | null;
1598
- prevPresenceContext?: PresenceContextProps | null;
1599
- /**
1600
- * Cleanup functions for active features (hover/tap/exit etc)
1601
- */
1602
- private features;
1603
- /**
1604
- * A map of every subscription that binds the provided or generated
1605
- * motion values onChange listeners to this visual element.
1606
- */
1607
- private valueSubscriptions;
1608
- /**
1609
- * A reference to the ReducedMotionConfig passed to the VisualElement's host React component.
1610
- */
1611
- private reducedMotionConfig;
1612
- /**
1613
- * On mount, this will be hydrated with a callback to disconnect
1614
- * this visual element from its parent on unmount.
1615
- */
1616
- private removeFromVariantTree;
1617
- /**
1618
- * A reference to the previously-provided motion values as returned
1619
- * from scrapeMotionValuesFromProps. We use the keys in here to determine
1620
- * if any motion values need to be removed after props are updated.
1621
- */
1622
- private prevMotionValues;
1623
- /**
1624
- * When values are removed from all animation props we need to search
1625
- * for a fallback value to animate to. These values are tracked in baseTarget.
1626
- */
1627
- private baseTarget;
1628
- /**
1629
- * Create an object of the values we initially animated from (if initial prop present).
1630
- */
1631
- private initialValues;
1632
- /**
1633
- * An object containing a SubscriptionManager for each active event.
1634
- */
1635
- private events;
1636
- /**
1637
- * An object containing an unsubscribe function for each prop event subscription.
1638
- * For example, every "Update" event can have multiple subscribers via
1639
- * VisualElement.on(), but only one of those can be defined via the onUpdate prop.
1640
- */
1641
- private propEventSubscriptions;
1642
- private onUpdate?;
1643
- constructor({ parent, props, presenceContext, reducedMotionConfig, blockInitialAnimation, visualState, }: VisualElementOptions<Instance, RenderState>, options?: Options);
1644
- mount(instance: Instance): void;
1645
- unmount(): void;
1646
- private bindToMotionValue;
1647
- sortNodePosition(other: VisualElement<Instance>): number;
1648
- updateFeatures(): void;
1649
- notifyUpdate: () => void;
1650
- triggerBuild(): void;
1651
- render: () => void;
1652
- private renderScheduledAt;
1653
- scheduleRender: () => void;
1654
- /**
1655
- * Measure the current viewport box with or without transforms.
1656
- * Only measures axis-aligned boxes, rotate and skew must be manually
1657
- * removed with a re-render to work.
1658
- */
1659
- measureViewportBox(): Box;
1660
- getStaticValue(key: string): string | number;
1661
- setStaticValue(key: string, value: string | number): void;
1662
- /**
1663
- * Update the provided props. Ensure any newly-added motion values are
1664
- * added to our map, old ones removed, and listeners updated.
1665
- */
1666
- update(props: MotionProps, presenceContext: PresenceContextProps | null): void;
1667
- getProps(): MotionProps;
1668
- /**
1669
- * Returns the variant definition with a given name.
1670
- */
1671
- getVariant(name: string): Variant | undefined;
1672
- /**
1673
- * Returns the defined default transition on this component.
1674
- */
1675
- getDefaultTransition(): Transition | undefined;
1676
- getTransformPagePoint(): any;
1677
- getClosestVariantNode(): VisualElement | undefined;
1678
- /**
1679
- * Add a child visual element to our set of children.
1680
- */
1681
- addVariantChild(child: VisualElement): (() => boolean) | undefined;
1682
- /**
1683
- * Add a motion value and bind it to this visual element.
1684
- */
1685
- addValue(key: string, value: MotionValue): void;
1686
- /**
1687
- * Remove a motion value and unbind any active subscriptions.
1688
- */
1689
- removeValue(key: string): void;
1690
- /**
1691
- * Check whether we have a motion value for this key
1692
- */
1693
- hasValue(key: string): boolean;
1694
- /**
1695
- * Get a motion value for this key. If called with a default
1696
- * value, we'll create one if none exists.
1697
- */
1698
- getValue(key: string): MotionValue | undefined;
1699
- getValue(key: string, defaultValue: string | number | null): MotionValue;
1700
- /**
1701
- * If we're trying to animate to a previously unencountered value,
1702
- * we need to check for it in our state and as a last resort read it
1703
- * directly from the instance (which might have performance implications).
1704
- */
1705
- readValue(key: string, target?: string | number | null): any;
1706
- /**
1707
- * Set the base target to later animate back to. This is currently
1708
- * only hydrated on creation and when we first read a value.
1709
- */
1710
- setBaseTarget(key: string, value: string | number): void;
1711
- /**
1712
- * Find the base target for a value thats been removed from all animation
1713
- * props.
1714
- */
1715
- getBaseTarget(key: string): ResolvedValues[string] | undefined | null;
1716
- on<EventName extends keyof VisualElementEventCallbacks>(eventName: EventName, callback: VisualElementEventCallbacks[EventName]): VoidFunction;
1717
- notify<EventName extends keyof VisualElementEventCallbacks>(eventName: EventName, ...args: any): void;
1718
- }
1719
-
1720
- interface DragControlOptions {
1721
- snapToCursor?: boolean;
1722
- cursorProgress?: Point;
1723
- }
1724
-
1725
- /**
1726
- * Can manually trigger a drag gesture on one or more `drag`-enabled `motion` components.
1727
- *
1728
- * ```jsx
1729
- * const dragControls = useDragControls()
1730
- *
1731
- * function startDrag(event) {
1732
- * dragControls.start(event, { snapToCursor: true })
1733
- * }
1734
- *
1735
- * return (
1736
- * <>
1737
- * <div onPointerDown={startDrag} />
1738
- * <motion.div drag="x" dragControls={dragControls} />
1739
- * </>
1740
- * )
1741
- * ```
1742
- *
1743
- * @public
1744
- */
1745
- declare class DragControls {
1746
- private componentControls;
1747
- /**
1748
- * Start a drag gesture on every `motion` component that has this set of drag controls
1749
- * passed into it via the `dragControls` prop.
1750
- *
1751
- * ```jsx
1752
- * dragControls.start(e, {
1753
- * snapToCursor: true
1754
- * })
1755
- * ```
1756
- *
1757
- * @param event - PointerEvent
1758
- * @param options - Options
1759
- *
1760
- * @public
1761
- */
1762
- start(event: React$1.PointerEvent | PointerEvent, options?: DragControlOptions): void;
1763
- }
1764
-
1765
- type DragElastic = boolean | number | Partial<BoundingBox>;
1766
- /**
1767
- * @public
1768
- */
1769
- interface DragHandlers {
1770
- /**
1771
- * Callback function that fires when dragging starts.
1772
- *
1773
- * ```jsx
1774
- * <motion.div
1775
- * drag
1776
- * onDragStart={
1777
- * (event, info) => console.log(info.point.x, info.point.y)
1778
- * }
1779
- * />
1780
- * ```
1781
- *
1782
- * @public
1783
- */
1784
- onDragStart?(event: MouseEvent | TouchEvent | PointerEvent, info: PanInfo): void;
1785
- /**
1786
- * Callback function that fires when dragging ends.
1787
- *
1788
- * ```jsx
1789
- * <motion.div
1790
- * drag
1791
- * onDragEnd={
1792
- * (event, info) => console.log(info.point.x, info.point.y)
1793
- * }
1794
- * />
1795
- * ```
1796
- *
1797
- * @public
1798
- */
1799
- onDragEnd?(event: MouseEvent | TouchEvent | PointerEvent, info: PanInfo): void;
1800
- /**
1801
- * Callback function that fires when the component is dragged.
1802
- *
1803
- * ```jsx
1804
- * <motion.div
1805
- * drag
1806
- * onDrag={
1807
- * (event, info) => console.log(info.point.x, info.point.y)
1808
- * }
1809
- * />
1810
- * ```
1811
- *
1812
- * @public
1813
- */
1814
- onDrag?(event: MouseEvent | TouchEvent | PointerEvent, info: PanInfo): void;
1815
- /**
1816
- * Callback function that fires a drag direction is determined.
1817
- *
1818
- * ```jsx
1819
- * <motion.div
1820
- * drag
1821
- * dragDirectionLock
1822
- * onDirectionLock={axis => console.log(axis)}
1823
- * />
1824
- * ```
1825
- *
1826
- * @public
1827
- */
1828
- onDirectionLock?(axis: "x" | "y"): void;
1829
- /**
1830
- * Callback function that fires when drag momentum/bounce transition finishes.
1831
- *
1832
- * ```jsx
1833
- * <motion.div
1834
- * drag
1835
- * onDragTransitionEnd={() => console.log('Drag transition complete')}
1836
- * />
1837
- * ```
1838
- *
1839
- * @public
1840
- */
1841
- onDragTransitionEnd?(): void;
1842
- }
1843
- /**
1844
- * @public
1845
- */
1846
- type InertiaOptions = Partial<Omit<Inertia, "velocity" | "type">>;
1847
- /**
1848
- * @public
1849
- */
1850
- interface DraggableProps extends DragHandlers {
1851
- /**
1852
- * Enable dragging for this element. Set to `false` by default.
1853
- * Set `true` to drag in both directions.
1854
- * Set `"x"` or `"y"` to only drag in a specific direction.
1855
- *
1856
- * ```jsx
1857
- * <motion.div drag="x" />
1858
- * ```
1859
- */
1860
- drag?: boolean | "x" | "y";
1861
- /**
1862
- * Properties or variant label to animate to while the drag gesture is recognised.
1863
- *
1864
- * ```jsx
1865
- * <motion.div whileDrag={{ scale: 1.2 }} />
1866
- * ```
1867
- */
1868
- whileDrag?: VariantLabels | TargetAndTransition;
1869
- /**
1870
- * If `true`, this will lock dragging to the initially-detected direction. Defaults to `false`.
1871
- *
1872
- * ```jsx
1873
- * <motion.div drag dragDirectionLock />
1874
- * ```
1875
- */
1876
- dragDirectionLock?: boolean;
1877
- /**
1878
- * Allows drag gesture propagation to child components. Set to `false` by
1879
- * default.
1880
- *
1881
- * ```jsx
1882
- * <motion.div drag="x" dragPropagation />
1883
- * ```
1884
- */
1885
- dragPropagation?: boolean;
1886
- /**
1887
- * Applies constraints on the permitted draggable area.
1888
- *
1889
- * It can accept an object of optional `top`, `left`, `right`, and `bottom` values, measured in pixels.
1890
- * This will define a distance the named edge of the draggable component.
1891
- *
1892
- * Alternatively, it can accept a `ref` to another component created with React's `useRef` hook.
1893
- * This `ref` should be passed both to the draggable component's `dragConstraints` prop, and the `ref`
1894
- * of the component you want to use as constraints.
1895
- *
1896
- * ```jsx
1897
- * // In pixels
1898
- * <motion.div
1899
- * drag="x"
1900
- * dragConstraints={{ left: 0, right: 300 }}
1901
- * />
1902
- *
1903
- * // As a ref to another component
1904
- * const MyComponent = () => {
1905
- * const constraintsRef = useRef(null)
1906
- *
1907
- * return (
1908
- * <motion.div ref={constraintsRef}>
1909
- * <motion.div drag dragConstraints={constraintsRef} />
1910
- * </motion.div>
1911
- * )
1912
- * }
1913
- * ```
1914
- */
1915
- dragConstraints?: false | Partial<BoundingBox> | RefObject<Element | null>;
1916
- /**
1917
- * The degree of movement allowed outside constraints. 0 = no movement, 1 =
1918
- * full movement.
1919
- *
1920
- * Set to `0.5` by default. Can also be set as `false` to disable movement.
1921
- *
1922
- * By passing an object of `top`/`right`/`bottom`/`left`, individual values can be set
1923
- * per constraint. Any missing values will be set to `0`.
1924
- *
1925
- * ```jsx
1926
- * <motion.div
1927
- * drag
1928
- * dragConstraints={{ left: 0, right: 300 }}
1929
- * dragElastic={0.2}
1930
- * />
1931
- * ```
1932
- */
1933
- dragElastic?: DragElastic;
1934
- /**
1935
- * Apply momentum from the pan gesture to the component when dragging
1936
- * finishes. Set to `true` by default.
1937
- *
1938
- * ```jsx
1939
- * <motion.div
1940
- * drag
1941
- * dragConstraints={{ left: 0, right: 300 }}
1942
- * dragMomentum={false}
1943
- * />
1944
- * ```
1945
- */
1946
- dragMomentum?: boolean;
1947
- /**
1948
- * Allows you to change dragging inertia parameters.
1949
- * When releasing a draggable Frame, an animation with type `inertia` starts. The animation is based on your dragging velocity. This property allows you to customize it.
1950
- * See {@link https://framer.com/api/animation/#inertia | Inertia} for all properties you can use.
1951
- *
1952
- * ```jsx
1953
- * <motion.div
1954
- * drag
1955
- * dragTransition={{ bounceStiffness: 600, bounceDamping: 10 }}
1956
- * />
1957
- * ```
1958
- */
1959
- dragTransition?: InertiaOptions;
1960
- /**
1961
- * Usually, dragging is initiated by pressing down on a component and moving it. For some
1962
- * use-cases, for instance clicking at an arbitrary point on a video scrubber, we
1963
- * might want to initiate dragging from a different component than the draggable one.
1964
- *
1965
- * By creating a `dragControls` using the `useDragControls` hook, we can pass this into
1966
- * the draggable component's `dragControls` prop. It exposes a `start` method
1967
- * that can start dragging from pointer events on other components.
1968
- *
1969
- * ```jsx
1970
- * const dragControls = useDragControls()
1971
- *
1972
- * function startDrag(event) {
1973
- * dragControls.start(event, { snapToCursor: true })
1974
- * }
1975
- *
1976
- * return (
1977
- * <>
1978
- * <div onPointerDown={startDrag} />
1979
- * <motion.div drag="x" dragControls={dragControls} />
1980
- * </>
1981
- * )
1982
- * ```
1983
- */
1984
- dragControls?: DragControls;
1985
- /**
1986
- * If true, element will snap back to its origin when dragging ends.
1987
- *
1988
- * Enabling this is the equivalent of setting all `dragConstraints` axes to `0`
1989
- * with `dragElastic={1}`, but when used together `dragConstraints` can define
1990
- * a wider draggable area and `dragSnapToOrigin` will ensure the element
1991
- * animates back to its origin on release.
1992
- */
1993
- dragSnapToOrigin?: boolean;
1994
- /**
1995
- * By default, if `drag` is defined on a component then an event listener will be attached
1996
- * to automatically initiate dragging when a user presses down on it.
1997
- *
1998
- * By setting `dragListener` to `false`, this event listener will not be created.
1999
- *
2000
- * ```jsx
2001
- * const dragControls = useDragControls()
2002
- *
2003
- * function startDrag(event) {
2004
- * dragControls.start(event, { snapToCursor: true })
2005
- * }
2006
- *
2007
- * return (
2008
- * <>
2009
- * <div onPointerDown={startDrag} />
2010
- * <motion.div
2011
- * drag="x"
2012
- * dragControls={dragControls}
2013
- * dragListener={false}
2014
- * />
2015
- * </>
2016
- * )
2017
- * ```
2018
- */
2019
- dragListener?: boolean;
2020
- /**
2021
- * If `dragConstraints` is set to a React ref, this callback will call with the measured drag constraints.
2022
- *
2023
- * @public
2024
- */
2025
- onMeasureDragConstraints?: (constraints: BoundingBox) => BoundingBox | void;
2026
- /**
2027
- * Usually, dragging uses the layout project engine, and applies transforms to the underlying VisualElement.
2028
- * Passing MotionValues as _dragX and _dragY instead applies drag updates to these motion values.
2029
- * This allows you to manually control how updates from a drag gesture on an element is applied.
2030
- *
2031
- * @public
2032
- */
2033
- _dragX?: MotionValue<number>;
2034
- /**
2035
- * Usually, dragging uses the layout project engine, and applies transforms to the underlying VisualElement.
2036
- * Passing MotionValues as _dragX and _dragY instead applies drag updates to these motion values.
2037
- * This allows you to manually control how updates from a drag gesture on an element is applied.
2038
- *
2039
- * @public
2040
- */
2041
- _dragY?: MotionValue<number>;
2042
- }
2043
-
2044
- /** @public */
2045
- interface EventInfo {
2046
- point: Point;
2047
- }
2048
-
2049
- /**
2050
- * @public
2051
- */
2052
- interface FocusHandlers {
2053
- /**
2054
- * Properties or variant label to animate to while the focus gesture is recognised.
2055
- *
2056
- * ```jsx
2057
- * <motion.input whileFocus={{ scale: 1.2 }} />
2058
- * ```
2059
- */
2060
- whileFocus?: VariantLabels | TargetAndTransition;
2061
- }
2062
- /**
2063
- * Passed in to tap event handlers like `onTap` the `TapInfo` object contains
2064
- * information about the tap gesture such as it‘s location.
2065
- *
2066
- * ```jsx
2067
- * function onTap(event, info) {
2068
- * console.log(info.point.x, info.point.y)
2069
- * }
2070
- *
2071
- * <motion.div onTap={onTap} />
2072
- * ```
2073
- *
2074
- * @public
2075
- */
2076
- interface TapInfo {
2077
- /**
2078
- * Contains `x` and `y` values for the tap gesture relative to the
2079
- * device or page.
2080
- *
2081
- * ```jsx
2082
- * function onTapStart(event, info) {
2083
- * console.log(info.point.x, info.point.y)
2084
- * }
2085
- *
2086
- * <motion.div onTapStart={onTapStart} />
2087
- * ```
2088
- *
2089
- * @public
2090
- */
2091
- point: Point;
2092
- }
2093
- /**
2094
- * @public
2095
- */
2096
- interface TapHandlers {
2097
- /**
2098
- * Callback when the tap gesture successfully ends on this element.
2099
- *
2100
- * ```jsx
2101
- * function onTap(event, info) {
2102
- * console.log(info.point.x, info.point.y)
2103
- * }
2104
- *
2105
- * <motion.div onTap={onTap} />
2106
- * ```
2107
- *
2108
- * @param event - The originating pointer event.
2109
- * @param info - An {@link TapInfo} object containing `x` and `y` values for the `point` relative to the device or page.
2110
- */
2111
- onTap?(event: MouseEvent | TouchEvent | PointerEvent, info: TapInfo): void;
2112
- /**
2113
- * Callback when the tap gesture starts on this element.
2114
- *
2115
- * ```jsx
2116
- * function onTapStart(event, info) {
2117
- * console.log(info.point.x, info.point.y)
2118
- * }
2119
- *
2120
- * <motion.div onTapStart={onTapStart} />
2121
- * ```
2122
- *
2123
- * @param event - The originating pointer event.
2124
- * @param info - An {@link TapInfo} object containing `x` and `y` values for the `point` relative to the device or page.
2125
- */
2126
- onTapStart?(event: MouseEvent | TouchEvent | PointerEvent, info: TapInfo): void;
2127
- /**
2128
- * Callback when the tap gesture ends outside this element.
2129
- *
2130
- * ```jsx
2131
- * function onTapCancel(event, info) {
2132
- * console.log(info.point.x, info.point.y)
2133
- * }
2134
- *
2135
- * <motion.div onTapCancel={onTapCancel} />
2136
- * ```
2137
- *
2138
- * @param event - The originating pointer event.
2139
- * @param info - An {@link TapInfo} object containing `x` and `y` values for the `point` relative to the device or page.
2140
- */
2141
- onTapCancel?(event: MouseEvent | TouchEvent | PointerEvent, info: TapInfo): void;
2142
- /**
2143
- * Properties or variant label to animate to while the component is pressed.
2144
- *
2145
- * ```jsx
2146
- * <motion.div whileTap={{ scale: 0.8 }} />
2147
- * ```
2148
- */
2149
- whileTap?: VariantLabels | TargetAndTransition;
2150
- /**
2151
- * If `true`, the tap gesture will attach its start listener to window.
2152
- *
2153
- * Note: This is not supported publically.
2154
- */
2155
- globalTapTarget?: boolean;
2156
- }
2157
- /**
2158
- * @public
2159
- */
2160
- interface PanHandlers {
2161
- /**
2162
- * Callback function that fires when the pan gesture is recognised on this element.
2163
- *
2164
- * **Note:** For pan gestures to work correctly with touch input, the element needs
2165
- * touch scrolling to be disabled on either x/y or both axis with the
2166
- * [touch-action](https://developer.mozilla.org/en-US/docs/Web/CSS/touch-action) CSS rule.
2167
- *
2168
- * ```jsx
2169
- * function onPan(event, info) {
2170
- * console.log(info.point.x, info.point.y)
2171
- * }
2172
- *
2173
- * <motion.div onPan={onPan} />
2174
- * ```
2175
- *
2176
- * @param event - The originating pointer event.
2177
- * @param info - A {@link PanInfo} object containing `x` and `y` values for:
2178
- *
2179
- * - `point`: Relative to the device or page.
2180
- * - `delta`: Distance moved since the last event.
2181
- * - `offset`: Offset from the original pan event.
2182
- * - `velocity`: Current velocity of the pointer.
2183
- */
2184
- onPan?(event: PointerEvent, info: PanInfo): void;
2185
- /**
2186
- * Callback function that fires when the pan gesture begins on this element.
2187
- *
2188
- * ```jsx
2189
- * function onPanStart(event, info) {
2190
- * console.log(info.point.x, info.point.y)
2191
- * }
2192
- *
2193
- * <motion.div onPanStart={onPanStart} />
2194
- * ```
2195
- *
2196
- * @param event - The originating pointer event.
2197
- * @param info - A {@link PanInfo} object containing `x`/`y` values for:
2198
- *
2199
- * - `point`: Relative to the device or page.
2200
- * - `delta`: Distance moved since the last event.
2201
- * - `offset`: Offset from the original pan event.
2202
- * - `velocity`: Current velocity of the pointer.
2203
- */
2204
- onPanStart?(event: PointerEvent, info: PanInfo): void;
2205
- /**
2206
- * Callback function that fires when we begin detecting a pan gesture. This
2207
- * is analogous to `onMouseStart` or `onTouchStart`.
2208
- *
2209
- * ```jsx
2210
- * function onPanSessionStart(event, info) {
2211
- * console.log(info.point.x, info.point.y)
2212
- * }
2213
- *
2214
- * <motion.div onPanSessionStart={onPanSessionStart} />
2215
- * ```
2216
- *
2217
- * @param event - The originating pointer event.
2218
- * @param info - An {@link EventInfo} object containing `x`/`y` values for:
2219
- *
2220
- * - `point`: Relative to the device or page.
2221
- */
2222
- onPanSessionStart?(event: PointerEvent, info: EventInfo): void;
2223
- /**
2224
- * Callback function that fires when the pan gesture ends on this element.
2225
- *
2226
- * ```jsx
2227
- * function onPanEnd(event, info) {
2228
- * console.log(info.point.x, info.point.y)
2229
- * }
2230
- *
2231
- * <motion.div onPanEnd={onPanEnd} />
2232
- * ```
2233
- *
2234
- * @param event - The originating pointer event.
2235
- * @param info - A {@link PanInfo} object containing `x`/`y` values for:
2236
- *
2237
- * - `point`: Relative to the device or page.
2238
- * - `delta`: Distance moved since the last event.
2239
- * - `offset`: Offset from the original pan event.
2240
- * - `velocity`: Current velocity of the pointer.
2241
- */
2242
- onPanEnd?(event: PointerEvent, info: PanInfo): void;
2243
- }
2244
- /**
2245
- * @public
2246
- */
2247
- interface HoverHandlers {
2248
- /**
2249
- * Properties or variant label to animate to while the hover gesture is recognised.
2250
- *
2251
- * ```jsx
2252
- * <motion.div whileHover={{ scale: 1.2 }} />
2253
- * ```
2254
- */
2255
- whileHover?: VariantLabels | TargetAndTransition;
2256
- /**
2257
- * Callback function that fires when pointer starts hovering over the component.
2258
- *
2259
- * ```jsx
2260
- * <motion.div onHoverStart={() => console.log('Hover starts')} />
2261
- * ```
2262
- */
2263
- onHoverStart?(event: MouseEvent, info: EventInfo): void;
2264
- /**
2265
- * Callback function that fires when pointer stops hovering over the component.
2266
- *
2267
- * ```jsx
2268
- * <motion.div onHoverEnd={() => console.log("Hover ends")} />
2269
- * ```
2270
- */
2271
- onHoverEnd?(event: MouseEvent, info: EventInfo): void;
2272
- }
2273
-
2274
- /**
2275
- * @public
2276
- */
2277
- interface LayoutProps {
2278
- /**
2279
- * If `true`, this component will automatically animate to its new position when
2280
- * its layout changes.
2281
- *
2282
- * ```jsx
2283
- * <motion.div layout />
2284
- * ```
2285
- *
2286
- * This will perform a layout animation using performant transforms. Part of this technique
2287
- * involved animating an element's scale. This can introduce visual distortions on children,
2288
- * `boxShadow` and `borderRadius`.
2289
- *
2290
- * To correct distortion on immediate children, add `layout` to those too.
2291
- *
2292
- * `boxShadow` and `borderRadius` will automatically be corrected if they are already being
2293
- * animated on this component. Otherwise, set them directly via the `initial` prop.
2294
- *
2295
- * If `layout` is set to `"position"`, the size of the component will change instantly and
2296
- * only its position will animate.
2297
- *
2298
- * If `layout` is set to `"size"`, the position of the component will change instantly and
2299
- * only its size will animate.
2300
- *
2301
- * If `layout` is set to `"preserve-aspect"`, the component will animate size & position if
2302
- * the aspect ratio remains the same between renders, and just position if the ratio changes.
2303
- *
2304
- * @public
2305
- */
2306
- layout?: boolean | "position" | "size" | "preserve-aspect";
2307
- /**
2308
- * Enable shared layout transitions between different components with the same `layoutId`.
2309
- *
2310
- * When a component with a layoutId is removed from the React tree, and then
2311
- * added elsewhere, it will visually animate from the previous component's bounding box
2312
- * and its latest animated values.
2313
- *
2314
- * ```jsx
2315
- * {items.map(item => (
2316
- * <motion.li layout>
2317
- * {item.name}
2318
- * {item.isSelected && <motion.div layoutId="underline" />}
2319
- * </motion.li>
2320
- * ))}
2321
- * ```
2322
- *
2323
- * If the previous component remains in the tree it will crossfade with the new component.
2324
- *
2325
- * @public
2326
- */
2327
- layoutId?: string;
2328
- /**
2329
- * A callback that will fire when a layout animation on this component starts.
2330
- *
2331
- * @public
2332
- */
2333
- onLayoutAnimationStart?(): void;
2334
- /**
2335
- * A callback that will fire when a layout animation on this component completes.
2336
- *
2337
- * @public
2338
- */
2339
- onLayoutAnimationComplete?(): void;
2340
- /**
2341
- * @public
2342
- */
2343
- layoutDependency?: any;
2344
- /**
2345
- * Whether a projection node should measure its scroll when it or its descendants update their layout.
2346
- *
2347
- * @public
2348
- */
2349
- layoutScroll?: boolean;
2350
- /**
2351
- * Whether an element should be considered a "layout root", where
2352
- * all children will be forced to resolve relatively to it.
2353
- * Currently used for `position: sticky` elements in Framer.
2354
- */
2355
- layoutRoot?: boolean;
2356
- /**
2357
- * Attached to a portal root to ensure we attach the child to the document root and don't
2358
- * perform scale correction on it.
2359
- */
2360
- "data-framer-portal-id"?: string;
2361
- }
2362
-
2363
- type ViewportEventHandler = (entry: IntersectionObserverEntry | null) => void;
2364
- interface ViewportOptions {
2365
- root?: RefObject<Element | null>;
2366
- once?: boolean;
2367
- margin?: string;
2368
- amount?: "some" | "all" | number;
2369
- }
2370
- interface ViewportProps {
2371
- whileInView?: VariantLabels | TargetAndTransition;
2372
- onViewportEnter?: ViewportEventHandler;
2373
- onViewportLeave?: ViewportEventHandler;
2374
- viewport?: ViewportOptions;
2375
- }
2376
-
2377
- /**
2378
- * Either a string, or array of strings, that reference variants defined via the `variants` prop.
2379
- * @public
2380
- */
2381
- type VariantLabels = string | string[];
2382
-
2383
- interface CustomStyles {
2384
- /**
2385
- * Framer Library custom prop types. These are not actually supported in Motion - preferably
2386
- * we'd have a way of external consumers injecting supported styles into this library.
2387
- */
2388
- size?: string | number;
2389
- radius?: string | number;
2390
- shadow?: string;
2391
- image?: string;
2392
- }
2393
- type MakeMotion<T> = MakeCustomValueType<{
2394
- [K in keyof T]: T[K] | MotionValue<number> | MotionValue<string> | MotionValue<any>;
2395
- }>;
2396
- type MotionCSS = MakeMotion<Omit$1<CSSProperties, "rotate" | "scale" | "perspective">>;
2397
- /**
2398
- * @public
2399
- */
2400
- type MotionTransform = MakeMotion<TransformProperties>;
2401
- /**
2402
- * @public
2403
- */
2404
- type MotionStyle = MotionCSS & MotionTransform & MakeMotion<SVGPathProperties> & MakeCustomValueType<CustomStyles>;
2405
- /**
2406
- * @public
2407
- */
2408
- interface AnimationProps {
2409
- /**
2410
- * Properties, variant label or array of variant labels to start in.
2411
- *
2412
- * Set to `false` to initialise with the values in `animate` (disabling the mount animation)
2413
- *
2414
- * ```jsx
2415
- * // As values
2416
- * <motion.div initial={{ opacity: 1 }} />
2417
- *
2418
- * // As variant
2419
- * <motion.div initial="visible" variants={variants} />
2420
- *
2421
- * // Multiple variants
2422
- * <motion.div initial={["visible", "active"]} variants={variants} />
2423
- *
2424
- * // As false (disable mount animation)
2425
- * <motion.div initial={false} animate={{ opacity: 0 }} />
2426
- * ```
2427
- */
2428
- initial?: TargetAndTransition | VariantLabels | boolean;
2429
- /**
2430
- * Values to animate to, variant label(s), or `AnimationControls`.
2431
- *
2432
- * ```jsx
2433
- * // As values
2434
- * <motion.div animate={{ opacity: 1 }} />
2435
- *
2436
- * // As variant
2437
- * <motion.div animate="visible" variants={variants} />
2438
- *
2439
- * // Multiple variants
2440
- * <motion.div animate={["visible", "active"]} variants={variants} />
2441
- *
2442
- * // AnimationControls
2443
- * <motion.div animate={animation} />
2444
- * ```
2445
- */
2446
- animate?: AnimationControls | TargetAndTransition | VariantLabels | boolean;
2447
- /**
2448
- * A target to animate to when this component is removed from the tree.
2449
- *
2450
- * This component **must** be the first animatable child of an `AnimatePresence` to enable this exit animation.
2451
- *
2452
- * This limitation exists because React doesn't allow components to defer unmounting until after
2453
- * an animation is complete. Once this limitation is fixed, the `AnimatePresence` component will be unnecessary.
2454
- *
2455
- * ```jsx
2456
- * import { AnimatePresence, motion } from 'framer-motion'
2457
- *
2458
- * export const MyComponent = ({ isVisible }) => {
2459
- * return (
2460
- * <AnimatePresence>
2461
- * {isVisible && (
2462
- * <motion.div
2463
- * initial={{ opacity: 0 }}
2464
- * animate={{ opacity: 1 }}
2465
- * exit={{ opacity: 0 }}
2466
- * />
2467
- * )}
2468
- * </AnimatePresence>
2469
- * )
2470
- * }
2471
- * ```
2472
- */
2473
- exit?: TargetAndTransition | VariantLabels;
2474
- /**
2475
- * Variants allow you to define animation states and organise them by name. They allow
2476
- * you to control animations throughout a component tree by switching a single `animate` prop.
2477
- *
2478
- * Using `transition` options like `delayChildren` and `staggerChildren`, you can orchestrate
2479
- * when children animations play relative to their parent.
2480
-
2481
- *
2482
- * After passing variants to one or more `motion` component's `variants` prop, these variants
2483
- * can be used in place of values on the `animate`, `initial`, `whileFocus`, `whileTap` and `whileHover` props.
2484
- *
2485
- * ```jsx
2486
- * const variants = {
2487
- * active: {
2488
- * backgroundColor: "#f00"
2489
- * },
2490
- * inactive: {
2491
- * backgroundColor: "#fff",
2492
- * transition: { duration: 2 }
2493
- * }
2494
- * }
2495
- *
2496
- * <motion.div variants={variants} animate="active" />
2497
- * ```
2498
- */
2499
- variants?: Variants;
2500
- /**
2501
- * Default transition. If no `transition` is defined in `animate`, it will use the transition defined here.
2502
- * ```jsx
2503
- * const spring = {
2504
- * type: "spring",
2505
- * damping: 10,
2506
- * stiffness: 100
2507
- * }
2508
- *
2509
- * <motion.div transition={spring} animate={{ scale: 1.2 }} />
2510
- * ```
2511
- */
2512
- transition?: Transition;
2513
- }
2514
- /**
2515
- * @public
2516
- */
2517
- interface MotionAdvancedProps {
2518
- /**
2519
- * Custom data to use to resolve dynamic variants differently for each animating component.
2520
- *
2521
- * ```jsx
2522
- * const variants = {
2523
- * visible: (custom) => ({
2524
- * opacity: 1,
2525
- * transition: { delay: custom * 0.2 }
2526
- * })
2527
- * }
2528
- *
2529
- * <motion.div custom={0} animate="visible" variants={variants} />
2530
- * <motion.div custom={1} animate="visible" variants={variants} />
2531
- * <motion.div custom={2} animate="visible" variants={variants} />
2532
- * ```
2533
- *
2534
- * @public
2535
- */
2536
- custom?: any;
2537
- /**
2538
- * @public
2539
- * Set to `false` to prevent inheriting variant changes from its parent.
2540
- */
2541
- inherit?: boolean;
2542
- /**
2543
- * @public
2544
- * Set to `false` to prevent throwing an error when a `motion` component is used within a `LazyMotion` set to strict.
2545
- */
2546
- ignoreStrict?: boolean;
2547
- }
2548
- /**
2549
- * Props for `motion` components.
2550
- *
2551
- * @public
2552
- */
2553
- interface MotionProps extends AnimationProps, EventProps, PanHandlers, TapHandlers, HoverHandlers, FocusHandlers, ViewportProps, DraggableProps, LayoutProps, MotionAdvancedProps {
2554
- /**
2555
- *
2556
- * The React DOM `style` prop, enhanced with support for `MotionValue`s and separate `transform` values.
2557
- *
2558
- * ```jsx
2559
- * export const MyComponent = () => {
2560
- * const x = useMotionValue(0)
2561
- *
2562
- * return <motion.div style={{ x, opacity: 1, scale: 0.5 }} />
2563
- * }
2564
- * ```
2565
- */
2566
- style?: MotionStyle;
2567
- /**
2568
- * By default, Motion generates a `transform` property with a sensible transform order. `transformTemplate`
2569
- * can be used to create a different order, or to append/preprend the automatically generated `transform` property.
2570
- *
2571
- * ```jsx
2572
- * <motion.div
2573
- * style={{ x: 0, rotate: 180 }}
2574
- * transformTemplate={
2575
- * ({ x, rotate }) => `rotate(${rotate}deg) translateX(${x}px)`
2576
- * }
2577
- * />
2578
- * ```
2579
- *
2580
- * @param transform - The latest animated transform props.
2581
- * @param generatedTransform - The transform string as automatically generated by Motion
2582
- *
2583
- * @public
2584
- */
2585
- transformTemplate?(transform: TransformProperties, generatedTransform: string): string;
2586
- children?: React.ReactNode | MotionValue<number> | MotionValue<string>;
2587
- "data-framer-appear-id"?: string;
2588
- }
2589
-
2590
- type AnimationDefinition = VariantLabels | TargetAndTransition | TargetResolver;
2591
- /**
2592
- * @public
2593
- */
2594
- interface AnimationControls {
2595
- /**
2596
- * Starts an animation on all linked components.
2597
- *
2598
- * @remarks
2599
- *
2600
- * ```jsx
2601
- * controls.start("variantLabel")
2602
- * controls.start({
2603
- * x: 0,
2604
- * transition: { duration: 1 }
2605
- * })
2606
- * ```
2607
- *
2608
- * @param definition - Properties or variant label to animate to
2609
- * @param transition - Optional `transtion` to apply to a variant
2610
- * @returns - A `Promise` that resolves when all animations have completed.
2611
- *
2612
- * @public
2613
- */
2614
- start(definition: AnimationDefinition, transitionOverride?: Transition$1): Promise<any>;
2615
- /**
2616
- * Instantly set to a set of properties or a variant.
2617
- *
2618
- * ```jsx
2619
- * // With properties
2620
- * controls.set({ opacity: 0 })
2621
- *
2622
- * // With variants
2623
- * controls.set("hidden")
2624
- * ```
2625
- *
2626
- * @privateRemarks
2627
- * We could perform a similar trick to `.start` where this can be called before mount
2628
- * and we maintain a list of of pending actions that get applied on mount. But the
2629
- * expectation of `set` is that it happens synchronously and this would be difficult
2630
- * to do before any children have even attached themselves. It's also poor practise
2631
- * and we should discourage render-synchronous `.start` calls rather than lean into this.
2632
- *
2633
- * @public
2634
- */
2635
- set(definition: AnimationDefinition): void;
2636
- /**
2637
- * Stops animations on all linked components.
2638
- *
2639
- * ```jsx
2640
- * controls.stop()
2641
- * ```
2642
- *
2643
- * @public
2644
- */
2645
- stop(): void;
2646
- mount(): () => void;
2647
- }
2648
-
2649
- interface OnUpdateSettings<Instance, RenderState> {
2650
- props: MotionProps;
2651
- prevProps?: MotionProps;
2652
- current: Instance | null;
2653
- renderState: RenderState;
2654
- latestValues: ResolvedValues;
2655
- }
2656
- interface VisualState<Instance, RenderState> {
2657
- renderState: RenderState;
2658
- latestValues: ResolvedValues;
2659
- onUpdate?: (settings: OnUpdateSettings<Instance, RenderState>) => void;
2660
- onMount?: (instance: Instance) => void;
2661
- }
2662
- type UseVisualState<Instance, RenderState> = (props: MotionProps, isStatic: boolean) => VisualState<Instance, RenderState>;
2663
- interface UseVisualStateConfig<Instance, RenderState> {
2664
- scrapeMotionValuesFromProps: ScrapeMotionValuesFromProps;
2665
- createRenderState: () => RenderState;
2666
- onUpdate?: (settings: OnUpdateSettings<Instance, RenderState>) => void;
2667
- }
2668
- declare const makeUseVisualState: <I, RS>(config: UseVisualStateConfig<I, RS>) => UseVisualState<I, RS>;
2669
-
2670
- type ScrapeMotionValuesFromProps = (props: MotionProps, prevProps: MotionProps, visualElement?: VisualElement) => {
2671
- [key: string]: MotionValue | string | number;
2672
- };
2673
- type VisualElementOptions<Instance, RenderState = any> = {
2674
- visualState: VisualState<Instance, RenderState>;
2675
- parent?: VisualElement<unknown>;
2676
- variantParent?: VisualElement<unknown>;
2677
- presenceContext: PresenceContextProps | null;
2678
- props: MotionProps;
2679
- blockInitialAnimation?: boolean;
2680
- reducedMotionConfig?: ReducedMotionConfig;
2681
- };
2682
- /**
2683
- * A generic set of string/number values
2684
- */
2685
- interface ResolvedValues {
2686
- [key: string]: string | number;
2687
- }
2688
- interface VisualElementEventCallbacks {
2689
- BeforeLayoutMeasure: () => void;
2690
- LayoutMeasure: (layout: Box, prevLayout?: Box) => void;
2691
- LayoutUpdate: (layout: Axis, prevLayout: Axis) => void;
2692
- Update: (latest: ResolvedValues) => void;
2693
- AnimationStart: (definition: AnimationDefinition) => void;
2694
- AnimationComplete: (definition: AnimationDefinition) => void;
2695
- LayoutAnimationStart: () => void;
2696
- LayoutAnimationComplete: () => void;
2697
- SetAxisTarget: () => void;
2698
- Unmount: () => void;
2699
- }
2700
- interface LayoutLifecycles {
2701
- onBeforeLayoutMeasure?(box: Box): void;
2702
- onLayoutMeasure?(box: Box, prevBox: Box): void;
2703
- }
2704
- interface AnimationLifecycles {
2705
- /**
2706
- * Callback with latest motion values, fired max once per frame.
2707
- *
2708
- * ```jsx
2709
- * function onUpdate(latest) {
2710
- * console.log(latest.x, latest.opacity)
2711
- * }
2712
- *
2713
- * <motion.div animate={{ x: 100, opacity: 0 }} onUpdate={onUpdate} />
2714
- * ```
2715
- */
2716
- onUpdate?(latest: ResolvedValues): void;
2717
- /**
2718
- * Callback when animation defined in `animate` begins.
2719
- *
2720
- * The provided callback will be called with the triggering animation definition.
2721
- * If this is a variant, it'll be the variant name, and if a target object
2722
- * then it'll be the target object.
2723
- *
2724
- * This way, it's possible to figure out which animation has started.
2725
- *
2726
- * ```jsx
2727
- * function onStart() {
2728
- * console.log("Animation started")
2729
- * }
2730
- *
2731
- * <motion.div animate={{ x: 100 }} onAnimationStart={onStart} />
2732
- * ```
2733
- */
2734
- onAnimationStart?(definition: AnimationDefinition): void;
2735
- /**
2736
- * Callback when animation defined in `animate` is complete.
2737
- *
2738
- * The provided callback will be called with the triggering animation definition.
2739
- * If this is a variant, it'll be the variant name, and if a target object
2740
- * then it'll be the target object.
2741
- *
2742
- * This way, it's possible to figure out which animation has completed.
2743
- *
2744
- * ```jsx
2745
- * function onComplete() {
2746
- * console.log("Animation completed")
2747
- * }
2748
- *
2749
- * <motion.div
2750
- * animate={{ x: 100 }}
2751
- * onAnimationComplete={definition => {
2752
- * console.log('Completed animating', definition)
2753
- * }}
2754
- * />
2755
- * ```
2756
- */
2757
- onAnimationComplete?(definition: AnimationDefinition): void;
2758
- }
2759
- type EventProps = LayoutLifecycles & AnimationLifecycles;
2760
-
2761
- declare abstract class Feature<T extends any = any> {
2762
- isMounted: boolean;
2763
- node: VisualElement<T>;
2764
- constructor(node: VisualElement<T>);
2765
- abstract mount(): void;
2766
- abstract unmount(): void;
2767
- update(): void;
2768
- }
2769
-
2770
- declare function MeasureLayout(props: MotionProps & {
2771
- visualElement: VisualElement;
2772
- }): react_jsx_runtime.JSX.Element;
2773
-
2774
- interface FeatureClass<Props = unknown> {
2775
- new (props: Props): Feature<Props>;
2776
- }
2777
- type HydratedFeatureDefinition = {
2778
- isEnabled: (props: MotionProps) => boolean;
2779
- Feature: FeatureClass<unknown>;
2780
- ProjectionNode?: any;
2781
- MeasureLayout?: typeof MeasureLayout;
2782
- };
2783
- interface HydratedFeatureDefinitions {
2784
- animation?: HydratedFeatureDefinition;
2785
- exit?: HydratedFeatureDefinition;
2786
- drag?: HydratedFeatureDefinition;
2787
- tap?: HydratedFeatureDefinition;
2788
- focus?: HydratedFeatureDefinition;
2789
- hover?: HydratedFeatureDefinition;
2790
- pan?: HydratedFeatureDefinition;
2791
- inView?: HydratedFeatureDefinition;
2792
- layout?: HydratedFeatureDefinition;
2793
- }
2794
- type FeaturePackage = {
2795
- Feature?: HydratedFeatureDefinition["Feature"];
2796
- ProjectionNode?: HydratedFeatureDefinition["ProjectionNode"];
2797
- MeasureLayout?: HydratedFeatureDefinition["MeasureLayout"];
2798
- };
2799
- type FeaturePackages = {
2800
- [K in keyof HydratedFeatureDefinitions]: FeaturePackage;
2801
- };
2802
-
2803
- declare const animations: FeaturePackages;
2804
-
2805
- interface MotionContextProps<Instance = unknown> {
2806
- visualElement?: VisualElement<Instance>;
2807
- initial?: false | string | string[];
2808
- animate?: string | string[];
2809
- }
2810
- declare const MotionContext: React$1.Context<MotionContextProps<unknown>>;
2811
-
2812
- declare const createBox: () => Box;
2813
-
2814
- declare function calcLength(axis: Axis): number;
2815
-
2816
- declare function filterProps(props: MotionProps, isDom: boolean, forwardMotionProps: boolean): MotionProps;
2817
-
2818
- type EventListenerWithPointInfo = (e: PointerEvent, info: EventInfo) => void;
2819
- declare const addPointerInfo: (handler: EventListenerWithPointInfo) => EventListener;
2820
-
2821
- declare function addPointerEvent(target: EventTarget, eventName: string, handler: EventListenerWithPointInfo, options?: AddEventListenerOptions): () => void;
2822
-
2823
- declare const isMotionValue: (value: any) => value is MotionValue<any>;
2824
-
2825
- declare const isBrowser: boolean;
2826
-
2827
- declare function useUnmountEffect(callback: () => void): void;
2828
-
2829
- declare const useIsomorphicLayoutEffect: typeof useEffect;
2830
-
2831
- declare function useForceUpdate(): [VoidFunction, number];
2832
-
2833
- export { type AnimationType, MotionContext, type ResolvedValues, type ScrapeMotionValuesFromProps, type VisualState, addPointerEvent, addPointerInfo, animations, calcLength, createBox, filterProps, isBrowser, isMotionValue, makeUseVisualState, useForceUpdate, useIsomorphicLayoutEffect, useUnmountEffect };