framer-motion 7.6.4 → 7.6.6

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