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