UNPKG

153 kBTypeScriptView Raw
1/// <reference types="react" />
2import { CSSProperties } from 'react';
3import { DetailedHTMLFactory } from 'react';
4import { Easing as Easing_2 } from '@popmotion/easing';
5import { ForwardRefExoticComponent } from 'react';
6import { FunctionComponent } from 'react';
7import { HTMLAttributes } from 'react';
8import { PropsWithoutRef } from 'react';
9import * as React from 'react';
10import { ReactElement } from 'react';
11import { ReactHTML } from 'react';
12import { ReactNode } from 'react';
13import { Ref } from 'react';
14import { RefAttributes } from 'react';
15import { RefObject } from 'react';
16import { SpringProps } from 'popmotion';
17import { SVGAttributes } from 'react';
18
19/**
20 * The `AnimatePresence` component enables the use of the `exit` prop to animate components
21 * when they're removed from the component tree.
22 *
23 * When adding/removing more than a single child component, every component
24 * **must** be given a unique `key` prop.
25 *
26 * You can propagate exit animations throughout a tree by using variants.
27 *
28 * @library
29 *
30 * You can use any component(s) within `AnimatePresence`, but the first `Frame` in each should
31 * have an `exit` property defined.
32 *
33 * ```jsx
34 * import { Frame, AnimatePresence } from 'framer'
35 *
36 * // As items are added and removed from `items`
37 * export function Items({ items }) {
38 * return (
39 * <AnimatePresence>
40 * {items.map(item => (
41 * <Frame
42 * key={item.id}
43 * initial={{ opacity: 0 }}
44 * animate={{ opacity: 1 }}
45 * exit={{ opacity: 0 }}
46 * />
47 * ))}
48 * </AnimatePresence>
49 * )
50 * }
51 * ```
52 *
53 * @motion
54 *
55 * You can use any component(s) within `AnimatePresence`, but the first `motion` component in each should
56 * have an `exit` property defined.
57 *
58 * ```jsx
59 * import { motion, AnimatePresence } from 'framer-motion'
60 *
61 * export const Items = ({ items }) => (
62 * <AnimatePresence>
63 * {items.map(item => (
64 * <motion.div
65 * key={item.id}
66 * initial={{ opacity: 0 }}
67 * animate={{ opacity: 1 }}
68 * exit={{ opacity: 0 }}
69 * />
70 * ))}
71 * </AnimatePresence>
72 * )
73 * ```
74 *
75 * @public
76 */
77export declare const AnimatePresence: FunctionComponent<AnimatePresenceProps>;
78
79/**
80 * @public
81 */
82export declare interface AnimatePresenceProps {
83 /**
84 * By passing `initial={false}`, `AnimatePresence` will disable any initial animations on children
85 * that are present when the component is first rendered.
86 *
87 * @library
88 *
89 * ```jsx
90 * <AnimatePresence initial={false}>
91 * {isVisible && (
92 * <Frame
93 * key="modal"
94 * initial={{ opacity: 0 }}
95 * animate={{ opacity: 1 }}
96 * exit={{ opacity: 0 }}
97 * />
98 * )}
99 * </AnimatePresence>
100 * ```
101 *
102 * @motion
103 *
104 * ```jsx
105 * <AnimatePresence initial={false}>
106 * {isVisible && (
107 * <motion.div
108 * key="modal"
109 * initial={{ opacity: 0 }}
110 * animate={{ opacity: 1 }}
111 * exit={{ opacity: 0 }}
112 * />
113 * )}
114 * </AnimatePresence>
115 * ```
116 *
117 * @public
118 */
119 initial?: boolean;
120 /**
121 * When a component is removed, there's no longer a chance to update its props. So if a component's `exit`
122 * prop is defined as a dynamic variant and you want to pass a new `custom` prop, you can do so via `AnimatePresence`.
123 * This will ensure all leaving components animate using the latest data.
124 *
125 * @public
126 */
127 custom?: any;
128 /**
129 * Fires when all exiting nodes have completed animating out.
130 *
131 * @public
132 */
133 onExitComplete?: () => void;
134 /**
135 * `AnimatePresence` locally re-renders its children once exit animations are
136 * complete. This means that if surrounding or parent components are also set to `positionTransition`,
137 * they aren't informed of updates to the layout when they happen asynchronous to a render.
138 *
139 * This prop allows `AnimatePresence` to trigger re-renders at a higher level, so more
140 * components can be made aware of the layout change and animate accordingly.
141 *
142 * In this example, the both the parent and sibling will animate to their new layout
143 * once the div within `AnimatePresence` has finished animating:
144 *
145 * ```jsx
146 * const MyComponent = ({ isVisible }) => {
147 * const forceUpdate = useForceUpdate() // Forces a set state or something
148 *
149 * return (
150 * <motion.div positionTransition>
151 * <AnimatePresence _syncLayout={forceUpdate}>
152 * <motion.div positionTransition exit={{ opacity: 0 }} />
153 * </AnimatePresence>
154 * <motion.div positionTransition />
155 * </motion.div>
156 * )
157 * }
158 * ```
159 *
160 * In the final implementation `syncLayout` might be better as a component
161 * that provides this function to children via context, or some other method
162 * that obfuscates
163 *
164 * This isn't generally a problem for most use-cases but this capability will be useful
165 * for advanced uses but also more so for phase 2 of `sizeTransition`, as we'd gain the power
166 * to declaratively relayout entire parts of the page using only performant transforms.
167 *
168 * @internal
169 */
170 _syncLayout?: () => void;
171 /**
172 * If set to `true`, `AnimatePresence` will only render one component at a time. The exiting component
173 * will finished its exit animation before the entering component is rendered.
174 *
175 * @library
176 *
177 * ```jsx
178 * function MyComponent({ currentItem }) {
179 * return (
180 * <AnimatePresence exitBeforeEnter>
181 * <Frame key={currentItem} exit={{ opacity: 0 }} />
182 * </AnimatePresence>
183 * )
184 * }
185 * ```
186 *
187 * @motion
188 *
189 * ```jsx
190 * const MyComponent = ({ currentItem }) => (
191 * <AnimatePresence exitBeforeEnter>
192 * <motion.div key={currentItem} exit={{ opacity: 0 }} />
193 * </AnimatePresence>
194 * )
195 * ```
196 *
197 * @beta
198 */
199 exitBeforeEnter?: boolean;
200}
201
202/**
203 * Control animations on one or more components.
204 *
205 * @public
206 */
207export declare class AnimationControls {
208 /**
209 * Track whether the host component has mounted.
210 *
211 * @internal
212 */
213 private hasMounted;
214 /**
215 * A default `Transition` to set on linked components.
216 *
217 * @internal
218 */
219 private defaultTransition;
220 /**
221 * Pending animations that are started before a component is mounted.
222 *
223 * @internal
224 */
225 private pendingAnimations;
226 /**
227 * A collection of linked component animation controls.
228 *
229 * @internal
230 */
231 private componentControls;
232 /**
233 * A map of variants that can be later referenced via `start(variantLabel)`
234 *
235 * @internal
236 */
237 private variants;
238 /**
239 * Set variants on this and all child components.
240 *
241 * @param variants - The variants to set
242 *
243 * @internal
244 */
245 setVariants(variants: Variants): void;
246 /**
247 * Set a default transition on this and all child components
248 *
249 * @param transition - The default transition to set
250 *
251 * @internal
252 */
253 setDefaultTransition(transition: Transition): void;
254 /**
255 * Subscribes a component's animation controls to this.
256 *
257 * @param controls - The controls to subscribe
258 * @returns An unsubscribe function.
259 *
260 * @internal
261 */
262 subscribe(controls: ValueAnimationControls): () => boolean;
263 /**
264 * Starts an animation on all linked components.
265 *
266 * @remarks
267 *
268 * ```jsx
269 * controls.start("variantLabel")
270 * controls.start({
271 * x: 0,
272 * transition: { duration: 1 }
273 * })
274 * ```
275 *
276 * @param definition - Properties or variant label to animate to
277 * @param transition - Optional `transtion` to apply to a variant
278 * @returns - A `Promise` that resolves when all animations have completed.
279 *
280 * @public
281 */
282 start(definition: AnimationDefinition, transitionOverride?: Transition): Promise<any>;
283 /**
284 * Instantly set to a set of properties or a variant.
285 *
286 * ```jsx
287 * // With properties
288 * controls.set({ opacity: 0 })
289 *
290 * // With variants
291 * controls.set("hidden")
292 * ```
293 *
294 * @internalremarks
295 * We could perform a similar trick to `.start` where this can be called before mount
296 * and we maintain a list of of pending actions that get applied on mount. But the
297 * expectation of `set` is that it happens synchronously and this would be difficult
298 * to do before any children have even attached themselves. It's also poor practise
299 * and we should discourage render-synchronous `.start` calls rather than lean into this.
300 *
301 * @public
302 */
303 set(definition: AnimationDefinition): void;
304 /**
305 * Stops animations on all linked components.
306 *
307 * ```jsx
308 * controls.stop()
309 * ```
310 *
311 * @public
312 */
313 stop(): void;
314 /**
315 * Initialises the animation controls.
316 *
317 * @internal
318 */
319 mount(): void;
320 /**
321 * Stops all child animations when the host component unmounts.
322 *
323 * @internal
324 */
325 unmount(): void;
326}
327
328/**
329 * @internal
330 */
331export declare const animationControls: () => AnimationControls;
332
333declare type AnimationDefinition = VariantLabels | TargetAndTransition | TargetResolver;
334
335declare type AnimationOptions = {
336 delay?: number;
337 priority?: number;
338 transitionOverride?: Transition;
339};
340
341/**
342 * @public
343 */
344export declare interface AnimationProps {
345 /**
346 * Values to animate to, variant label(s), or `AnimationControls`.
347 *
348 * @library
349 *
350 * ```jsx
351 * // As values
352 * <Frame animate={{ opacity: 1 }} />
353 *
354 * // As variant
355 * <Frame animate="visible" variants={variants} />
356 *
357 * // Multiple variants
358 * <Frame animate={["visible", "active"]} variants={variants} />
359 *
360 * // AnimationControls
361 * <Frame animate={animation} />
362 * ```
363 *
364 * @motion
365 *
366 * ```jsx
367 * // As values
368 * <motion.div animate={{ opacity: 1 }} />
369 *
370 * // As variant
371 * <motion.div animate="visible" variants={variants} />
372 *
373 * // Multiple variants
374 * <motion.div animate={["visible", "active"]} variants={variants} />
375 *
376 * // AnimationControls
377 * <motion.div animate={animation} />
378 * ```
379 */
380 animate?: AnimationControls | TargetAndTransition | VariantLabels;
381 /**
382 * A target to animate to when this component is removed from the tree.
383 *
384 * This component **must** be the first animatable child of an `AnimatePresence` to enable this exit animation.
385 *
386 * This limitation exists because React doesn't allow components to defer unmounting until after
387 * an animation is complete. Once this limitation is fixed, the `AnimatePresence` component will be unnecessary.
388 *
389 * @library
390 *
391 * ```jsx
392 * import { Frame, AnimatePresence } from 'framer'
393 *
394 * export function MyComponent(props) {
395 * return (
396 * <AnimatePresence>
397 * {props.isVisible && (
398 * <Frame
399 * initial={{ opacity: 0 }}
400 * animate={{ opacity: 1 }}
401 * exit={{ opacity: 0 }}
402 * />
403 * )}
404 * </AnimatePresence>
405 * )
406 * }
407 * ```
408 *
409 * @motion
410 *
411 * ```jsx
412 * import { AnimatePresence, motion } from 'framer-motion'
413 *
414 * export const MyComponent = ({ isVisible }) => {
415 * return (
416 * <AnimatePresence>
417 * {isVisible && (
418 * <motion.div
419 * initial={{ opacity: 0 }}
420 * animate={{ opacity: 1 }}
421 * exit={{ opacity: 0 }}
422 * />
423 * )}
424 * </AnimatePresence>
425 * )
426 * }
427 * ```
428 */
429 exit?: TargetAndTransition | VariantLabels | TargetResolver;
430 /**
431 * Variants allow you to define animation states and organise them by name. They allow
432 * you to control animations throughout a component tree by switching a single `animate` prop.
433 *
434 * Using `transition` options like `delayChildren` and `staggerChildren`, you can orchestrate
435 * when children animations play relative to their parent.
436 *
437 * @library
438 *
439 * After passing variants to one or more `Frame`'s `variants` prop, these variants
440 * can be used in place of values on the `animate`, `initial`, `whileTap` and `whileHover` props.
441 *
442 * ```jsx
443 * const variants = {
444 * active: {
445 * backgroundColor: "#f00"
446 * },
447 * inactive: {
448 * backgroundColor: "#fff",
449 * transition: { duration: 2 }
450 * }
451 * }
452 *
453 * <Frame variants={variants} animate="active" />
454 * ```
455 *
456 * @motion
457 *
458 * After passing variants to one or more `motion` component's `variants` prop, these variants
459 * can be used in place of values on the `animate`, `initial`, `whileTap` and `whileHover` props.
460 *
461 * ```jsx
462 * const variants = {
463 * active: {
464 * backgroundColor: "#f00"
465 * },
466 * inactive: {
467 * backgroundColor: "#fff",
468 * transition: { duration: 2 }
469 * }
470 * }
471 *
472 * <motion.div variants={variants} animate="active" />
473 * ```
474 */
475 variants?: Variants;
476 /**
477 * Default transition. If no `transition` is defined in `animate`, it will use the transition defined here.
478 *
479 * @library
480 *
481 * ```jsx
482 * const spring = {
483 * type: "spring",
484 * damping: 10,
485 * stiffness: 100
486 * }
487 *
488 * <Frame transition={spring} animate={{ scale: 1.2 }} />
489 * ```
490 *
491 * @motion
492 *
493 * ```jsx
494 * const spring = {
495 * type: "spring",
496 * damping: 10,
497 * stiffness: 100
498 * }
499 *
500 * <motion.div transition={spring} animate={{ scale: 1.2 }} />
501 * ```
502 */
503 transition?: Transition;
504 /**
505 * @library
506 *
507 * When a `Frame` is the child of a `Stack`, the `Stack` is responsible for its layout. This makes it harder
508 * for us to know when a `Frame`'s position changes within the `Stack` and make it animate to its new position.
509 *
510 * By adding `positionTransition` to a `Frame`, it'll automatically animate to its new position in the `Stack`,
511 * whether the `Stack` layout has changed or the `Frame` has changed its order within it.
512 *
513 * It can either be set as a `Transition`, or just `true` to use the default layout transition.
514 *
515 * ```jsx
516 * function MyComponent({ distribution = "space-around" }) {
517 * const spring = {
518 * type: "spring",
519 * damping: 10,
520 * stiffness: 100
521 * }
522 *
523 * return (
524 * <Stack distribution={distribution}>
525 * <Frame layoutTransition={spring} />
526 * </Stack>
527 * )
528 * }
529 * ```
530 *
531 * @motion
532 *
533 * If `positionTransition` is defined on a `motion` component, it will automatically animate any changes to its layout
534 * using a performant `x`/`y` transform.
535 *
536 * `positionTransition` can either be set as a `Transition`, or just `true` to use the default position transition, which is a snappy spring.
537 *
538 * It can also be set as a function that will resolve when the component has changed layout. This function
539 * should return either a `Transition`, or `true`. For advanced use-cases where you want the component
540 * to visually stay in its previous position, this function can also return `false`. This function will receive
541 * the `delta` of the changed layout.
542 *
543 * ```jsx
544 * const spring = {
545 * type: "spring",
546 * damping: 10,
547 * stiffness: 100
548 * }
549 *
550 * // This component will animate position when `isVisible` is toggled.
551 * const MyComponent = ({ isOpen }) => {
552 * return (
553 * <motion.div positionTransition={spring} style={{ left: isOpen ? 0 : 100 }} />
554 * )
555 * }
556 *
557 * // This component will animate items to their new position if its place in `items` changes order.
558 * const MyComponent = ({ items }) => {
559 * return items.map((item) => (
560 * <motion.div key={item.id} positionTransition={spring} />
561 * ))
562 * }
563 * ```
564 *
565 * @public
566 */
567 positionTransition?: Transition | boolean | ResolveLayoutTransition;
568 /**
569 * @library
570 *
571 * When a `Frame` is the child of a `Stack`, the `Stack` is responsible for its layout. This makes it
572 * difficult for to know when the layout changes and smoothly animate components to their new positions.
573 *
574 * By adding `layoutTransition` to a child `Frame`, it'll automatically animate to its new position
575 * when it moves in the `Stack`, whether the `Stack` layout has changed, or the `Frame` has changed order within it.
576 *
577 * It can either be set as a `Transition`, or just `true` to use the default layout transition.
578 *
579 * Animating size with `scale` can introduce visual distortion to the component's children. If unwanted,
580 * the `useInvertedScale` function can be used to undo this distortion.
581 *
582 * ```jsx
583 * function MyComponent({ distribution = "space-around" }) {
584 * const spring = {
585 * type: "spring",
586 * damping: 10,
587 * stiffness: 100
588 * }
589 *
590 * return (
591 * <Stack distribution={distribution}>
592 * <Frame layoutTransition={spring} />
593 * </Stack>
594 * )
595 * }
596 * ```
597 *
598 * @motion
599 *
600 * If `layoutTransition` is defined on a `motion` component, the component will automatically
601 * animate any changes to its position **and** size.
602 *
603 * It will do so using performant transforms. So if a `motion` component changes position, it'll animate
604 * to its new position using `x` and `y`. If it changes size, it'll animate using `scaleX` and `scaleY`.
605 *
606 * Animating size with `scale` can introduce visual distortion to the component's children. If unwanted,
607 * the `useInvertedScale` function can be used to undo this distortion.
608 *
609 * `layoutTransition` can either be set as a `Transition`, or just `true` to use the default layout transition,
610 * which is a smooth `0.8` second ease.
611 *
612 * It can also be set as a function that will resolve when the component has changed layout. This function
613 * should return either a `Transition`, or `true`. For advanced use-cases where you want the component
614 * to visually stay in its previous position, this function can also return `false`. This function will receive
615 * the `delta` of the changed layout.
616 *
617 * ```jsx
618 * const spring = {
619 * type: "spring",
620 * damping: 10,
621 * stiffness: 100
622 * }
623 *
624 * // This component will animate between sizes when `isVisible` is toggled.
625 * const MyComponent = ({ isVisible }) => {
626 * return (
627 * <motion.div layoutTransition={spring}>
628 * {isVisible && <Content />}
629 * </motion.div>
630 * )
631 * }
632 * ```
633 *
634 * @beta
635 */
636 layoutTransition?: Transition | boolean | ResolveLayoutTransition;
637}
638
639declare type AnyPointerEvent = MouseEvent | TouchEvent | PointerEvent;
640
641declare class ComponentDragControls {
642 /**
643 * Track whether we're currently dragging.
644 *
645 * @internal
646 */
647 private isDragging;
648 /**
649 * The current direction of drag, or `null` if both.
650 *
651 * @internal
652 */
653 private currentDirection;
654 /**
655 * The permitted t/r/b/l boundaries of travel, in pixels.
656 *
657 * @internal
658 */
659 private constraints;
660 /**
661 * If `true`, our constraints need to be resolved from a Element ref
662 * passed to props.dragConstraints
663 *
664 * @internal
665 */
666 private constraintsNeedResolution;
667 /**
668 * A reference to the host component's latest props.
669 *
670 * @internal
671 */
672 private props;
673 /**
674 * @internal
675 */
676 private ref;
677 /**
678 * A reference to the host component's animation controls.
679 *
680 * @internal
681 */
682 private controls;
683 /**
684 * A reference to the host component's motion values.
685 *
686 * @internal
687 */
688 private values;
689 /**
690 * References to the MotionValues used for tracking the current dragged point.
691 *
692 * @internal
693 */
694 private point;
695 /**
696 * The origin point for the current drag gesture.
697 *
698 * @internal
699 */
700 private origin;
701 private openGlobalLock;
702 /**
703 * @internal
704 */
705 private panSession;
706 /**
707 * A reference to the previous constraints bounding box
708 *
709 * @internal
710 */
711 private prevConstraintsBox;
712 constructor({ ref, values, controls }: DragControlConfig);
713 /**
714 * Start dragging the host component.
715 *
716 * @param event - The originating pointer event.
717 * @param options -
718 *
719 * @public
720 */
721 start(originEvent: AnyPointerEvent, { snapToCursor }?: DragControlOptions): void;
722 cancelDrag(): void;
723 stop(event: AnyPointerEvent, info: PanInfo): void;
724 recordBoxInfo(constraints?: Constraints | false): void;
725 snapToCursor(event: AnyPointerEvent): void;
726 setPoint(axis: DragDirection, value: MotionValue<number>): void;
727 updatePoint(axis: DragDirection, offset: {
728 x: number;
729 y: number;
730 }): void;
731 updateProps({ drag, dragDirectionLock, dragPropagation, dragConstraints, dragElastic, dragMomentum, ...remainingProps }: DragControlsProps): void;
732 private applyConstraintsToPoint;
733 private animateDragEnd;
734 scalePoint(): void;
735 mount(element: Element): () => void;
736}
737
738declare type Config<T> = {
739 transformer?: Transformer<T>;
740 parent?: MotionValue<T>;
741};
742
743declare type Constraints = {
744 left?: number;
745 right?: number;
746 top?: number;
747 bottom?: number;
748};
749
750declare interface ControlsProp {
751 controls?: ValueAnimationControls;
752}
753
754/**
755 * @internal
756 */
757export declare const createMotionComponent: <P extends {}>({ getValueControlsConfig, loadFunctionalityComponents, renderComponent, }: MotionComponentConfig) => React.ForwardRefExoticComponent<React.PropsWithoutRef<P & MotionProps> & React.RefAttributes<Element>>;
758
759declare type CSSPropertiesWithoutTransitionOrSingleTransforms = Omit<CSSProperties, "transition" | "rotate" | "scale" | "perspective">;
760
761declare interface CustomStyles {
762 /**
763 * Framer Library custom prop types. These are not actually supported in Motion - preferably
764 * we'd have a way of external consumers injecting supported styles into this library.
765 */
766 size?: string | number;
767 radius?: string | number;
768 shadow?: string;
769 image?: string;
770}
771
772/**
773 * @public
774 */
775export declare interface CustomValueType {
776 mix: (from: any, to: any) => (p: number) => number | string;
777 toValue: () => number | string;
778}
779
780declare type Cycle = (i?: number) => void;
781
782declare type CycleState<T> = [T, Cycle];
783
784declare interface DragControlConfig {
785 ref: RefObject<Element>;
786 values: MotionValuesMap;
787 controls: ValueAnimationControls;
788}
789
790declare interface DragControlOptions {
791 snapToCursor?: boolean;
792}
793
794/**
795 * Can manually trigger a drag gesture on one or more `drag`-enabled `motion` components.
796 *
797 * @library
798 *
799 * ```jsx
800 * const dragControls = useDragControls()
801 *
802 * function startDrag(event) {
803 * dragControls.start(event, { snapToCursor: true })
804 * }
805 *
806 * return (
807 * <>
808 * <Frame onTapStart={startDrag} />
809 * <Frame drag="x" dragControls={dragControls} />
810 * </>
811 * )
812 * ```
813 *
814 * @motion
815 *
816 * ```jsx
817 * const dragControls = useDragControls()
818 *
819 * function startDrag(event) {
820 * dragControls.start(event, { snapToCursor: true })
821 * }
822 *
823 * return (
824 * <>
825 * <div onMouseDown={startDrag} />
826 * <motion.div drag="x" dragControls={dragControls} />
827 * </>
828 * )
829 * ```
830 *
831 * @public
832 */
833export declare class DragControls {
834 private componentControls;
835 /**
836 * Subscribe a component's internal `ComponentDragControls` to the user-facing API.
837 *
838 * @internal
839 */
840 subscribe(controls: ComponentDragControls): () => void;
841 /**
842 * Start a drag gesture on every `motion` component that has this set of drag controls
843 * passed into it via the `dragControls` prop.
844 *
845 * ```jsx
846 * dragControls.start(e, {
847 * snapToCursor: true
848 * })
849 * ```
850 *
851 * @param event - A mouse/touch/pointer event.
852 * @param options - Options
853 *
854 * @public
855 */
856 start(event: React.MouseEvent | React.TouchEvent | React.PointerEvent | MouseEvent | TouchEvent | PointerEvent, options?: DragControlOptions): void;
857}
858
859declare interface DragControlsProps extends DraggableProps {
860 transformPagePoint: (point: Point) => Point;
861}
862
863declare type DragDirection = "x" | "y";
864
865/**
866 * @public
867 */
868export declare interface DraggableProps extends DragHandlers {
869 /**
870 * Enable dragging for this element. Set to `false` by default.
871 * Set `true` to drag in both directions.
872 * Set `"x"` or `"y"` to only drag in a specific direction.
873 *
874 * @library
875 *
876 * ```jsx
877 * <Frame drag="x" />
878 * ```
879 *
880 * @motion
881 *
882 * ```jsx
883 * <motion.div drag="x" />
884 * ```
885 */
886 drag?: boolean | "x" | "y";
887 /**
888 * If `true`, this will lock dragging to the initially-detected direction. Defaults to `false`.
889 *
890 * @library
891 *
892 * ```jsx
893 * <Frame drag={true} dragDirectionLock={true} />
894 * ```
895 *
896 * @motion
897 *
898 * ```jsx
899 * <motion.div drag dragDirectionLock />
900 * ```
901 */
902 dragDirectionLock?: boolean;
903 /**
904 * Allows drag gesture propagation to child components. Set to `false` by
905 * default.
906 *
907 * @library
908 *
909 * ```jsx
910 * <Frame drag="x" dragPropagation={true} />
911 * ```
912 *
913 * @motion
914 *
915 * ```jsx
916 * <motion.div drag="x" dragPropagation />
917 * ```
918 */
919 dragPropagation?: boolean;
920 /**
921 * An object of optional `top`, `left`, `right`, `bottom` pixel values,
922 * beyond which dragging is constrained.
923 *
924 * Another component can be used as drag constraints by creating a `ref` with React's `useRef`.hook.
925 * This `ref` should be passed to that component's `ref` prop and to this component's `dragConstraints` prop.
926 *
927 * @library
928 *
929 * ```jsx
930 * // In pixels
931 * <Frame
932 * drag="x"
933 * dragConstraints={{ left: 0, right: 300 }}
934 * />
935 *
936 * // As a ref to another component
937 * function MyComponent() {
938 * const constraintsRef = useRef(null)
939 *
940 * return (
941 * <Frame ref={constraintsRef} width={400} height={400}>
942 * <Frame drag dragConstraints={constraintsRef} />
943 * </Frame>
944 * )
945 * }
946 * ```
947 *
948 * @motion
949 *
950 * ```jsx
951 * // In pixels
952 * <motion.div
953 * drag="x"
954 * dragConstraints={{ left: 0, right: 300 }}
955 * />
956 *
957 * // As a ref to another component
958 * const MyComponent = () => {
959 * const constraintsRef = useRef(null)
960 *
961 * return (
962 * <motion.div ref={constraintsRef}>
963 * <motion.div drag dragConstraints={constraintsRef} />
964 * </motion.div>
965 * )
966 * }
967 * ```
968 */
969 dragConstraints?: false | {
970 top?: number;
971 right?: number;
972 bottom?: number;
973 left?: number;
974 } | RefObject<Element>;
975 /**
976 * The degree of movement allowed outside constraints. 0 = no movement, 1 =
977 * full movement. Set to `0.5` by default.
978 *
979 * @library
980 *
981 * ```jsx
982 * <Frame
983 * drag={true}
984 * dragConstraints={{ left: 0, right: 300 }}
985 * dragElastic={0.2}
986 * />
987 * ```
988 *
989 * @motion
990 *
991 * ```jsx
992 * <motion.div
993 * drag
994 * dragConstraints={{ left: 0, right: 300 }}
995 * dragElastic={0.2}
996 * />
997 * ```
998 */
999 dragElastic?: boolean | number;
1000 /**
1001 * Apply momentum from the pan gesture to the component when dragging
1002 * finishes. Set to `true` by default.
1003 *
1004 * @library
1005 *
1006 * ```jsx
1007 * <Frame
1008 * drag={true}
1009 * dragConstraints={{ left: 0, right: 300 }}
1010 * dragMomentum={false}
1011 * />
1012 * ```
1013 *
1014 * @motion
1015 *
1016 * ```jsx
1017 * <motion.div
1018 * drag
1019 * dragConstraints={{ left: 0, right: 300 }}
1020 * dragMomentum={false}
1021 * />
1022 * ```
1023 */
1024 dragMomentum?: boolean;
1025 /**
1026 * Allows you to change dragging inertia parameters.
1027 * 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.
1028 * See {@link https://framer.com/api/animation/#inertia | Inertia} for all properties you can use.
1029 *
1030 * @library
1031 *
1032 * ```jsx
1033 * <Frame
1034 * drag={true}
1035 * dragTransition={{ bounceStiffness: 600, bounceDamping: 10 }}
1036 * />
1037 * ```
1038 *
1039 * @motion
1040 *
1041 * ```jsx
1042 * <motion.div
1043 * drag
1044 * dragTransition={{ bounceStiffness: 600, bounceDamping: 10 }}
1045 * />
1046 * ```
1047 */
1048 dragTransition?: InertiaOptions;
1049 /**
1050 * @internalremarks
1051 *
1052 * _dragValueX, _dragValueY and _dragTransitionControls are a way of allowing this
1053 * component to be a drag target for another element.
1054 *
1055 * @internal
1056 */
1057 _dragValueX?: MotionValue<number>;
1058 /**
1059 * @internal
1060 */
1061 _dragValueY?: MotionValue<number>;
1062 /**
1063 * @internal
1064 */
1065 _dragTransitionControls?: AnimationControls;
1066 /**
1067 * Drag position is calculated by applying the pan offset to the x/y origin
1068 * measured when the drag gesture begins.
1069 *
1070 * By manually creating `dragOriginX` as a `MotionValue`, it can be updated
1071 * while the gesture is active, for instance to visually offset any movement should
1072 * the component change layout.
1073 *
1074 * @library
1075 *
1076 * ```jsx
1077 * const dragOriginX = useMotionValue(0)
1078 *
1079 * return <Frame dragOriginX={dragOriginX} />
1080 * ```
1081 *
1082 * @motion
1083 *
1084 * ```jsx
1085 * const dragOriginX = useMotionValue(0)
1086 *
1087 * return <motion.div dragOriginX={dragOriginX} />
1088 * ```
1089 *
1090 * @public
1091 */
1092 dragOriginX?: MotionValue<number>;
1093 /**
1094 * Drag position is calculated by applying the pan offset to the x/y origin
1095 * measured when the drag gesture begins.
1096 *
1097 * By manually creating `dragOriginY` as a `MotionValue`, it can be updated
1098 * while the gesture is active, for instance to visually offset any movement should
1099 * the component change layout.
1100 *
1101 * @library
1102 *
1103 * ```jsx
1104 * const dragOriginY = useMotionValue(0)
1105 *
1106 * return <Frame dragOriginY={dragOriginY} />
1107 * ```
1108 *
1109 * @motion
1110 *
1111 * ```jsx
1112 * const dragOriginY = useMotionValue(0)
1113 *
1114 * return <motion.div dragOriginY={dragOriginY} />
1115 * ```
1116 *
1117 * @public
1118 */
1119 dragOriginY?: MotionValue<number>;
1120 /**
1121 * Usually, dragging is initiated by pressing down on a component and moving it. For some
1122 * use-cases, for instance clicking at an arbitrary point on a video scrubber, we
1123 * might want to initiate dragging from a different component than the draggable one.
1124 *
1125 * By creating a `dragControls` using the `useDragControls` hook, we can pass this into
1126 * the draggable component's `dragControls` prop. It exposes a `start` method
1127 * that can start dragging from pointer events on other components.
1128 *
1129 * @library
1130 *
1131 * ```jsx
1132 * const dragControls = useDragControls()
1133 *
1134 * function startDrag(event) {
1135 * dragControls.start(event, { snapToCursor: true })
1136 * }
1137 *
1138 * return (
1139 * <>
1140 * <Frame onTapStart={startDrag} />
1141 * <Frame drag="x" dragControls={dragControls} />
1142 * </>
1143 * )
1144 * ```
1145 *
1146 * @motion
1147 *
1148 * ```jsx
1149 * const dragControls = useDragControls()
1150 *
1151 * function startDrag(event) {
1152 * dragControls.start(event, { snapToCursor: true })
1153 * }
1154 *
1155 * return (
1156 * <>
1157 * <div onMouseDown={startDrag} />
1158 * <motion.div drag="x" dragControls={dragControls} />
1159 * </>
1160 * )
1161 * ```
1162 */
1163 dragControls?: DragControls;
1164 /**
1165 * By default, if `drag` is defined on a component then an event listener will be attached
1166 * to automatically initiate dragging when a user presses down on it.
1167 *
1168 * By setting `dragListener` to `false`, this event listener will not be created.
1169 *
1170 * @library
1171 *
1172 * ```jsx
1173 * const dragControls = useDragControls()
1174 *
1175 * function startDrag(event) {
1176 * dragControls.start(event, { snapToCursor: true })
1177 * }
1178 *
1179 * return (
1180 * <>
1181 * <Frame onTapStart={startDrag} />
1182 * <Frame
1183 * drag="x"
1184 * dragControls={dragControls}
1185 * dragListener={false}
1186 * />
1187 * </>
1188 * )
1189 * ```
1190 *
1191 * @motion
1192 *
1193 * ```jsx
1194 * const dragControls = useDragControls()
1195 *
1196 * function startDrag(event) {
1197 * dragControls.start(event, { snapToCursor: true })
1198 * }
1199 *
1200 * return (
1201 * <>
1202 * <div onMouseDown={startDrag} />
1203 * <motion.div
1204 * drag="x"
1205 * dragControls={dragControls}
1206 * dragListener={false}
1207 * />
1208 * </>
1209 * )
1210 * ```
1211 */
1212 dragListener?: boolean;
1213}
1214
1215/**
1216 * @public
1217 */
1218export declare interface DragHandlers {
1219 /**
1220 * Callback function that fires when dragging starts.
1221 *
1222 * @library
1223 *
1224 * ```jsx
1225 * function onDragStart(event, info) {
1226 * console.log(info.point.x, info.point.y)
1227 * }
1228 *
1229 * <Frame drag onDragStart={onDragStart} />
1230 * ```
1231 *
1232 * @motion
1233 *
1234 * ```jsx
1235 * <motion.div
1236 * drag
1237 * onDragStart={
1238 * (event, info) => console.log(info.point.x, info.point.y)
1239 * }
1240 * />
1241 * ```
1242 *
1243 * @public
1244 */
1245 onDragStart?(event: MouseEvent | TouchEvent | PointerEvent, info: PanInfo): void;
1246 /**
1247 * Callback function that fires when dragging ends.
1248 *
1249 * @library
1250 *
1251 * ```jsx
1252 * function onDragEnd(event, info) {
1253 * console.log(info.point.x, info.point.y)
1254 * }
1255 *
1256 * <Frame drag onDragEnd={onDragEnd} />
1257 * ```
1258 *
1259 * @motion
1260 *
1261 * ```jsx
1262 * <motion.div
1263 * drag
1264 * onDragEnd={
1265 * (event, info) => console.log(info.point.x, info.point.y)
1266 * }
1267 * />
1268 * ```
1269 *
1270 * @public
1271 */
1272 onDragEnd?(event: MouseEvent | TouchEvent | PointerEvent, info: PanInfo): void;
1273 /**
1274 * Callback function that fires when the component is dragged.
1275 *
1276 * @library
1277 *
1278 * ```jsx
1279 * function onDrag(event, info) {
1280 * console.log(info.point.x, info.point.y)
1281 * }
1282 *
1283 * <Frame drag onDrag={onDrag} />
1284 * ```
1285 *
1286 * @motion
1287 *
1288 * ```jsx
1289 * <motion.div
1290 * drag
1291 * onDrag={
1292 * (event, info) => console.log(info.point.x, info.point.y)
1293 * }
1294 * />
1295 * ```
1296 *
1297 * @public
1298 */
1299 onDrag?(event: MouseEvent | TouchEvent | PointerEvent, info: PanInfo): void;
1300 /**
1301 * Callback function that fires a drag direction is determined.
1302 *
1303 * @library
1304 *
1305 * ```jsx
1306 * function onDirectionLock(axis) {
1307 * console.log(axis)
1308 * }
1309 *
1310 * <Frame
1311 * drag
1312 * dragDirectionLock
1313 * onDirectionLock={onDirectionLock}
1314 * />
1315 * ```
1316 *
1317 * @motion
1318 *
1319 * ```jsx
1320 * <motion.div
1321 * drag
1322 * dragDirectionLock
1323 * onDirectionLock={axis => console.log(axis)}
1324 * />
1325 * ```
1326 *
1327 * @public
1328 */
1329 onDirectionLock?(axis: "x" | "y"): void;
1330 /**
1331 * Callback function that fires when drag momentum/bounce transition finishes.
1332 *
1333 * @library
1334 *
1335 * ```jsx
1336 * function onDragTransitionEnd() {
1337 * console.log('drag transition has ended')
1338 * }
1339 *
1340 * <Frame
1341 * drag
1342 * onDragTransitionEnd={onDragTransitionEnd}
1343 * />
1344 * ```
1345 *
1346 * @motion
1347 *
1348 * ```jsx
1349 * <motion.div
1350 * drag
1351 * onDragTransitionEnd={() => console.log('Drag transition complete')}
1352 * />
1353 * ```
1354 *
1355 * @public
1356 */
1357 onDragTransitionEnd?(): void;
1358}
1359
1360/**
1361 * The easing function to use. Set as one of:
1362 *
1363 * - The name of an in-built easing function.
1364 * - An array of four numbers to define a cubic bezier curve.
1365 * - An easing function, that accepts and returns a progress value between `0` and `1`.
1366 *
1367 * @public
1368 */
1369declare type Easing = [number, number, number, number] | "linear" | "easeIn" | "easeOut" | "easeInOut" | "circIn" | "circOut" | "circInOut" | "backIn" | "backOut" | "backInOut" | "anticipate" | EasingFunction;
1370
1371/**
1372 * A function that accepts a progress value between `0` and `1` and returns a
1373 * new one.
1374 *
1375 * @library
1376 *
1377 * ```jsx
1378 * const transition = {
1379 * ease: progress => progress * progress
1380 * }
1381 *
1382 * <Frame
1383 * animate={{ opacity: 0 }}
1384 * transition={transition}
1385 * />
1386 * ```
1387 *
1388 * @motion
1389 *
1390 * ```jsx
1391 * <motion.div
1392 * animate={{ opacity: 0 }}
1393 * transition={{
1394 * duration: 1,
1395 * ease: progress => progress * progress
1396 * }}
1397 * />
1398 * ```
1399 *
1400 * @public
1401 */
1402export declare type EasingFunction = (v: number) => number;
1403
1404/** @public */
1405export declare interface EventInfo {
1406 point: Point;
1407}
1408
1409declare interface ExitProps {
1410 initial?: false | VariantLabels;
1411 isExiting?: boolean;
1412 onExitComplete?: () => void;
1413 custom?: any;
1414}
1415
1416/**
1417 * @public
1418 */
1419export declare type ForwardRefComponent<T, P> = ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>>;
1420
1421declare interface FunctionalProps extends MotionProps {
1422 controls: ValueAnimationControls;
1423 values: MotionValuesMap;
1424 innerRef: RefObject<Element>;
1425 parentContext: MotionContextProps;
1426}
1427
1428/**
1429 * @public
1430 */
1431export declare type GestureHandlers = PanHandlers & TapHandlers & HoverHandlers;
1432
1433/**
1434 * @public
1435 */
1436export declare interface HoverHandlers {
1437 /**
1438 * Properties or variant label to animate to while the hover gesture is recognised.
1439 *
1440 * @library
1441 *
1442 * ```jsx
1443 * <Frame whileHover={{ scale: 1.2 }} />
1444 * ```
1445 *
1446 * @motion
1447 *
1448 * ```jsx
1449 * <motion.div whileHover={{ scale: 1.2 }} />
1450 * ```
1451 */
1452 whileHover?: string | TargetAndTransition;
1453 /**
1454 * Callback function that fires when pointer starts hovering over the component.
1455 *
1456 * @library
1457 *
1458 * ```jsx
1459 * function onHoverStart(event) {
1460 * console.log("Hover starts")
1461 * }
1462 *
1463 * <Frame onHoverStart={onHoverStart} />
1464 * ```
1465 *
1466 * @motion
1467 *
1468 * ```jsx
1469 * <motion.div onHoverStart={() => console.log('Hover starts')} />
1470 * ```
1471 */
1472 onHoverStart?(event: MouseEvent, info: EventInfo): void;
1473 /**
1474 * Callback function that fires when pointer stops hovering over the component.
1475 *
1476 * @library
1477 *
1478 * ```jsx
1479 * function onHoverEnd(event) {
1480 * console.log("Hover ends")
1481 * }
1482 *
1483 * <Frame onHoverEnd={onHoverEnd} />
1484 * ```
1485 *
1486 * @motion
1487 *
1488 * ```jsx
1489 * <motion.div onHoverEnd={() => console.log("Hover ends")} />
1490 * ```
1491 */
1492 onHoverEnd?(event: MouseEvent, info: EventInfo): void;
1493}
1494
1495declare type HTMLAttributesWithoutMotionProps<Attributes extends HTMLAttributes<Element>, Element extends HTMLElement> = {
1496 [K in Exclude<keyof Attributes, keyof MotionProps>]?: Attributes[K];
1497};
1498
1499/**
1500 * @public
1501 */
1502export declare type HTMLMotionProps<TagName extends keyof ReactHTML> = HTMLAttributesWithoutMotionProps<UnwrapFactoryAttributes<ReactHTML[TagName]>, UnwrapFactoryElement<ReactHTML[TagName]>> & MotionProps;
1503
1504/**
1505 * An animation that decelerates a value based on its initial velocity,
1506 * usually used to implement inertial scrolling.
1507 *
1508 * Optionally, `min` and `max` boundaries can be defined, and inertia
1509 * will snap to these with a spring animation.
1510 *
1511 * This animation will automatically precalculate a target value,
1512 * which can be modified with the `modifyTarget` property.
1513 *
1514 * This allows you to add snap-to-grid or similar functionality.
1515 *
1516 * Inertia is also the animation used for `dragTransition`, and can be configured via that prop.
1517 *
1518 * @public
1519 */
1520export declare interface Inertia {
1521 /**
1522 * Set `type` to animate using the inertia animation. Set to `"tween"` by
1523 * default. This can be used for natural deceleration, like momentum scrolling.
1524 *
1525 * @library
1526 *
1527 * ```jsx
1528 * const transition = {
1529 * type: "inertia",
1530 * velocity: 50
1531 * }
1532 *
1533 * <Frame
1534 * animate={{ rotate: 180 }}
1535 * transition={transition}
1536 * />
1537 * ```
1538 *
1539 * @motion
1540 *
1541 * ```jsx
1542 * <motion.div
1543 * animate={{ rotate: 180 }}
1544 * transition={{ type: "inertia", velocity: 50 }}
1545 * />
1546 * ```
1547 *
1548 * @public
1549 */
1550 type: "inertia";
1551 /**
1552 * A function that receives the automatically-calculated target and returns a new one. Useful for snapping the target to a grid.
1553 *
1554 * @library
1555 *
1556 * ```jsx
1557 * const transition = {
1558 * power: 0,
1559 * // Snap calculated target to nearest 50 pixels
1560 * modifyTarget: target => Math.round(target / 50) * 50
1561 * }
1562 *
1563 * <Frame
1564 * drag
1565 * dragTransition={transition}
1566 * />
1567 * ```
1568 *
1569 * @motion
1570 *
1571 * ```jsx
1572 * <motion.div
1573 * drag
1574 * dragTransition={{
1575 * power: 0,
1576 * // Snap calculated target to nearest 50 pixels
1577 * modifyTarget: target => Math.round(target / 50) * 50
1578 * }}
1579 * />
1580 * ```
1581 *
1582 * @public
1583 */
1584 modifyTarget?(v: number): number;
1585 /**
1586 * If `min` or `max` is set, this affects the stiffness of the bounce
1587 * spring. Higher values will create more sudden movement. Set to `500` by
1588 * default.
1589 *
1590 * @library
1591 *
1592 * ```jsx
1593 * const transition = {
1594 * min: 0,
1595 * max: 100,
1596 * bounceStiffness: 100
1597 * }
1598 *
1599 * <Frame
1600 * drag
1601 * dragTransition={transition}
1602 * />
1603 * ```
1604 *
1605 * @motion
1606 *
1607 * ```jsx
1608 * <motion.div
1609 * drag
1610 * dragTransition={{
1611 * min: 0,
1612 * max: 100,
1613 * bounceStiffness: 100
1614 * }}
1615 * />
1616 * ```
1617 *
1618 * @public
1619 */
1620 bounceStiffness?: number;
1621 /**
1622 * If `min` or `max` is set, this affects the damping of the bounce spring.
1623 * If set to `0`, spring will oscillate indefinitely. Set to `10` by
1624 * default.
1625 *
1626 * @library
1627 *
1628 * ```jsx
1629 * const transition = {
1630 * min: 0,
1631 * max: 100,
1632 * bounceDamping: 8
1633 * }
1634 *
1635 * <Frame
1636 * drag
1637 * dragTransition={transition}
1638 * />
1639 * ```
1640 *
1641 * @motion
1642 *
1643 * ```jsx
1644 * <motion.div
1645 * drag
1646 * dragTransition={{
1647 * min: 0,
1648 * max: 100,
1649 * bounceDamping: 8
1650 * }}
1651 * />
1652 * ```
1653 *
1654 * @public
1655 */
1656 bounceDamping?: number;
1657 /**
1658 * A higher power value equals a further target. Set to `0.8` by default.
1659 *
1660 * @library
1661 *
1662 * ```jsx
1663 * const transition = {
1664 * min: 0,
1665 * max: 100,
1666 * power: 0.2
1667 * }
1668 *
1669 * <Frame
1670 * drag
1671 * dragTransition={transition}
1672 * />
1673 * ```
1674 *
1675 * @motion
1676 *
1677 * ```jsx
1678 * <motion.div
1679 * drag
1680 * dragTransition={{ power: 0.2 }}
1681 * />
1682 * ```
1683 *
1684 * @public
1685 */
1686 power?: number;
1687 /**
1688 * Adjusting the time constant will change the duration of the
1689 * deceleration, thereby affecting its feel. Set to `700` by default.
1690 *
1691 * @library
1692 *
1693 * ```jsx
1694 * const transition = {
1695 * min: 0,
1696 * max: 100,
1697 * timeConstant: 200
1698 * }
1699 *
1700 * <Frame
1701 * drag
1702 * dragTransition={transition}
1703 * />
1704 * ```
1705 *
1706 * @motion
1707 *
1708 * ```jsx
1709 * <motion.div
1710 * drag
1711 * dragTransition={{ timeConstant: 200 }}
1712 * />
1713 * ```
1714 *
1715 * @public
1716 */
1717 timeConstant?: number;
1718 /**
1719 * End the animation if the distance to the animation target is below this value, and the absolute speed is below `restSpeed`.
1720 * When the animation ends, the value gets snapped to the animation target. Set to `0.01` by default.
1721 * Generally the default values provide smooth animation endings, only in rare cases should you need to customize these.
1722 *
1723 * @library
1724 *
1725 * ```jsx
1726 * const transition = {
1727 * min: 0,
1728 * max: 100,
1729 * restDelta: 10
1730 * }
1731 *
1732 * <Frame
1733 * drag
1734 * dragTransition={transition}
1735 * />
1736 * ```
1737 *
1738 * @motion
1739 *
1740 * ```jsx
1741 * <motion.div
1742 * drag
1743 * dragTransition={{ restDelta: 10 }}
1744 * />
1745 * ```
1746 *
1747 * @public
1748 */
1749 restDelta?: number;
1750 /**
1751 * 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).
1752 *
1753 * @library
1754 *
1755 * ```jsx
1756 * <Frame
1757 * drag
1758 * dragTransition={{ min: 0, max: 100 }}
1759 * />
1760 * ```
1761 *
1762 * @motion
1763 *
1764 * ```jsx
1765 * <motion.div
1766 * drag
1767 * dragTransition={{ min: 0, max: 100 }}
1768 * />
1769 * ```
1770 *
1771 * @public
1772 */
1773 min?: number;
1774 /**
1775 * Maximum constraint. If set, the value will "bump" against this value (or immediately snap to it, if the initial animation value exceeds this value).
1776 *
1777 * @library
1778 *
1779 * ```jsx
1780 * <Frame
1781 * drag
1782 * dragTransition={{ min: 0, max: 100 }}
1783 * />
1784 * ```
1785 *
1786 * @motion
1787 *
1788 * ```jsx
1789 * <motion.div
1790 * drag
1791 * dragTransition={{ min: 0, max: 100 }}
1792 * />
1793 * ```
1794 *
1795 * @public
1796 */
1797 max?: number;
1798 /**
1799 * The value to animate from. By default, this is the current state of the animating value.
1800 *
1801 * @library
1802 *
1803 * ```jsx
1804 * const transition = {
1805 * min: 0,
1806 * max: 100,
1807 * from: 50
1808 * }
1809 *
1810 * <Frame
1811 * drag
1812 * dragTransition={transition}
1813 * />
1814 * ```
1815 *
1816 * @motion
1817 *
1818 * ```jsx
1819 * <Frame
1820 * drag
1821 * dragTransition={{ from: 50 }}
1822 * />
1823 * ```
1824 *
1825 * @public
1826 */
1827 from?: number | string;
1828 /**
1829 * The initial velocity of the animation.
1830 * By default this is the current velocity of the component.
1831 *
1832 * @library
1833 *
1834 * ```jsx
1835 * const transition = {
1836 * type: "inertia",
1837 * velocity: 200
1838 * }
1839 *
1840 * <Frame
1841 * animate={{ rotate: 180 }}
1842 * transition={transition}
1843 * />
1844 * ```
1845 *
1846 * @motion
1847 *
1848 * ```jsx
1849 * <motion.div
1850 * animate={{ rotate: 180 }}
1851 * transition={{ type: 'inertia', velocity: 200 }}
1852 * />
1853 * ```
1854 *
1855 * @public
1856 */
1857 velocity?: number;
1858 /**
1859 * @internal
1860 */
1861 delay?: number;
1862}
1863
1864/**
1865 * @public
1866 */
1867declare type InertiaOptions = Partial<Omit<Inertia, "velocity" | "type">>;
1868
1869/**
1870 * Check whether a prop name is a valid `MotionProp` key.
1871 *
1872 * @param key - Name of the property to check
1873 * @returns `true` is key is a valid `MotionProp`.
1874 *
1875 * @public
1876 */
1877export declare function isValidMotionProp(key: string): boolean;
1878
1879/**
1880 * @internal
1881 */
1882declare interface Just {
1883 type: "just";
1884 to?: number | string | ValueTarget;
1885 from?: number | string;
1886 delay?: number;
1887 velocity?: number;
1888}
1889
1890/**
1891 * Keyframes tweens between multiple `values`.
1892 *
1893 * These tweens can be arranged using the `duration`, `easings`, and `times` properties.
1894 *
1895 * @internalremarks
1896 * We could possibly make the `type` property redundant, if not for all animations
1897 * then for this one quite easily.
1898 *
1899 * @internal
1900 */
1901export declare interface Keyframes {
1902 /**
1903 * Set `type` to `"keyframes"` to animate using the keyframes animation.
1904 * Set to `"tween"` by default. This can be used to animate between a series of values.
1905 *
1906 * @public
1907 */
1908 type: "keyframes";
1909 /**
1910 * An array of values to animate between.
1911 *
1912 * @internal
1913 */
1914 values: KeyframesTarget;
1915 /**
1916 * An array of numbers between 0 and 1, where `1` represents the `total` duration.
1917 *
1918 * 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`.
1919 *
1920 * Defaults to an array of evenly-spread durations.
1921 *
1922 * @public
1923 */
1924 times?: number[];
1925 /**
1926 * An array of easing functions for each generated tween, or a single easing function applied to all tweens.
1927 *
1928 * This array should be one item less than `values`, as these easings apply to the transitions *between* the `values`.
1929 *
1930 * ```jsx
1931 * const transition = {
1932 * backgroundColor: {
1933 * type: 'keyframes',
1934 * easings: ['circIn', 'circOut']
1935 * }
1936 * }
1937 * ```
1938 *
1939 * @public
1940 */
1941 ease?: Easing | Easing[];
1942 /**
1943 * Popmotion's easing prop to define individual easings. `ease` will be mapped to this prop in keyframes animations.
1944 *
1945 * @internal
1946 */
1947 easings?: Easing | Easing[];
1948 /**
1949 * @internal
1950 */
1951 elapsed?: number;
1952 /**
1953 * The total duration of the animation. Set to `0.3` by default.
1954 *
1955 * ```jsx
1956 * const transition = {
1957 * type: "keyframes",
1958 * duration: 2
1959 * }
1960 *
1961 * <Frame
1962 * animate={{ opacity: 0 }}
1963 * transition={transition}
1964 * />
1965 * ```
1966 *
1967 * @public
1968 */
1969 duration?: number;
1970 /**
1971 * The number of times to loop the animation.
1972 *
1973 * Set to `Infinity` for perpetual looping.
1974 *
1975 * @public
1976 */
1977 loop?: number;
1978 /**
1979 * The number of times to flip the animation by swapping the `to` and `from` values.
1980 * Set to `Infinity` for perpetual flipping.
1981 *
1982 * ```jsx
1983 * const transition = {
1984 * flip: Infinity,
1985 * duration: 2
1986 * }
1987 *
1988 * <Frame
1989 * animate={{ opacity: 0 }}
1990 * transition={transition}
1991 * />
1992 * ```
1993 *
1994 * @public
1995 */
1996 flip?: number;
1997 /**
1998 * The number of times to reverse the animation.
1999 * Set to `Infinity` for perpetual reversing.
2000 *
2001 * ```jsx
2002 * const transition = {
2003 * yoyo: Infinity,
2004 * duration: 2
2005 * }
2006 *
2007 * <Frame
2008 * animate={{ rotate: 180 }}
2009 * transition={transition}
2010 * />
2011 *
2012 * ```
2013 * @public
2014 */
2015 yoyo?: number;
2016 /**
2017 * @public
2018 */
2019 repeatDelay?: number;
2020 /**
2021 * @internal
2022 */
2023 from?: number | string;
2024 /**
2025 * @internal
2026 */
2027 to?: number | string | ValueTarget;
2028 /**
2029 * @internal
2030 */
2031 velocity?: number;
2032 /**
2033 * @internal
2034 */
2035 delay?: number;
2036}
2037
2038/**
2039 * @public
2040 */
2041export declare type KeyframesTarget = ResolvedKeyframesTarget | [null, ...CustomValueType[]] | CustomValueType[];
2042
2043declare type LoadFunctionalityComponents<P = {}> = (ref: RefObject<Element>, values: MotionValuesMap, props: P & MotionProps, parentContext: MotionContextProps, controls: ValueAnimationControls<P>, inherit: boolean) => ReactElement<FunctionalProps>[];
2044
2045declare type MakeCustomValueType<T> = {
2046 [K in keyof T]: T[K] | CustomValueType;
2047};
2048
2049declare type MakeKeyframes<T> = {
2050 [K in keyof T]: T[K] | T[K][] | [null, ...T[K][]];
2051};
2052
2053declare type MakeMotion<T> = MakeCustomValueType<{
2054 [K in keyof T]: T[K] | MotionValue<number> | MotionValue<string> | MotionValue<any>;
2055}>;
2056
2057declare type MakeTargetAnimatable = (target: TargetWithKeyframes, transitionEnd?: Target | undefined) => {
2058 target: TargetWithKeyframes;
2059 transitionEnd?: Target | undefined;
2060};
2061
2062/**
2063 * HTML & SVG components, optimised for use with gestures and animation. These can be used as
2064 * drop-in replacements for any HTML & SVG component, all CSS & SVG properties are supported.
2065 *
2066 * @internalremarks
2067 *
2068 * I'd like to make it possible for these to be loaded "on demand" - to reduce bundle size by only
2069 * including HTML/SVG stylers, animation and/or gesture support when necessary.
2070 *
2071 * ```jsx
2072 * <motion.div animate={{ x: 100 }} />
2073 *
2074 * <motion.p animate={{ height: 200 }} />
2075 *
2076 * <svg><motion.circle r={10} animate={{ r: 20 }} /></svg>
2077 * ```
2078 *
2079 * @public
2080 */
2081export declare const motion: {
2082 symbol: ForwardRefComponent<SVGSymbolElement, SVGMotionProps<SVGSymbolElement>>;
2083 clipPath: ForwardRefComponent<SVGClipPathElement, SVGMotionProps<SVGClipPathElement>>;
2084 filter: ForwardRefComponent<SVGFilterElement, SVGMotionProps<SVGFilterElement>>;
2085 mask: ForwardRefComponent<SVGMaskElement, SVGMotionProps<SVGMaskElement>>;
2086 marker: ForwardRefComponent<SVGMarkerElement, SVGMotionProps<SVGMarkerElement>>;
2087 image: ForwardRefComponent<SVGImageElement, SVGMotionProps<SVGImageElement>>;
2088 text: ForwardRefComponent<SVGTextElement, SVGMotionProps<SVGTextElement>>;
2089 circle: ForwardRefComponent<SVGCircleElement, SVGMotionProps<SVGCircleElement>>;
2090 svg: ForwardRefComponent<SVGSVGElement, SVGMotionProps<SVGSVGElement>>;
2091 animate: ForwardRefComponent<SVGElement, SVGMotionProps<SVGElement>>;
2092 defs: ForwardRefComponent<SVGDefsElement, SVGMotionProps<SVGDefsElement>>;
2093 desc: ForwardRefComponent<SVGDescElement, SVGMotionProps<SVGDescElement>>;
2094 ellipse: ForwardRefComponent<SVGEllipseElement, SVGMotionProps<SVGEllipseElement>>;
2095 feBlend: ForwardRefComponent<SVGFEBlendElement, SVGMotionProps<SVGFEBlendElement>>;
2096 feColorMatrix: ForwardRefComponent<SVGFEColorMatrixElement, SVGMotionProps<SVGFEColorMatrixElement>>;
2097 feComponentTransfer: ForwardRefComponent<SVGFEComponentTransferElement, SVGMotionProps<SVGFEComponentTransferElement>>;
2098 feComposite: ForwardRefComponent<SVGFECompositeElement, SVGMotionProps<SVGFECompositeElement>>;
2099 feConvolveMatrix: ForwardRefComponent<SVGFEConvolveMatrixElement, SVGMotionProps<SVGFEConvolveMatrixElement>>;
2100 feDiffuseLighting: ForwardRefComponent<SVGFEDiffuseLightingElement, SVGMotionProps<SVGFEDiffuseLightingElement>>;
2101 feDisplacementMap: ForwardRefComponent<SVGFEDisplacementMapElement, SVGMotionProps<SVGFEDisplacementMapElement>>;
2102 feDistantLight: ForwardRefComponent<SVGFEDistantLightElement, SVGMotionProps<SVGFEDistantLightElement>>;
2103 feDropShadow: ForwardRefComponent<SVGFEDropShadowElement, SVGMotionProps<SVGFEDropShadowElement>>;
2104 feFlood: ForwardRefComponent<SVGFEFloodElement, SVGMotionProps<SVGFEFloodElement>>;
2105 feFuncA: ForwardRefComponent<SVGFEFuncAElement, SVGMotionProps<SVGFEFuncAElement>>;
2106 feFuncB: ForwardRefComponent<SVGFEFuncBElement, SVGMotionProps<SVGFEFuncBElement>>;
2107 feFuncG: ForwardRefComponent<SVGFEFuncGElement, SVGMotionProps<SVGFEFuncGElement>>;
2108 feFuncR: ForwardRefComponent<SVGFEFuncRElement, SVGMotionProps<SVGFEFuncRElement>>;
2109 feGaussianBlur: ForwardRefComponent<SVGFEGaussianBlurElement, SVGMotionProps<SVGFEGaussianBlurElement>>;
2110 feImage: ForwardRefComponent<SVGFEImageElement, SVGMotionProps<SVGFEImageElement>>;
2111 feMerge: ForwardRefComponent<SVGFEMergeElement, SVGMotionProps<SVGFEMergeElement>>;
2112 feMergeNode: ForwardRefComponent<SVGFEMergeNodeElement, SVGMotionProps<SVGFEMergeNodeElement>>;
2113 feMorphology: ForwardRefComponent<SVGFEMorphologyElement, SVGMotionProps<SVGFEMorphologyElement>>;
2114 feOffset: ForwardRefComponent<SVGFEOffsetElement, SVGMotionProps<SVGFEOffsetElement>>;
2115 fePointLight: ForwardRefComponent<SVGFEPointLightElement, SVGMotionProps<SVGFEPointLightElement>>;
2116 feSpecularLighting: ForwardRefComponent<SVGFESpecularLightingElement, SVGMotionProps<SVGFESpecularLightingElement>>;
2117 feSpotLight: ForwardRefComponent<SVGFESpotLightElement, SVGMotionProps<SVGFESpotLightElement>>;
2118 feTile: ForwardRefComponent<SVGFETileElement, SVGMotionProps<SVGFETileElement>>;
2119 feTurbulence: ForwardRefComponent<SVGFETurbulenceElement, SVGMotionProps<SVGFETurbulenceElement>>;
2120 foreignObject: ForwardRefComponent<SVGForeignObjectElement, SVGMotionProps<SVGForeignObjectElement>>;
2121 g: ForwardRefComponent<SVGGElement, SVGMotionProps<SVGGElement>>;
2122 line: ForwardRefComponent<SVGLineElement, SVGMotionProps<SVGLineElement>>;
2123 linearGradient: ForwardRefComponent<SVGLinearGradientElement, SVGMotionProps<SVGLinearGradientElement>>;
2124 metadata: ForwardRefComponent<SVGMetadataElement, SVGMotionProps<SVGMetadataElement>>;
2125 path: ForwardRefComponent<SVGPathElement, SVGMotionProps<SVGPathElement>>;
2126 pattern: ForwardRefComponent<SVGPatternElement, SVGMotionProps<SVGPatternElement>>;
2127 polygon: ForwardRefComponent<SVGPolygonElement, SVGMotionProps<SVGPolygonElement>>;
2128 polyline: ForwardRefComponent<SVGPolylineElement, SVGMotionProps<SVGPolylineElement>>;
2129 radialGradient: ForwardRefComponent<SVGRadialGradientElement, SVGMotionProps<SVGRadialGradientElement>>;
2130 rect: ForwardRefComponent<SVGRectElement, SVGMotionProps<SVGRectElement>>;
2131 stop: ForwardRefComponent<SVGStopElement, SVGMotionProps<SVGStopElement>>;
2132 switch: ForwardRefComponent<SVGSwitchElement, SVGMotionProps<SVGSwitchElement>>;
2133 textPath: ForwardRefComponent<SVGTextPathElement, SVGMotionProps<SVGTextPathElement>>;
2134 tspan: ForwardRefComponent<SVGTSpanElement, SVGMotionProps<SVGTSpanElement>>;
2135 use: ForwardRefComponent<SVGUseElement, SVGMotionProps<SVGUseElement>>;
2136 view: ForwardRefComponent<SVGViewElement, SVGMotionProps<SVGViewElement>>;
2137 object: ForwardRefComponent<HTMLObjectElement, HTMLMotionProps<"object">>;
2138 style: ForwardRefComponent<HTMLStyleElement, HTMLMotionProps<"style">>;
2139 progress: ForwardRefComponent<HTMLProgressElement, HTMLMotionProps<"progress">>;
2140 ruby: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2141 table: ForwardRefComponent<HTMLTableElement, HTMLMotionProps<"table">>;
2142 small: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2143 sub: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2144 embed: ForwardRefComponent<HTMLEmbedElement, HTMLMotionProps<"embed">>;
2145 pre: ForwardRefComponent<HTMLPreElement, HTMLMotionProps<"pre">>;
2146 caption: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2147 menu: ForwardRefComponent<HTMLElement, HTMLMotionProps<"menu">>;
2148 button: ForwardRefComponent<HTMLButtonElement, HTMLMotionProps<"button">>;
2149 menuitem: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2150 meter: ForwardRefComponent<HTMLElement, HTMLMotionProps<"meter">>;
2151 textarea: ForwardRefComponent<HTMLTextAreaElement, HTMLMotionProps<"textarea">>;
2152 time: ForwardRefComponent<HTMLElement, HTMLMotionProps<"time">>;
2153 link: ForwardRefComponent<HTMLLinkElement, HTMLMotionProps<"link">>;
2154 dialog: ForwardRefComponent<HTMLDialogElement, HTMLMotionProps<"dialog">>;
2155 a: ForwardRefComponent<HTMLAnchorElement, HTMLMotionProps<"a">>;
2156 abbr: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2157 address: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2158 area: ForwardRefComponent<HTMLAreaElement, HTMLMotionProps<"area">>;
2159 article: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2160 aside: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2161 audio: ForwardRefComponent<HTMLAudioElement, HTMLMotionProps<"audio">>;
2162 b: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2163 base: ForwardRefComponent<HTMLBaseElement, HTMLMotionProps<"base">>;
2164 bdi: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2165 bdo: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2166 big: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2167 blockquote: ForwardRefComponent<HTMLElement, HTMLMotionProps<"blockquote">>;
2168 body: ForwardRefComponent<HTMLBodyElement, HTMLMotionProps<"body">>;
2169 br: ForwardRefComponent<HTMLBRElement, HTMLMotionProps<"br">>;
2170 canvas: ForwardRefComponent<HTMLCanvasElement, HTMLMotionProps<"canvas">>;
2171 cite: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2172 code: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2173 col: ForwardRefComponent<HTMLTableColElement, HTMLMotionProps<"col">>;
2174 colgroup: ForwardRefComponent<HTMLTableColElement, HTMLMotionProps<"colgroup">>;
2175 data: ForwardRefComponent<HTMLDataElement, HTMLMotionProps<"data">>;
2176 datalist: ForwardRefComponent<HTMLDataListElement, HTMLMotionProps<"datalist">>;
2177 dd: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2178 del: ForwardRefComponent<HTMLElement, HTMLMotionProps<"del">>;
2179 details: ForwardRefComponent<HTMLElement, HTMLMotionProps<"details">>;
2180 dfn: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2181 div: ForwardRefComponent<HTMLDivElement, HTMLMotionProps<"div">>;
2182 dl: ForwardRefComponent<HTMLDListElement, HTMLMotionProps<"dl">>;
2183 dt: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2184 em: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2185 fieldset: ForwardRefComponent<HTMLFieldSetElement, HTMLMotionProps<"fieldset">>;
2186 figcaption: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2187 figure: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2188 footer: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2189 form: ForwardRefComponent<HTMLFormElement, HTMLMotionProps<"form">>;
2190 h1: ForwardRefComponent<HTMLHeadingElement, HTMLMotionProps<"h1">>;
2191 h2: ForwardRefComponent<HTMLHeadingElement, HTMLMotionProps<"h1">>;
2192 h3: ForwardRefComponent<HTMLHeadingElement, HTMLMotionProps<"h1">>;
2193 h4: ForwardRefComponent<HTMLHeadingElement, HTMLMotionProps<"h1">>;
2194 h5: ForwardRefComponent<HTMLHeadingElement, HTMLMotionProps<"h1">>;
2195 h6: ForwardRefComponent<HTMLHeadingElement, HTMLMotionProps<"h1">>;
2196 head: ForwardRefComponent<HTMLHeadElement, HTMLMotionProps<"head">>;
2197 header: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2198 hgroup: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2199 hr: ForwardRefComponent<HTMLHRElement, HTMLMotionProps<"hr">>;
2200 html: ForwardRefComponent<HTMLHtmlElement, HTMLMotionProps<"html">>;
2201 i: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2202 iframe: ForwardRefComponent<HTMLIFrameElement, HTMLMotionProps<"iframe">>;
2203 img: ForwardRefComponent<HTMLImageElement, HTMLMotionProps<"img">>;
2204 input: ForwardRefComponent<HTMLInputElement, HTMLMotionProps<"input">>;
2205 ins: ForwardRefComponent<HTMLModElement, HTMLMotionProps<"ins">>;
2206 kbd: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2207 keygen: ForwardRefComponent<HTMLElement, HTMLMotionProps<"keygen">>;
2208 label: ForwardRefComponent<HTMLLabelElement, HTMLMotionProps<"label">>;
2209 legend: ForwardRefComponent<HTMLLegendElement, HTMLMotionProps<"legend">>;
2210 li: ForwardRefComponent<HTMLLIElement, HTMLMotionProps<"li">>;
2211 main: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2212 map: ForwardRefComponent<HTMLMapElement, HTMLMotionProps<"map">>;
2213 mark: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2214 meta: ForwardRefComponent<HTMLMetaElement, HTMLMotionProps<"meta">>;
2215 nav: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2216 noscript: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2217 ol: ForwardRefComponent<HTMLOListElement, HTMLMotionProps<"ol">>;
2218 optgroup: ForwardRefComponent<HTMLOptGroupElement, HTMLMotionProps<"optgroup">>;
2219 option: ForwardRefComponent<HTMLOptionElement, HTMLMotionProps<"option">>;
2220 output: ForwardRefComponent<HTMLElement, HTMLMotionProps<"output">>;
2221 p: ForwardRefComponent<HTMLParagraphElement, HTMLMotionProps<"p">>;
2222 param: ForwardRefComponent<HTMLParamElement, HTMLMotionProps<"param">>;
2223 picture: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2224 q: ForwardRefComponent<HTMLQuoteElement, HTMLMotionProps<"q">>;
2225 rp: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2226 rt: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2227 s: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2228 samp: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2229 script: ForwardRefComponent<HTMLScriptElement, HTMLMotionProps<"script">>;
2230 section: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2231 select: ForwardRefComponent<HTMLSelectElement, HTMLMotionProps<"select">>;
2232 source: ForwardRefComponent<HTMLSourceElement, HTMLMotionProps<"source">>;
2233 span: ForwardRefComponent<HTMLSpanElement, HTMLMotionProps<"span">>;
2234 strong: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2235 summary: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2236 sup: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2237 tbody: ForwardRefComponent<HTMLTableSectionElement, HTMLMotionProps<"tbody">>;
2238 td: ForwardRefComponent<HTMLTableDataCellElement, HTMLMotionProps<"td">>;
2239 tfoot: ForwardRefComponent<HTMLTableSectionElement, HTMLMotionProps<"tbody">>;
2240 th: ForwardRefComponent<HTMLTableHeaderCellElement, HTMLMotionProps<"th">>;
2241 thead: ForwardRefComponent<HTMLTableSectionElement, HTMLMotionProps<"tbody">>;
2242 title: ForwardRefComponent<HTMLTitleElement, HTMLMotionProps<"title">>;
2243 tr: ForwardRefComponent<HTMLTableRowElement, HTMLMotionProps<"tr">>;
2244 track: ForwardRefComponent<HTMLTrackElement, HTMLMotionProps<"track">>;
2245 u: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2246 ul: ForwardRefComponent<HTMLUListElement, HTMLMotionProps<"ul">>;
2247 var: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2248 video: ForwardRefComponent<HTMLVideoElement, HTMLMotionProps<"video">>;
2249 wbr: ForwardRefComponent<HTMLElement, HTMLMotionProps<"ruby">>;
2250 webview: ForwardRefComponent<HTMLWebViewElement, HTMLMotionProps<"webview">>;
2251 /**
2252 * Convert a custom React component into a `motion` component.
2253 *
2254 * It can also accept a string, to create [custom DOM elements](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements).
2255 *
2256 * ```jsx
2257 * const Component = React.forwardRef((props: Props, ref) => {
2258 * return <div ref={ref} />
2259 * })
2260 *
2261 * const MotionComponent = motion.custom<Props>(Component)
2262 * ```
2263 *
2264 * @param Component -
2265 */
2266 custom: <Props>(Component: string | React.ComponentClass<Props, any> | React.FunctionComponent<Props>) => React.ForwardRefExoticComponent<React.PropsWithoutRef<Props & MotionProps> & React.RefAttributes<Element>>;
2267};
2268
2269/**
2270 * @public
2271 */
2272export declare interface MotionAdvancedProps {
2273 /**
2274 * Custom data to use to resolve dynamic variants differently for each animating component.
2275 *
2276 * @library
2277 *
2278 * ```jsx
2279 * const variants = {
2280 * visible: (custom) => ({
2281 * opacity: 1,
2282 * transition: { delay: custom * 0.2 }
2283 * })
2284 * }
2285 *
2286 * <Frame custom={0} animate="visible" variants={variants} />
2287 * <Frame custom={1} animate="visible" variants={variants} />
2288 * <Frame custom={2} animate="visible" variants={variants} />
2289 * ```
2290 *
2291 * @motion
2292 *
2293 * ```jsx
2294 * const variants = {
2295 * visible: (custom) => ({
2296 * opacity: 1,
2297 * transition: { delay: custom * 0.2 }
2298 * })
2299 * }
2300 *
2301 * <motion.div custom={0} animate="visible" variants={variants} />
2302 * <motion.div custom={1} animate="visible" variants={variants} />
2303 * <motion.div custom={2} animate="visible" variants={variants} />
2304 * ```
2305 *
2306 * @public
2307 */
2308 custom?: any;
2309 /**
2310 * @public
2311 * Set to `false` to prevent inheriting variant changes from its parent.
2312 */
2313 inherit?: boolean;
2314 /**
2315 * @internal
2316 * Set to `true` to block rendering motion values (`animate`, gestures, etcetera)
2317 * on the component. This can be used to temporarily disable animations for performance reasons.
2318 */
2319 static?: boolean;
2320}
2321
2322/**
2323 * @public
2324 */
2325export declare interface MotionCallbacks {
2326 /**
2327 * Callback with latest motion values, fired max once per frame.
2328 *
2329 * @library
2330 *
2331 * ```jsx
2332 * function onUpdate(latest) {
2333 * console.log(latest.x, latest.opacity)
2334 * }
2335 *
2336 * <Frame animate={{ x: 100, opacity: 0 }} onUpdate={onUpdate} />
2337 * ```
2338 *
2339 * @motion
2340 *
2341 * ```jsx
2342 * function onUpdate(latest) {
2343 * console.log(latest.x, latest.opacity)
2344 * }
2345 *
2346 * <motion.div animate={{ x: 100, opacity: 0 }} onUpdate={onUpdate} />
2347 * ```
2348 */
2349 onUpdate?(latest: {
2350 [key: string]: string | number;
2351 }): void;
2352 /**
2353 * Callback when animation defined in `animate` begins.
2354 *
2355 * @library
2356 *
2357 * ```jsx
2358 * function onStart() {
2359 * console.log("Animation completed")
2360 * }
2361 *
2362 * <Frame animate={{ x: 100 }} onAnimationStart={onStart} />
2363 * ```
2364 *
2365 * @motion
2366 *
2367 * ```jsx
2368 * function onStart() {
2369 * console.log("Animation completed")
2370 * }
2371 *
2372 * <motion.div animate={{ x: 100 }} onAnimationStart={onStart} />
2373 * ```
2374 */
2375 onAnimationStart?(): void;
2376 /**
2377 * Callback when animation defined in `animate` is complete.
2378 *
2379 * @library
2380 *
2381 * ```jsx
2382 * function onComplete() {
2383 * console.log("Animation completed")
2384 * }
2385 *
2386 * <Frame animate={{ x: 100 }} onAnimationComplete={onComplete} />
2387 * ```
2388 *
2389 * @motion
2390 *
2391 * ```jsx
2392 * function onComplete() {
2393 * console.log("Animation completed")
2394 * }
2395 *
2396 * <motion.div animate={{ x: 100 }} onAnimationComplete={onComplete} />
2397 * ```
2398 */
2399 onAnimationComplete?(): void;
2400}
2401
2402declare interface MotionComponentConfig {
2403 loadFunctionalityComponents: LoadFunctionalityComponents;
2404 renderComponent: RenderComponent;
2405 getValueControlsConfig: (ref: RefObject<any>, values: MotionValuesMap) => ValueAnimationConfig;
2406}
2407
2408/**
2409 * @internal
2410 */
2411export declare const MotionContext: React.Context<MotionContextProps>;
2412
2413declare interface MotionContextProps {
2414 controls?: ValueAnimationControls;
2415 values?: MotionValuesMap;
2416 initial?: false | VariantLabels;
2417 animate?: VariantLabels;
2418 static?: boolean;
2419 hasMounted?: RefObject<boolean>;
2420 exitProps?: ExitProps;
2421 isReducedMotion?: boolean | undefined;
2422}
2423
2424declare type MotionCSS = MakeMotion<Omit<CSSProperties, "rotate" | "scale" | "perspective">>;
2425
2426/**
2427 * @internal
2428 */
2429export declare const MotionPluginContext: React.Context<MotionPluginsContext>;
2430
2431declare interface MotionPluginProps extends MotionPluginsContext {
2432 children?: ReactNode;
2433}
2434
2435/**
2436 * @remarks For now I think this should remain a private API for our own use
2437 * until we can figure out a nicer way of allowing people to add these
2438 *
2439 * @internal
2440 */
2441export declare function MotionPlugins({ children, ...props }: MotionPluginProps): JSX.Element;
2442
2443declare interface MotionPluginsContext {
2444 transformPagePoint: (point: Point) => Point;
2445}
2446
2447/**
2448 * Props for `motion` components.
2449 *
2450 * @public
2451 */
2452export declare interface MotionProps extends AnimationProps, MotionCallbacks, GestureHandlers, DraggableProps, MotionAdvancedProps {
2453 /**
2454 * Properties, variant label or array of variant labels to start in.
2455 *
2456 * Set to `false` to initialise with the values in `animate` (disabling the mount animation)
2457 *
2458 * @library
2459 *
2460 * ```jsx
2461 * // As values
2462 * <Frame initial={{ opacity: 1 }} />
2463 *
2464 * // As variant
2465 * <Frame initial="visible" variants={variants} />
2466 *
2467 * // Multiple variants
2468 * <Frame initial={["visible", "active"]} variants={variants} />
2469 *
2470 * // As false (disable mount animation)
2471 * <Frame initial={false} animate={{ opacity: 0 }} />
2472 * ```
2473 *
2474 * @motion
2475 *
2476 * ```jsx
2477 * // As values
2478 * <motion.div initial={{ opacity: 1 }} />
2479 *
2480 * // As variant
2481 * <motion.div initial="visible" variants={variants} />
2482 *
2483 * // Multiple variants
2484 * <motion.div initial={["visible", "active"]} variants={variants} />
2485 *
2486 * // As false (disable mount animation)
2487 * <motion.div initial={false} animate={{ opacity: 0 }} />
2488 * ```
2489 */
2490 initial?: boolean | Target | VariantLabels;
2491 /**
2492 * @library
2493 *
2494 * The React DOM `style` prop, useful for setting CSS properties that aren't explicitly exposed by `Frame` props.
2495 *
2496 * ```jsx
2497 * <Frame style={{ mixBlendMode: "difference" }} />
2498 * ```
2499 *
2500 * @motion
2501 *
2502 * The React DOM `style` prop, enhanced with support for `MotionValue`s and separate `transform` values.
2503 *
2504 * ```jsx
2505 * export const MyComponent = () => {
2506 * const x = useMotionValue(0)
2507 *
2508 * return <motion.div style={{ x, opacity: 1, scale: 0.5 }} />
2509 * }
2510 * ```
2511 */
2512 style?: MotionStyle;
2513 /**
2514 * By default, Framer Motion generates a `transform` property with a sensible transform order. `transformTemplate`
2515 * can be used to create a different order, or to append/preprend the automatically generated `transform` property.
2516 *
2517 * @library
2518 *
2519 * ```jsx
2520 * function transformTemplate({ x, rotate }) {
2521 * return `rotate(${rotate}deg) translateX(${x}px)`
2522 * }
2523 *
2524 * <Frame x={0} rotate={180} transformTemplate={transformTemplate} />
2525 * ```
2526 *
2527 * @motion
2528 *
2529 * ```jsx
2530 * <motion.div
2531 * style={{ x: 0, rotate: 180 }}
2532 * transformTemplate={
2533 * ({ x, rotate }) => `rotate(${rotate}deg) translateX(${x}px)`
2534 * }
2535 * />
2536 * ```
2537 *
2538 * @param transform - The latest animated transform props.
2539 * @param generatedTransform - The transform string as automatically generated by Framer Motion
2540 *
2541 * @public
2542 */
2543 transformTemplate?(transform: TransformProperties, generatedTransform: string): string;
2544 /**
2545 * This allows values to be transformed before being animated or set as styles.
2546 *
2547 * For instance, this allows custom values in Framer Library like `size` to be converted into `width` and `height`.
2548 * It also allows us a chance to take a value like `Color` and convert it to an animatable color string.
2549 *
2550 * A few structural typing changes need making before this can be a public property:
2551 * - Allow `Target` values to be appended by user-defined types (delete `CustomStyles` - does `size` throw a type error?)
2552 * - Extract `CustomValueType` as a separate user-defined type (delete `CustomValueType` and animate a `Color` - does this throw a type error?).
2553 *
2554 * @param values -
2555 *
2556 * @internal
2557 */
2558 transformValues?<V extends any>(values: V): V;
2559}
2560
2561/**
2562 * @public
2563 */
2564export declare type MotionStyle = MotionCSS & MotionTransform & MakeMotion<SVGPathProperties> & MakeCustomValueType<CustomStyles>;
2565
2566/**
2567 * @public
2568 */
2569export declare type MotionTransform = MakeMotion<TransformProperties>;
2570
2571/**
2572 * `MotionValue` is used to track the state and velocity of motion values.
2573 *
2574 * @public
2575 */
2576export declare class MotionValue<V = any> {
2577 /**
2578 * The current state of the `MotionValue`.
2579 *
2580 * @internal
2581 */
2582 private current;
2583 /**
2584 * The previous state of the `MotionValue`.
2585 *
2586 * @internal
2587 */
2588 private prev;
2589 /**
2590 * Duration, in milliseconds, since last updating frame.
2591 *
2592 * @internal
2593 */
2594 private timeDelta;
2595 /**
2596 * Timestamp of the last time this `MotionValue` was updated.
2597 *
2598 * @internal
2599 */
2600 private lastUpdated;
2601 /**
2602 * Collection of children `MotionValue`s to notify of updates.
2603 *
2604 * @internal
2605 */
2606 private children?;
2607 /**
2608 * A reference to this `MotionValue`'s parent.
2609 *
2610 * @internal
2611 */
2612 private parent?;
2613 /**
2614 * Functions to notify when the `MotionValue` updates.
2615 *
2616 * @internal
2617 */
2618 updateSubscribers?: Set<Subscriber<V>>;
2619 /**
2620 * Functions to notify when the `MotionValue` updates and `render` is set to `true`.
2621 *
2622 * @internal
2623 */
2624 private renderSubscribers?;
2625 /**
2626 * Add a passive effect to this `MotionValue`.
2627 *
2628 * A passive effect intercepts calls to `set`. For instance, `useSpring` adds
2629 * a passive effect that attaches a `spring` to the latest
2630 * set value. Hypothetically there could be a `useSmooth` that attaches an input smoothing effect.
2631 *
2632 * @internal
2633 */
2634 private passiveEffect?;
2635 /**
2636 * If defined, new values passed into `set` will be transformed through this function before being set.
2637 *
2638 * @internal
2639 */
2640 private transformer?;
2641 /**
2642 * A reference to the currently-controlling Popmotion animation
2643 *
2644 * @internal
2645 */
2646 private stopAnimation?;
2647 /**
2648 * Tracks whether this value can output a velocity. Currently this is only true
2649 * if the value is numerical, but we might be able to widen the scope here and support
2650 * other value types.
2651 *
2652 * @internal
2653 */
2654 private canTrackVelocity;
2655 /**
2656 * @param init - The initiating value
2657 * @param config - Optional configuration options
2658 *
2659 * - `transformer`: A function to transform incoming values with.
2660 *
2661 * @internal
2662 */
2663 constructor(init: V, { transformer, parent }?: Config<V>);
2664 /**
2665 * Creates a new `MotionValue` that's subscribed to the output of this one.
2666 *
2667 * @param config - Optional configuration options
2668 *
2669 * - `transformer`: A function to transform incoming values with.
2670 *
2671 * @internal
2672 */
2673 addChild(config?: Config<V>): MotionValue<V>;
2674 /**
2675 * Stops a `MotionValue` from being subscribed to this one.
2676 *
2677 * @param child - The subscribed `MotionValue`
2678 *
2679 * @internal
2680 */
2681 removeChild(child: MotionValue): void;
2682 /**
2683 * Subscribes a subscriber function to a subscription list.
2684 *
2685 * @param subscriptions - A `Set` of subscribers.
2686 * @param subscription - A subscriber function.
2687 */
2688 private subscribeTo;
2689 /**
2690 * Adds a function that will be notified when the `MotionValue` is updated.
2691 *
2692 * It returns a function that, when called, will cancel the subscription.
2693 *
2694 * When calling `onChange` inside a React component, it should be wrapped with the
2695 * `useEffect` hook. As it returns an unsubscribe function, this should be returned
2696 * from the `useEffect` function to ensure you don't add duplicate subscribers..
2697 *
2698 * @library
2699 *
2700 * ```jsx
2701 * function MyComponent() {
2702 * const x = useMotionValue(0)
2703 * const y = useMotionValue(0)
2704 * const opacity = useMotionValue(1)
2705 *
2706 * useEffect(() => {
2707 * function updateOpacity() {
2708 * const maxXY = Math.max(x.get(), y.get())
2709 * const newOpacity = transform(maxXY, [0, 100], [1, 0])
2710 * opacity.set(newOpacity)
2711 * }
2712 *
2713 * const unsubscribeX = x.onChange(updateOpacity)
2714 * const unsubscribeY = y.onChange(updateOpacity)
2715 *
2716 * return () => {
2717 * unsubscribeX()
2718 * unsubscribeY()
2719 * }
2720 * }, [])
2721 *
2722 * return <Frame x={x} />
2723 * }
2724 * ```
2725 *
2726 * @motion
2727 *
2728 * ```jsx
2729 * export const MyComponent = () => {
2730 * const x = useMotionValue(0)
2731 * const y = useMotionValue(0)
2732 * const opacity = useMotionValue(1)
2733 *
2734 * useEffect(() => {
2735 * function updateOpacity() {
2736 * const maxXY = Math.max(x.get(), y.get())
2737 * const newOpacity = transform(maxXY, [0, 100], [1, 0])
2738 * opacity.set(newOpacity)
2739 * }
2740 *
2741 * const unsubscribeX = x.onChange(updateOpacity)
2742 * const unsubscribeY = y.onChange(updateOpacity)
2743 *
2744 * return () => {
2745 * unsubscribeX()
2746 * unsubscribeY()
2747 * }
2748 * }, [])
2749 *
2750 * return <motion.div style={{ x }} />
2751 * }
2752 * ```
2753 *
2754 * @internalremarks
2755 *
2756 * We could look into a `useOnChange` hook if the above lifecycle management proves confusing.
2757 *
2758 * ```jsx
2759 * useOnChange(x, () => {})
2760 * ```
2761 *
2762 * @param subscriber - A function that receives the latest value.
2763 * @returns A function that, when called, will cancel this subscription.
2764 *
2765 * @public
2766 */
2767 onChange(subscription: Subscriber<V>): () => void;
2768 /**
2769 * Adds a function that will be notified when the `MotionValue` requests a render.
2770 *
2771 * @param subscriber - A function that's provided the latest value.
2772 * @returns A function that, when called, will cancel this subscription.
2773 *
2774 * @internal
2775 */
2776 onRenderRequest(subscription: Subscriber<V>): () => boolean;
2777 /**
2778 * Attaches a passive effect to the `MotionValue`.
2779 *
2780 * @internal
2781 */
2782 attach(passiveEffect: PassiveEffect<V>): void;
2783 /**
2784 * Sets the state of the `MotionValue`.
2785 *
2786 * @remarks
2787 *
2788 * ```jsx
2789 * const x = useMotionValue(0)
2790 * x.set(10)
2791 * ```
2792 *
2793 * @param latest - Latest value to set.
2794 * @param render - Whether to notify render subscribers. Defaults to `true`
2795 *
2796 * @public
2797 */
2798 set(v: V, render?: boolean): void;
2799 updateAndNotify: (v: V, render?: boolean) => void;
2800 /**
2801 * Returns the latest state of `MotionValue`
2802 *
2803 * @returns - The latest state of `MotionValue`
2804 *
2805 * @public
2806 */
2807 get(): V;
2808 /**
2809 * Returns the latest velocity of `MotionValue`
2810 *
2811 * @returns - The latest velocity of `MotionValue`. Returns `0` if the state is non-numerical.
2812 *
2813 * @public
2814 */
2815 getVelocity(): number;
2816 /**
2817 * Notify a subscriber with the latest value.
2818 *
2819 * This is an instanced and bound function to prevent generating a new
2820 * function once per frame.
2821 *
2822 * @param subscriber - The subscriber to notify.
2823 *
2824 * @internal
2825 */
2826 private notifySubscriber;
2827 /**
2828 * Schedule a velocity check for the next frame.
2829 *
2830 * This is an instanced and bound function to prevent generating a new
2831 * function once per frame.
2832 *
2833 * @internal
2834 */
2835 private scheduleVelocityCheck;
2836 /**
2837 * Updates `prev` with `current` if the value hasn't been updated this frame.
2838 * This ensures velocity calculations return `0`.
2839 *
2840 * This is an instanced and bound function to prevent generating a new
2841 * function once per frame.
2842 *
2843 * @internal
2844 */
2845 private velocityCheck;
2846 /**
2847 * Updates child `MotionValue`.
2848 *
2849 * @param child - Child `MotionValue`.
2850 *
2851 * @internal
2852 */
2853 private setChild;
2854 /**
2855 * Registers a new animation to control this `MotionValue`. Only one
2856 * animation can drive a `MotionValue` at one time.
2857 *
2858 * ```jsx
2859 * value.start()
2860 * ```
2861 *
2862 * @param animation - A function that starts the provided animation
2863 *
2864 * @internal
2865 */
2866 start(animation: StartAnimation): Promise<void>;
2867 /**
2868 * Stop the currently active animation.
2869 *
2870 * @public
2871 */
2872 stop(): void;
2873 /**
2874 * Returns `true` if this value is currently animating.
2875 *
2876 * @public
2877 */
2878 isAnimating(): boolean;
2879 private clearAnimation;
2880 /**
2881 * Destroy and clean up subscribers to this `MotionValue`.
2882 *
2883 * The `MotionValue` hooks like `useMotionValue` and `useTransform` automatically
2884 * handle the lifecycle of the returned `MotionValue`, so this method is only necessary if you've manually
2885 * created a `MotionValue` via the `motionValue` function.
2886 *
2887 * @public
2888 */
2889 destroy(): void;
2890}
2891
2892/**
2893 * @internal
2894 */
2895export declare function motionValue<V>(init: V, opts?: Config<V>): MotionValue<V>;
2896
2897declare class MotionValuesMap {
2898 private hasMounted;
2899 private transformTemplate;
2900 private onUpdate?;
2901 private values;
2902 private unsubscribers;
2903 private output;
2904 has(key: string): boolean;
2905 set(key: string, value: MotionValue): void;
2906 get<Value>(key: string): MotionValue<Value> | undefined;
2907 get<Value>(key: string, defaultValue: Value): MotionValue<Value>;
2908 forEach(callback: (value: MotionValue, key: string) => void): void;
2909 private bindValueToOutput;
2910 setOnUpdate(onUpdate?: OnUpdate): void;
2911 setTransformTemplate(transformTemplate?: TransformTemplate | undefined): void;
2912 getTransformTemplate(): TransformTemplate | undefined;
2913 updateTransformTemplate(): void;
2914 mount(output?: Output): void;
2915 unmount(): void;
2916}
2917
2918/**
2919 * @public
2920 */
2921export declare interface None {
2922 /**
2923 * Set `type` to `false` for an instant transition.
2924 *
2925 * @public
2926 */
2927 type: false;
2928 /**
2929 * @internal
2930 */
2931 from?: number | string;
2932 /**
2933 * @internal
2934 */
2935 delay?: number;
2936 /**
2937 * @internal
2938 */
2939 velocity?: number;
2940}
2941
2942declare type NotPresent = [false, () => void];
2943
2944declare type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
2945
2946declare type OnUpdate = (v: Target) => void;
2947
2948/**
2949 * Options for orchestrating the timing of animations.
2950 *
2951 * @public
2952 */
2953export declare interface Orchestration {
2954 /**
2955 * Delay the animation by this duration (in seconds). Defaults to `0`.
2956 *
2957 * @remarks
2958 * ```javascript
2959 * const transition = {
2960 * delay: 0.2
2961 * }
2962 * ```
2963 *
2964 * @public
2965 */
2966 delay?: number;
2967 /**
2968 * Describes the relationship between the transition and its children. Set
2969 * to `false` by default.
2970 *
2971 * @remarks
2972 * When using variants, the transition can be scheduled in relation to its
2973 * children with either `"beforeChildren"` to finish this transition before
2974 * starting children transitions, `"afterChildren"` to finish children
2975 * transitions before starting this transition.
2976 *
2977 * @library
2978 *
2979 * ```jsx
2980 * const container = {
2981 * hidden: {
2982 * opacity: 0,
2983 * transition: { when: "afterChildren" }
2984 * }
2985 * }
2986 *
2987 * const item = {
2988 * hidden: {
2989 * opacity: 0,
2990 * transition: { duration: 2 }
2991 * }
2992 * }
2993 *
2994 * return (
2995 * <Frame variants={container} animate="hidden">
2996 * <Frame variants={item} size={50} />
2997 * <Frame variants={item} size={50} />
2998 * </Frame>
2999 * )
3000 * ```
3001 *
3002 * @motion
3003 *
3004 * ```jsx
3005 * const list = {
3006 * hidden: {
3007 * opacity: 0,
3008 * transition: { when: "afterChildren" }
3009 * }
3010 * }
3011 *
3012 * const item = {
3013 * hidden: {
3014 * opacity: 0,
3015 * transition: { duration: 2 }
3016 * }
3017 * }
3018 *
3019 * return (
3020 * <motion.ul variants={list} animate="hidden">
3021 * <motion.li variants={item} />
3022 * <motion.li variants={item} />
3023 * </motion.ul>
3024 * )
3025 * ```
3026 *
3027 * @public
3028 */
3029 when?: false | "beforeChildren" | "afterChildren" | string;
3030 /**
3031 * When using variants, children animations will start after this duration
3032 * (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.
3033 *
3034 * @library
3035 *
3036 * ```jsx
3037 * const container = {
3038 * hidden: { opacity: 0 },
3039 * show: {
3040 * opacity: 1,
3041 * transition: {
3042 * delayChildren: 0.5
3043 * }
3044 * }
3045 * }
3046 *
3047 * const item = {
3048 * hidden: { opacity: 0 },
3049 * show: { opacity: 1 }
3050 * }
3051 *
3052 * return (
3053 * <Frame
3054 * variants={container}
3055 * initial="hidden"
3056 * animate="show"
3057 * >
3058 * <Frame variants={item} size={50} />
3059 * <Frame variants={item} size={50} />
3060 * </Frame>
3061 * )
3062 * ```
3063 *
3064 * @motion
3065 *
3066 * ```jsx
3067 * const container = {
3068 * hidden: { opacity: 0 },
3069 * show: {
3070 * opacity: 1,
3071 * transition: {
3072 * delayChildren: 0.5
3073 * }
3074 * }
3075 * }
3076 *
3077 * const item = {
3078 * hidden: { opacity: 0 },
3079 * show: { opacity: 1 }
3080 * }
3081 *
3082 * return (
3083 * <motion.ul
3084 * variants={container}
3085 * initial="hidden"
3086 * animate="show"
3087 * >
3088 * <motion.li variants={item} />
3089 * <motion.li variants={item} />
3090 * </motion.ul>
3091 * )
3092 * ```
3093 *
3094 * @public
3095 */
3096 delayChildren?: number;
3097 /**
3098 * When using variants, animations of child components can be staggered by this
3099 * duration (in seconds).
3100 *
3101 * For instance, if `staggerChildren` is `0.01`, the first child will be
3102 * delayed by `0` seconds, the second by `0.01`, the third by `0.02` and so
3103 * on.
3104 *
3105 * The calculated stagger delay will be added to `delayChildren`.
3106 *
3107 * @library
3108 *
3109 * ```jsx
3110 * const container = {
3111 * hidden: { opacity: 0 },
3112 * show: {
3113 * opacity: 1,
3114 * transition: {
3115 * staggerChildren: 0.5
3116 * }
3117 * }
3118 * }
3119 *
3120 * const item = {
3121 * hidden: { opacity: 0 },
3122 * show: { opacity: 1 }
3123 * }
3124 *
3125 * return (
3126 * <Frame
3127 * variants={container}
3128 * initial="hidden"
3129 * animate="show"
3130 * >
3131 * <Frame variants={item} size={50} />
3132 * <Frame variants={item} size={50} />
3133 * </Frame>
3134 * )
3135 * ```
3136 *
3137 * @motion
3138 *
3139 * ```jsx
3140 * const container = {
3141 * hidden: { opacity: 0 },
3142 * show: {
3143 * opacity: 1,
3144 * transition: {
3145 * staggerChildren: 0.5
3146 * }
3147 * }
3148 * }
3149 *
3150 * const item = {
3151 * hidden: { opacity: 0 },
3152 * show: { opacity: 1 }
3153 * }
3154 *
3155 * return (
3156 * <motion.ol
3157 * variants={container}
3158 * initial="hidden"
3159 * animate="show"
3160 * >
3161 * <motion.li variants={item} />
3162 * <motion.li variants={item} />
3163 * </motion.ol>
3164 * )
3165 * ```
3166 *
3167 * @public
3168 */
3169 staggerChildren?: number;
3170 /**
3171 * The direction in which to stagger children.
3172 *
3173 * A value of `1` staggers from the first to the last while `-1`
3174 * staggers from the last to the first.
3175 *
3176 * @library
3177 *
3178 * ```jsx
3179 * const container = {
3180 * hidden: { opacity: 0 },
3181 * show: {
3182 * opacity: 1,
3183 * transition: {
3184 * delayChildren: 0.5,
3185 * staggerDirection: -1
3186 * }
3187 * }
3188 * }
3189 *
3190 * const item = {
3191 * hidden: { opacity: 0 },
3192 * show: { opacity: 1 }
3193 * }
3194 *
3195 * return (
3196 * <Frame
3197 * variants={container}
3198 * initial="hidden"
3199 * animate="show"
3200 * >
3201 * <Frame variants={item} size={50} />
3202 * <Frame variants={item} size={50} />
3203 * </Frame>
3204 * )
3205 * ```
3206 *
3207 * @motion
3208 *
3209 * ```jsx
3210 * const container = {
3211 * hidden: { opacity: 0 },
3212 * show: {
3213 * opacity: 1,
3214 * transition: {
3215 * delayChildren: 0.5,
3216 * staggerDirection: -1
3217 * }
3218 * }
3219 * }
3220 *
3221 * const item = {
3222 * hidden: { opacity: 0 },
3223 * show: { opacity: 1 }
3224 * }
3225 *
3226 * return (
3227 * <motion.ul
3228 * variants={container}
3229 * initial="hidden"
3230 * animate="show"
3231 * >
3232 * <motion.li variants={item} size={50} />
3233 * <motion.li variants={item} size={50} />
3234 * </motion.ul>
3235 * )
3236 * ```
3237 *
3238 * @public
3239 */
3240 staggerDirection?: number;
3241}
3242
3243declare type Output = (key: string, value: string | number | TransformTemplate | undefined) => void;
3244
3245/**
3246 * @public
3247 */
3248export declare interface PanHandlers {
3249 /**
3250 * Callback function that fires when the pan gesture is recognised on this element.
3251 *
3252 * @library
3253 *
3254 * ```jsx
3255 * function onPan(event, info) {
3256 * console.log(info.point.x, info.point.y)
3257 * }
3258 *
3259 * <Frame onPan={onPan} />
3260 * ```
3261 *
3262 * @motion
3263 *
3264 * ```jsx
3265 * function onPan(event, info) {
3266 * console.log(info.point.x, info.point.y)
3267 * }
3268 *
3269 * <motion.div onPan={onPan} />
3270 * ```
3271 *
3272 * @param event - The originating pointer event.
3273 * @param info - A {@link PanInfo} object containing `x` and `y` values for:
3274 *
3275 * - `point`: Relative to the device or page.
3276 * - `delta`: Distance moved since the last event.
3277 * - `offset`: Offset from the original pan event.
3278 * - `velocity`: Current velocity of the pointer.
3279 */
3280 onPan?(event: MouseEvent | TouchEvent | PointerEvent, info: PanInfo): void;
3281 /**
3282 * Callback function that fires when the pan gesture begins on this element.
3283 *
3284 * @library
3285 *
3286 * ```jsx
3287 * function onPanStart(event, info) {
3288 * console.log(info.point.x, info.point.y)
3289 * }
3290 *
3291 * <Frame onPanStart={onPanStart} />
3292 * ```
3293 *
3294 * @motion
3295 *
3296 * ```jsx
3297 * function onPanStart(event, info) {
3298 * console.log(info.point.x, info.point.y)
3299 * }
3300 *
3301 * <motion.div onPanStart={onPanStart} />
3302 * ```
3303 *
3304 * @param event - The originating pointer event.
3305 * @param info - A {@link PanInfo} object containing `x`/`y` values for:
3306 *
3307 * - `point`: Relative to the device or page.
3308 * - `delta`: Distance moved since the last event.
3309 * - `offset`: Offset from the original pan event.
3310 * - `velocity`: Current velocity of the pointer.
3311 */
3312 onPanStart?(event: MouseEvent | TouchEvent | PointerEvent, info: PanInfo): void;
3313 /**
3314 * Callback function that fires when we begin detecting a pan gesture. This
3315 * is analogous to `onMouseStart` or `onTouchStart`.
3316 *
3317 * @library
3318 *
3319 * ```jsx
3320 * function onPanSessionStart(event, info) {
3321 * console.log(info.point.x, info.point.y)
3322 * }
3323 *
3324 * <Frame onPanSessionStart={onPanSessionStart} />
3325 * ```
3326 *
3327 * @motion
3328 *
3329 * ```jsx
3330 * function onPanSessionStart(event, info) {
3331 * console.log(info.point.x, info.point.y)
3332 * }
3333 *
3334 * <motion.div onPanSessionStart={onPanSessionStart} />
3335 * ```
3336 *
3337 * @param event - The originating pointer event.
3338 * @param info - An {@link EventInfo} object containing `x`/`y` values for:
3339 *
3340 * - `point`: Relative to the device or page.
3341 */
3342 onPanSessionStart?(event: MouseEvent | TouchEvent | PointerEvent, info: EventInfo): void;
3343 /**
3344 * Callback function that fires when the pan gesture ends on this element.
3345 *
3346 * @library
3347 *
3348 * ```jsx
3349 * function onPanEnd(event, info) {
3350 * console.log(info.point.x, info.point.y)
3351 * }
3352 *
3353 * <Frame onPanEnd={onPanEnd} />
3354 * ```
3355 *
3356 * @motion
3357 *
3358 * ```jsx
3359 * function onPanEnd(event, info) {
3360 * console.log(info.point.x, info.point.y)
3361 * }
3362 *
3363 * <motion.div onPanEnd={onPanEnd} />
3364 * ```
3365 *
3366 * @param event - The originating pointer event.
3367 * @param info - A {@link PanInfo} object containing `x`/`y` values for:
3368 *
3369 * - `point`: Relative to the device or page.
3370 * - `delta`: Distance moved since the last event.
3371 * - `offset`: Offset from the original pan event.
3372 * - `velocity`: Current velocity of the pointer.
3373 */
3374 onPanEnd?(event: MouseEvent | TouchEvent | PointerEvent, info: PanInfo): void;
3375}
3376
3377/**
3378 * Passed in to pan event handlers like `onPan` the `PanInfo` object contains
3379 * information about the current state of the tap gesture such as its
3380 * `point`, `delta`, `offset` and `velocity`.
3381 *
3382 * @library
3383 *
3384 * ```jsx
3385 * function onPan(event, info) {
3386 * console.log(info.point.x, info.point.y)
3387 * }
3388 *
3389 * <Frame onPan={onPan} />
3390 * ```
3391 *
3392 * @motion
3393 *
3394 * ```jsx
3395 * <motion.div onPan={(event, info) => {
3396 * console.log(info.point.x, info.point.y)
3397 * }} />
3398 * ```
3399 *
3400 * @public
3401 */
3402export declare interface PanInfo {
3403 /**
3404 * Contains `x` and `y` values for the current pan position relative
3405 * to the device or page.
3406 *
3407 * @library
3408 *
3409 * ```jsx
3410 * function onPan(event, info) {
3411 * console.log(info.point.x, info.point.y)
3412 * }
3413 *
3414 * <Frame onPan={onPan} />
3415 * ```
3416 *
3417 * @motion
3418 *
3419 * ```jsx
3420 * function onPan(event, info) {
3421 * console.log(info.point.x, info.point.y)
3422 * }
3423 *
3424 * <motion.div onPan={onPan} />
3425 * ```
3426 *
3427 * @public
3428 */
3429 point: Point;
3430 /**
3431 * Contains `x` and `y` values for the distance moved since
3432 * the last event.
3433 *
3434 * @library
3435 *
3436 * ```jsx
3437 * function onPan(event, info) {
3438 * console.log(info.delta.x, info.delta.y)
3439 * }
3440 *
3441 * <Frame onPan={onPan} />
3442 * ```
3443 *
3444 * @motion
3445 *
3446 * ```jsx
3447 * function onPan(event, info) {
3448 * console.log(info.delta.x, info.delta.y)
3449 * }
3450 *
3451 * <motion.div onPan={onPan} />
3452 * ```
3453 *
3454 * @public
3455 */
3456 delta: Point;
3457 /**
3458 * Contains `x` and `y` values for the distance moved from
3459 * the first pan event.
3460 *
3461 * @library
3462 *
3463 * ```jsx
3464 * function onPan(event, info) {
3465 * console.log(info.offset.x, info.offset.y)
3466 * }
3467 *
3468 * <Frame onPan={onPan} />
3469 * ```
3470 *
3471 * @motion
3472 *
3473 * ```jsx
3474 * function onPan(event, info) {
3475 * console.log(info.offset.x, info.offset.y)
3476 * }
3477 *
3478 * <motion.div onPan={onPan} />
3479 * ```
3480 *
3481 * @public
3482 */
3483 offset: Point;
3484 /**
3485 * Contains `x` and `y` values for the current velocity of the pointer.
3486 *
3487 * @library
3488 *
3489 * ```jsx
3490 * function onPan(event, info) {
3491 * console.log(info.velocity.x, info.velocity.y)
3492 * }
3493 *
3494 * <Frame onPan={onPan} />
3495 * ```
3496 *
3497 * @motion
3498 *
3499 * ```jsx
3500 * function onPan(event, info) {
3501 * console.log(info.velocity.x, info.velocity.y)
3502 * }
3503 *
3504 * <motion.div onPan={onPan} />
3505 * ```
3506 *
3507 * @public
3508 */
3509 velocity: Point;
3510}
3511
3512/**
3513 * @public
3514 */
3515export declare type PassiveEffect<T> = (v: T, safeSetter: (v: T) => void) => void;
3516
3517declare type PermissiveTransitionDefinition = {
3518 [key: string]: any;
3519};
3520
3521/** @public */
3522export declare interface Point {
3523 x: number;
3524 y: number;
3525}
3526
3527/** @public */
3528export declare namespace Point {
3529 /** @beta */
3530 const subtract: (a: Point, b: Point) => Point;
3531 /** @beta */
3532 const relativeTo: (idOrElem: string | HTMLElement) => ({ x, y }: Point) => Point | undefined;
3533}
3534
3535declare type Present = [true];
3536
3537declare interface Props {
3538 children?: any;
3539 /**
3540 * Can be used to explicitly set whether we're in reduced motion mode. Set
3541 * as undefined to resume device detection.
3542 */
3543 enabled?: boolean | undefined;
3544}
3545
3546declare type ReadValueFromSource = (key: string) => number | string;
3547
3548/**
3549 * Define accessibility options for a tree. Can be used to force the tree into Reduced Motion mode,
3550 * or disable device detection.
3551 *
3552 * @internal
3553 */
3554export declare function ReducedMotion({ children, enabled }: Props): JSX.Element;
3555
3556/**
3557 * @public
3558 */
3559export declare interface RelayoutInfo {
3560 delta: {
3561 x: number;
3562 y: number;
3563 width: number;
3564 height: number;
3565 };
3566}
3567
3568declare type RenderComponent<P = {}> = (ref: RefObject<Element>, style: CSSProperties, values: MotionValuesMap, props: P, isStatic?: boolean) => ReactElement;
3569
3570/**
3571 * @public
3572 */
3573export declare type ResolvedKeyframesTarget = [null, ...number[]] | number[] | [null, ...string[]] | string[];
3574
3575/**
3576 * @public
3577 */
3578export declare type ResolvedSingleTarget = string | number;
3579
3580/**
3581 * @public
3582 */
3583export declare type ResolvedValueTarget = ResolvedSingleTarget | ResolvedKeyframesTarget;
3584
3585/**
3586 * @public
3587 */
3588export declare type ResolveLayoutTransition = (info: RelayoutInfo) => Transition | boolean;
3589
3590declare interface ScaleMotionValues {
3591 scaleX: MotionValue<number>;
3592 scaleY: MotionValue<number>;
3593}
3594
3595declare interface ScrollMotionValues {
3596 scrollX: MotionValue<number>;
3597 scrollY: MotionValue<number>;
3598 scrollXProgress: MotionValue<number>;
3599 scrollYProgress: MotionValue<number>;
3600}
3601
3602/**
3603 * @public
3604 */
3605export declare type SingleTarget = ResolvedSingleTarget | CustomValueType;
3606
3607/**
3608 * An animation that simulates spring physics for realistic motion.
3609 * This is the default animation for physical values like `x`, `y`, `scale` and `rotate`.
3610 *
3611 * @public
3612 */
3613export declare interface Spring {
3614 /**
3615 * Set `type` to `"spring"` to animate using spring physics for natural
3616 * movement. Type is set to `"spring"` by default.
3617 *
3618 * @library
3619 *
3620 * ```jsx
3621 * const transition = {
3622 * type: "spring"
3623 * }
3624 *
3625 * <Frame
3626 * animate={{ rotate: 180 }}
3627 * transition={transition}
3628 * />
3629 * ```
3630 *
3631 * @motion
3632 *
3633 * ```jsx
3634 * <motion.div
3635 * animate={{ rotate: 180 }}
3636 * transition={{ type: 'spring' }}
3637 * />
3638 * ```
3639 *
3640 * @public
3641 */
3642 type: "spring";
3643 /**
3644 * Stiffness of the spring. Higher values will create more sudden movement.
3645 * Set to `100` by default.
3646 *
3647 * @library
3648 *
3649 * ```jsx
3650 * const transition = {
3651 * type: "spring",
3652 * stiffness: 50
3653 * }
3654 *
3655 * <Frame
3656 * animate={{ rotate: 180 }}
3657 * transition={transition}
3658 * />
3659 * ```
3660 *
3661 * @motion
3662 *
3663 * ```jsx
3664 * <motion.section
3665 * animate={{ rotate: 180 }}
3666 * transition={{ type: 'spring', stiffness: 50 }}
3667 * />
3668 * ```
3669 *
3670 * @public
3671 */
3672 stiffness?: number;
3673 /**
3674 * Strength of opposing force. If set to 0, spring will oscillate
3675 * indefinitely. Set to `10` by default.
3676 *
3677 * @library
3678 *
3679 * ```jsx
3680 * const transition = {
3681 * type: "spring",
3682 * damping: 300
3683 * }
3684 *
3685 * <Frame
3686 * animate={{ rotate: 180 }}
3687 * transition={transition}
3688 * />
3689 * ```
3690 *
3691 * @motion
3692 *
3693 * ```jsx
3694 * <motion.a
3695 * animate={{ rotate: 180 }}
3696 * transition={{ type: 'spring', damping: 300 }}
3697 * />
3698 * ```
3699 *
3700 * @public
3701 */
3702 damping?: number;
3703 /**
3704 * Mass of the moving object. Higher values will result in more lethargic
3705 * movement. Set to `1` by default.
3706 *
3707 * @library
3708 *
3709 * ```jsx
3710 * const transition = {
3711 * type: "spring",
3712 * mass: 0.5
3713 * }
3714 *
3715 * <Frame
3716 * animate={{ rotate: 180 }}
3717 * transition={transition}
3718 * />
3719 * ```
3720 *
3721 * @motion
3722 *
3723 * ```jsx
3724 * <motion.feTurbulence
3725 * animate={{ baseFrequency: 0.5 } as any}
3726 * transition={{ type: "spring", mass: 0.5 }}
3727 * />
3728 * ```
3729 *
3730 * @public
3731 */
3732 mass?: number;
3733 /**
3734 * End animation if absolute speed (in units per second) drops below this
3735 * value and delta is smaller than `restDelta`. Set to `0.01` by default.
3736 *
3737 * @library
3738 *
3739 * ```jsx
3740 * const transition = {
3741 * type: "spring",
3742 * restSpeed: 0.5
3743 * }
3744 *
3745 * <Frame
3746 * animate={{ rotate: 180 }}
3747 * transition={transition}
3748 * />
3749 * ```
3750 *
3751 * @motion
3752 *
3753 * ```jsx
3754 * <motion.div
3755 * animate={{ rotate: 180 }}
3756 * transition={{ type: 'spring', restSpeed: 0.5 }}
3757 * />
3758 * ```
3759 *
3760 * @public
3761 */
3762 restSpeed?: number;
3763 /**
3764 * End animation if distance is below this value and speed is below
3765 * `restSpeed`. When animation ends, spring gets “snapped” to. Set to
3766 * `0.01` by default.
3767 *
3768 * @library
3769 *
3770 * ```jsx
3771 * const transition = {
3772 * type: "spring",
3773 * restDelta: 0.5
3774 * }
3775 *
3776 * <Frame
3777 * animate={{ rotate: 180 }}
3778 * transition={transition}
3779 * />
3780 * ```
3781 *
3782 * @motion
3783 *
3784 * ```jsx
3785 * <motion.div
3786 * animate={{ rotate: 180 }}
3787 * transition={{ type: 'spring', restDelta: 0.5 }}
3788 * />
3789 * ```
3790 *
3791 * @public
3792 */
3793 restDelta?: number;
3794 /**
3795 * The value to animate from.
3796 * By default, this is the initial state of the animating value.
3797 *
3798 * @library
3799 *
3800 * ```jsx
3801 * const transition = {
3802 * type: "spring",
3803 * from: 90
3804 * }
3805 *
3806 * <Frame
3807 * animate={{ rotate: 180 }}
3808 * transition={transition}
3809 * />
3810 * ```
3811 *
3812 * @motion
3813 *
3814 * ```jsx
3815 * <motion.div
3816 * animate={{ rotate: 180 }}
3817 * transition={{ type: 'spring', from: 90 }}
3818 * />
3819 * ```
3820 *
3821 * @public
3822 */
3823 from?: number | string;
3824 /**
3825 * @internal
3826 */
3827 to?: number | string | ValueTarget;
3828 /**
3829 * The initial velocity of the spring. By default this is the current velocity of the component.
3830 *
3831 * @library
3832 *
3833 * ```jsx
3834 * const transition = {
3835 * type: "spring",
3836 * velocity: 2
3837 * }
3838 *
3839 * <Frame
3840 * animate={{ rotate: 180 }}
3841 * transition={transition}
3842 * />
3843 * ```
3844 *
3845 * @motion
3846 *
3847 * ```jsx
3848 * <motion.div
3849 * animate={{ rotate: 180 }}
3850 * transition={{ type: 'spring', velocity: 2 }}
3851 * />
3852 * ```
3853 *
3854 * @public
3855 */
3856 velocity?: number;
3857 /**
3858 * @internal
3859 */
3860 delay?: number;
3861}
3862
3863declare type StartAnimation = (complete: () => void) => () => void;
3864
3865/**
3866 * @public
3867 */
3868export declare type Subscriber<T> = (v: T) => void;
3869
3870/**
3871 * Blanket-accept any SVG attribute as a `MotionValue`
3872 * @public
3873 */
3874export declare type SVGAttributesAsMotionValues<T> = MakeMotion<SVGAttributesWithoutMotionProps<T>>;
3875
3876declare interface SVGAttributesWithoutMotionProps<T> extends Pick<SVGAttributes<T>, Exclude<keyof SVGAttributes<T>, keyof MotionProps>> {
3877}
3878
3879/**
3880 * @public
3881 */
3882export declare interface SVGMotionProps<T> extends SVGAttributesAsMotionValues<T>, Omit<MotionProps, "positionTransition"> {
3883}
3884
3885/**
3886 * @public
3887 */
3888declare interface SVGPathProperties {
3889 pathLength?: number;
3890 pathOffset?: number;
3891 pathSpacing?: number;
3892}
3893
3894declare interface SyncLayoutProps {
3895 children: React.ReactNode;
3896}
3897
3898/**
3899 * @public
3900 */
3901export declare interface TapHandlers {
3902 /**
3903 * Callback when the tap gesture successfully ends on this element.
3904 *
3905 * @library
3906 *
3907 * ```jsx
3908 * function onTap(event, info) {
3909 * console.log(info.point.x, info.point.y)
3910 * }
3911 *
3912 * <Frame onTap={onTap} />
3913 * ```
3914 *
3915 * @motion
3916 *
3917 * ```jsx
3918 * function onTap(event, info) {
3919 * console.log(info.point.x, info.point.y)
3920 * }
3921 *
3922 * <motion.div onTap={onTap} />
3923 * ```
3924 *
3925 * @param event - The originating pointer event.
3926 * @param info - An {@link TapInfo} object containing `x` and `y` values for the `point` relative to the device or page.
3927 */
3928 onTap?(event: MouseEvent | TouchEvent | PointerEvent, info: TapInfo): void;
3929 /**
3930 * Callback when the tap gesture starts on this element.
3931 *
3932 * @library
3933 *
3934 * ```jsx
3935 * function onTapStart(event, info) {
3936 * console.log(info.point.x, info.point.y)
3937 * }
3938 *
3939 * <Frame onTapStart={onTapStart} />
3940 * ```
3941 *
3942 * @motion
3943 *
3944 * ```jsx
3945 * function onTapStart(event, info) {
3946 * console.log(info.point.x, info.point.y)
3947 * }
3948 *
3949 * <motion.div onTapStart={onTapStart} />
3950 * ```
3951 *
3952 * @param event - The originating pointer event.
3953 * @param info - An {@link TapInfo} object containing `x` and `y` values for the `point` relative to the device or page.
3954 */
3955 onTapStart?(event: MouseEvent | TouchEvent | PointerEvent, info: TapInfo): void;
3956 /**
3957 * Callback when the tap gesture ends outside this element.
3958 *
3959 * @library
3960 *
3961 * ```jsx
3962 * function onTapCancel(event, info) {
3963 * console.log(info.point.x, info.point.y)
3964 * }
3965 *
3966 * <Frame onTapCancel={onTapCancel} />
3967 * ```
3968 *
3969 * @motion
3970 *
3971 * ```jsx
3972 * function onTapCancel(event, info) {
3973 * console.log(info.point.x, info.point.y)
3974 * }
3975 *
3976 * <motion.div onTapCancel={onTapCancel} />
3977 * ```
3978 *
3979 * @param event - The originating pointer event.
3980 * @param info - An {@link TapInfo} object containing `x` and `y` values for the `point` relative to the device or page.
3981 */
3982 onTapCancel?(event: MouseEvent | TouchEvent | PointerEvent, info: TapInfo): void;
3983 /**
3984 * Properties or variant label to animate to while the component is pressed.
3985 *
3986 * @library
3987 *
3988 * ```jsx
3989 * <Frame whileTap={{ scale: 0.8 }} />
3990 * ```
3991 *
3992 * @motion
3993 *
3994 * ```jsx
3995 * <motion.div whileTap={{ scale: 0.8 }} />
3996 * ```
3997 */
3998 whileTap?: string | TargetAndTransition;
3999}
4000
4001/**
4002 * Passed in to tap event handlers like `onTap` the `TapInfo` object contains
4003 * information about the tap gesture such as it‘s location.
4004 *
4005 * @library
4006 *
4007 * ```jsx
4008 * function onTap(event, info) {
4009 * console.log(info.point.x, info.point.y)
4010 * }
4011 *
4012 * <Frame onTap={onTap} />
4013 * ```
4014 *
4015 * @motion
4016 *
4017 * ```jsx
4018 * function onTap(event, info) {
4019 * console.log(info.point.x, info.point.y)
4020 * }
4021 *
4022 * <motion.div onTap={onTap} />
4023 * ```
4024 *
4025 * @public
4026 */
4027export declare interface TapInfo {
4028 /**
4029 * Contains `x` and `y` values for the tap gesture relative to the
4030 * device or page.
4031 *
4032 * @library
4033 *
4034 * ```jsx
4035 * function onTapStart(event, info) {
4036 * console.log(info.point.x, info.point.y)
4037 * }
4038 *
4039 * <Frame onTapStart={onTapStart} />
4040 * ```
4041 *
4042 * @motion
4043 *
4044 * ```jsx
4045 * function onTapStart(event, info) {
4046 * console.log(info.point.x, info.point.y)
4047 * }
4048 *
4049 * <motion.div onTapStart={onTapStart} />
4050 * ```
4051 *
4052 * @public
4053 */
4054 point: Point;
4055}
4056
4057declare type Target = MakeCustomValueType<TargetProperties>;
4058
4059/**
4060 * An object that specifies values to animate to. Each value may be set either as
4061 * a single value, or an array of values.
4062 *
4063 * It may also option contain these properties:
4064 *
4065 * - `transition`: Specifies transitions for all or individual values.
4066 * - `transitionEnd`: Specifies values to set when the animation finishes.
4067 *
4068 * ```jsx
4069 * const target = {
4070 * x: "0%",
4071 * opacity: 0,
4072 * transition: { duration: 1 },
4073 * transitionEnd: { display: "none" }
4074 * }
4075 * ```
4076 *
4077 * @public
4078 */
4079export declare type TargetAndTransition = TargetWithKeyframes & {
4080 transition?: Transition;
4081 transitionEnd?: Target;
4082};
4083
4084declare type TargetProperties = CSSPropertiesWithoutTransitionOrSingleTransforms & SVGAttributes<SVGElement> & TransformProperties & CustomStyles;
4085
4086declare type TargetResolver = (custom: any, current: Target, velocity: Target) => TargetAndTransition;
4087
4088declare type TargetWithKeyframes = MakeKeyframes<Target>;
4089
4090/**
4091 * Transforms numbers into other values by mapping them from an input range to an output range.
4092 * Returns the type of the input provided.
4093 *
4094 * @remarks
4095 *
4096 * Given an input range of `[0, 200]` and an output range of
4097 * `[0, 1]`, this function will return a value between `0` and `1`.
4098 * The input range must be a linear series of numbers. The output range
4099 * can be any supported value type, such as numbers, colors, shadows, arrays, objects and more.
4100 * Every value in the output range must be of the same type and in the same format.
4101 *
4102 * @library
4103 *
4104 * ```jsx
4105 * import * as React from "react"
4106 * import { Frame, transform } from "framer"
4107 *
4108 * export function MyComponent() {
4109 * const inputRange = [0, 200]
4110 * const outputRange = [0, 1]
4111 * const output = transform(100, inputRange, outputRange)
4112 *
4113 * // Returns 0.5
4114 * return <Frame>{output}</Frame>
4115 * }
4116 * ```
4117 *
4118 * @motion
4119 *
4120 * ```jsx
4121 * import * as React from "react"
4122 * import { transform } from "framer-motion"
4123 *
4124 * export function MyComponent() {
4125 * const inputRange = [0, 200]
4126 * const outputRange = [0, 1]
4127 * const output = transform(100, inputRange, outputRange)
4128 *
4129 * // Returns 0.5
4130 * return <div>{output}</div>
4131 * }
4132 * ```
4133 *
4134 * @param inputValue - A number to transform between the input and output ranges.
4135 * @param inputRange - A linear series of numbers (either all increasing or decreasing).
4136 * @param outputRange - A series of numbers, colors, strings, or arrays/objects of those. Must be the same length as `inputRange`.
4137 * @param options - Clamp: Clamp values to within the given range. Defaults to `true`.
4138 *
4139 * @public
4140 */
4141export declare function transform<T>(inputValue: number, inputRange: number[], outputRange: T[], options?: TransformOptions<T>): T;
4142
4143/**
4144 * @library
4145 *
4146 * For improved performance, `transform` can pre-calculate the function that will transform a value between two ranges.
4147 * Returns a function.
4148 *
4149 * ```jsx
4150 * import * as React from "react"
4151 * import { Frame, transform } from "framer"
4152 *
4153 * export function MyComponent() {
4154 * const inputRange = [-200, -100, 100, 200]
4155 * const outputRange = [0, 1, 1, 0]
4156 * const convertRange = transform(inputRange, outputRange)
4157 * const output = convertRange(-150)
4158 *
4159 * // Returns 0.5
4160 * return <Frame>{output}</Frame>
4161 * }
4162 *
4163 * ```
4164 *
4165 * @motion
4166 *
4167 * Transforms numbers into other values by mapping them from an input range to an output range.
4168 *
4169 * Given an input range of `[0, 200]` and an output range of
4170 * `[0, 1]`, this function will return a value between `0` and `1`.
4171 * The input range must be a linear series of numbers. The output range
4172 * can be any supported value type, such as numbers, colors, shadows, arrays, objects and more.
4173 * Every value in the output range must be of the same type and in the same format.
4174 *
4175 * ```jsx
4176 * import * as React from "react"
4177 * import { Frame, transform } from "framer"
4178 *
4179 * export function MyComponent() {
4180 * const inputRange = [-200, -100, 100, 200]
4181 * const outputRange = [0, 1, 1, 0]
4182 * const convertRange = transform(inputRange, outputRange)
4183 * const output = convertRange(-150)
4184 *
4185 * // Returns 0.5
4186 * return <div>{output}</div>
4187 * }
4188 *
4189 * ```
4190 *
4191 * @param inputRange - A linear series of numbers (either all increasing or decreasing).
4192 * @param outputRange - A series of numbers, colors or strings. Must be the same length as `inputRange`.
4193 * @param options - Clamp: clamp values to within the given range. Defaults to `true`.
4194 *
4195 * @public
4196 */
4197export declare function transform<T>(inputRange: number[], outputRange: T[], options?: TransformOptions<T>): (inputValue: number) => T;
4198
4199declare type Transformer<T> = (v: T) => T;
4200
4201declare type Transformer_2<T> = (v: any) => T;
4202
4203/**
4204 * @public
4205 */
4206declare interface TransformOptions<T> {
4207 /**
4208 * Clamp values to within the given range. Defaults to `true`
4209 *
4210 * @public
4211 */
4212 clamp?: boolean;
4213 /**
4214 * Easing functions to use on the interpolations between each value in the input and output ranges.
4215 *
4216 * If provided as an array, the array must be one item shorter than the input and output ranges, as the easings apply to the transition **between** each.
4217 *
4218 * @public
4219 */
4220 ease?: Easing_2 | Easing_2[];
4221 /**
4222 * @internal
4223 */
4224 mixer?: (from: T, to: T) => (v: number) => any;
4225}
4226
4227declare interface TransformProperties {
4228 x?: string | number;
4229 y?: string | number;
4230 z?: string | number;
4231 translateX?: string | number;
4232 translateY?: string | number;
4233 translateZ?: string | number;
4234 rotate?: string | number;
4235 rotateX?: string | number;
4236 rotateY?: string | number;
4237 rotateZ?: string | number;
4238 scale?: string | number;
4239 scaleX?: string | number;
4240 scaleY?: string | number;
4241 scaleZ?: string | number;
4242 skew?: string | number;
4243 skewX?: string | number;
4244 skewY?: string | number;
4245 originX?: string | number;
4246 originY?: string | number;
4247 originZ?: string | number;
4248 perspective?: string | number;
4249}
4250
4251declare type TransformTemplate = (transform: TransformProperties, generatedTransform: string) => string;
4252
4253/**
4254 * Transition props
4255 *
4256 * @public
4257 */
4258export declare type Transition = (Orchestration & TransitionDefinition) | (Orchestration & TransitionMap);
4259
4260/**
4261 * @public
4262 */
4263declare type TransitionDefinition = Tween | Spring | Keyframes | Inertia | Just | None | PermissiveTransitionDefinition;
4264
4265declare type TransitionMap = Orchestration & {
4266 [key: string]: TransitionDefinition;
4267};
4268
4269/**
4270 * An animation that animates between two or more values over a specific duration of time.
4271 * This is the default animation for non-physical values like `color` and `opacity`.
4272 *
4273 * @public
4274 */
4275export declare interface Tween {
4276 /**
4277 * Set `type` to `"tween"` to use a duration-based tween animation.
4278 * If any non-orchestration `transition` values are set without a `type` property,
4279 * this is used as the default animation.
4280 *
4281 * @library
4282 *
4283 * ```jsx
4284 * <Frame
4285 * animate={{ opacity: 0 }}
4286 * transition={{ duration: 2, type: "tween" }}
4287 * />
4288 * ```
4289 *
4290 * @motion
4291 *
4292 * ```jsx
4293 * <motion.path
4294 * animate={{ pathLength: 1 }}
4295 * transition={{ duration: 2, type: "tween" }}
4296 * />
4297 * ```
4298 *
4299 * @public
4300 */
4301 type?: "tween";
4302 /**
4303 * The duration of the tween animation. Set to `0.3` by default, 0r `0.8` if animating a series of keyframes.
4304 *
4305 * @library
4306 *
4307 * ```jsx
4308 * <Frame
4309 * animate={{ opacity: 0 }}
4310 * transition={{ duration: 2 }}
4311 * />
4312 * ```
4313 *
4314 * @motion
4315 *
4316 * ```jsx
4317 * const variants = {
4318 * visible: {
4319 * opacity: 1,
4320 * transition: { duration: 2 }
4321 * }
4322 * }
4323 * ```
4324 *
4325 * @public
4326 */
4327 duration?: number;
4328 /**
4329 * The easing function to use. Set as one of the below.
4330 *
4331 * - The name of an existing easing function.
4332 * - An array of four numbers to define a cubic bezier curve.
4333 * - An easing function, that accepts and returns a value `0-1`.
4334 *
4335 * If the animating value is set as an array of multiple values for a keyframes
4336 * animation, `ease` can be set as an array of easing functions to set different easings between
4337 * each of those values.
4338 *
4339 * @library
4340 *
4341 * ```jsx
4342 * const transition = {
4343 * ease: [0.17, 0.67, 0.83, 0.67]
4344 * }
4345 *
4346 * <Frame
4347 * animate={{ opacity: 0 }}
4348 * transition={transition}
4349 * />
4350 * ```
4351 *
4352 * @motion
4353 *
4354 * ```jsx
4355 * <motion.div
4356 * animate={{ opacity: 0 }}
4357 * transition={{ ease: [0.17, 0.67, 0.83, 0.67] }}
4358 * />
4359 * ```
4360 *
4361 * @public
4362 */
4363 ease?: Easing | Easing[];
4364 /**
4365 * The duration of time already elapsed in the animation. Set to `0` by
4366 * default.
4367 *
4368 * @internal
4369 */
4370 elapsed?: number;
4371 /**
4372 * When animating keyframes, `times` can be used to determine where in the animation each keyframe is reached.
4373 * Each value in `times` is a value between `0` and `1`, representing `duration`.
4374 *
4375 * There must be the same number of `times` as there are keyframes.
4376 * Defaults to an array of evenly-spread durations.
4377 *
4378 * @library
4379 *
4380 * ```jsx
4381 * const transition = {
4382 * times: [0, 0.1, 0.9, 1]
4383 * }
4384 *
4385 * <Frame
4386 * animate={{ scale: [0, 1, 0.5, 1] }}
4387 * transition={transition}
4388 * />
4389 * ```
4390 *
4391 * @motion
4392 *
4393 * ```jsx
4394 * <motion.div
4395 * animate={{ scale: [0, 1, 0.5, 1] }}
4396 * transition={{ times: [0, 0.1, 0.9, 1] }}
4397 * />
4398 * ```
4399 *
4400 * @public
4401 */
4402 times?: number[];
4403 /**
4404 * 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.
4405 *
4406 * @library
4407 *
4408 * ```jsx
4409 * const transition = {
4410 * easings: ["easeIn", "easeOut"]
4411 * }
4412 *
4413 * <Frame
4414 * animate={{ backgroundColor: ["#0f0", "#00f", "#f00"] }}
4415 * transition={transition}
4416 * />
4417 * ```
4418 *
4419 * @motion
4420 *
4421 * ```jsx
4422 * <motion.div
4423 * animate={{ backgroundColor: ["#0f0", "#00f", "#f00"] }}
4424 * transition={{ easings: ["easeIn", "easeOut"] }}
4425 * />
4426 * ```
4427 *
4428 * @public
4429 */
4430 easings?: Easing[];
4431 /**
4432 * The number of times to loop the animation.
4433 * Set to `Infinity` for perpetual looping.
4434 *
4435 * @library
4436 *
4437 * ```jsx
4438 * const transition = {
4439 * loop: Infinity,
4440 * ease: "linear",
4441 * duration: 2
4442 * }
4443 *
4444 * <Frame
4445 * animate={{ rotate: 360 }}
4446 * transition={transition}
4447 * />
4448 * ```
4449 *
4450 * @motion
4451 *
4452 * ```jsx
4453 * <motion.div
4454 * animate={{ rotate: 360 }}
4455 * transition={{
4456 * loop: Infinity,
4457 * ease: "linear",
4458 * duration: 2
4459 * }}
4460 * />
4461 * ```
4462 *
4463 * @public
4464 */
4465 loop?: number;
4466 /**
4467 * The number of times to flip the animation by swapping the `to` and `from` values.
4468 * Set to `Infinity` for perpetual flipping.
4469 *
4470 * @library
4471 *
4472 * ```jsx
4473 * const transition = {
4474 * flip: Infinity,
4475 * duration: 2
4476 * }
4477 *
4478 * <Frame
4479 * animate={{ opacity: 0 }}
4480 * transition={transition}
4481 * />
4482 * ```
4483 *
4484 * @motion
4485 *
4486 * ```jsx
4487 * <motion.div
4488 * animate={{ opacity: 0 }}
4489 * transition={{ flip: Infinity, duration: 2 }}
4490 * />
4491 * ```
4492 *
4493 * @public
4494 */
4495 flip?: number;
4496 /**
4497 * The number of times to reverse the animation.
4498 * Set to `Infinity` for perpetual reversing.
4499 *
4500 * @library
4501 *
4502 * ```jsx
4503 * const transition = {
4504 * yoyo: Infinity,
4505 * duration: 2
4506 * }
4507 *
4508 * <Frame
4509 * animate={{ rotate: 180 }}
4510 * transition={transition}
4511 * />
4512 * ```
4513 *
4514 * @motion
4515 *
4516 * ```jsx
4517 * <motion.div
4518 * animate={{ rotate: 180 }}
4519 * transition={{ yoyo: Infinity, duration: 2 }}
4520 * />
4521 * ```
4522 *
4523 * @public
4524 */
4525 yoyo?: number;
4526 /**
4527 * When repeating an animation using `loop`, `flip`, or `yoyo`, `repeatDelay` can set the
4528 * duration of the time to wait, in seconds, between each repetition.
4529 *
4530 * @library
4531 *
4532 * ```jsx
4533 * const transition = {
4534 * yoyo: Infinity,
4535 * repeatDelay: 1
4536 * }
4537 *
4538 * <Frame
4539 * animate={{ rotate: 180 }}
4540 * transition={transition}
4541 * />
4542 * ```
4543 *
4544 * @motion
4545 *
4546 * ```jsx
4547 * <motion.div
4548 * animate={{ rotate: 180 }}
4549 * transition={{ yoyo: Infinity, repeatDelay: 1 }}
4550 * />
4551 * ```
4552 *
4553 *
4554 * @public
4555 */
4556 repeatDelay?: number;
4557 /**
4558 * The value to animate from.
4559 * By default, this is the current state of the animating value.
4560 *
4561 * @library
4562 *
4563 * ```jsx
4564 * const transition = {
4565 * from: 90,
4566 * duration: 2
4567 * }
4568 *
4569 * <Frame
4570 * animate={{ rotate: 180 }}
4571 * transition={transition}
4572 * />
4573 * ```
4574 *
4575 * @motion
4576 *
4577 * ```jsx
4578 * <motion.div
4579 * animate={{ rotate: 180 }}
4580 * transition={{ from: 90, duration: 2 }}
4581 * />
4582 * ```
4583 *
4584 * @public
4585 */
4586 from?: number | string;
4587 /**
4588 * @internal
4589 */
4590 to?: number | string | ValueTarget;
4591 /**
4592 * @internal
4593 */
4594 velocity?: number;
4595 /**
4596 * @internal
4597 */
4598 delay?: number;
4599}
4600
4601/**
4602 * When layout changes happen asynchronously to their instigating render (ie when exiting
4603 * children of `AnimatePresence` are removed), `SyncLayout` can wrap parent and sibling
4604 * components that need to animate as a result of this layout change.
4605 *
4606 * @motion
4607 *
4608 * ```jsx
4609 * const MyComponent = ({ isVisible }) => {
4610 * return (
4611 * <SyncLayout>
4612 * <AnimatePresence>
4613 * {isVisible && (
4614 * <motion.div exit={{ opacity: 0 }} />
4615 * )}
4616 * </AnimatePresence>
4617 * <motion.div positionTransition />
4618 * </SyncLayout>
4619 * )
4620 * }
4621 * ```
4622 *
4623 * @internalremarks
4624 *
4625 * The way this component works is by memoising a function and passing it down via context.
4626 * The function, when called, updates the local state, which is used to invalidate the
4627 * memoisation cache. A new function is called, performing a synced re-render of components
4628 * that are using the SyncLayoutContext.
4629 *
4630 * @internal
4631 */
4632export declare const UnstableSyncLayout: ({ children }: SyncLayoutProps) => JSX.Element;
4633
4634declare type UnwrapFactoryAttributes<F> = F extends DetailedHTMLFactory<infer P, any> ? P : never;
4635
4636declare type UnwrapFactoryElement<F> = F extends DetailedHTMLFactory<any, infer P> ? P : never;
4637
4638/**
4639 * If the provided value is a MotionValue, this returns the actual value, otherwise just the value itself
4640 *
4641 * TODO: Remove and move to library
4642 *
4643 * @internal
4644 */
4645export declare function unwrapMotionValue(value?: string | number | CustomValueType | MotionValue): string | number;
4646
4647/**
4648 * Experimental API.
4649 *
4650 * Makes an animated version of `useState`.
4651 *
4652 * @remarks
4653 *
4654 * When the returned state setter is called, values will be animated to their new target.
4655 *
4656 * This allows the animation of arbitrary React components.
4657 *
4658 * **Note:** When animating DOM components, it's always preferable to use the `animate` prop, as Framer
4659 * will bypass React's rendering cycle with one optimised for 60fps motion. This Hook is specifically
4660 * for animating props on arbitrary React components, or for animating text content.
4661 *
4662 * ```jsx
4663 * const [state, setState] = useAnimatedState({ percentage: 0 })
4664 *
4665 * return (
4666 * <Graph
4667 * percentage={state.percentage}
4668 * onTap={() => setState({ percentage: 50 })}
4669 * />
4670 * )
4671 * ```
4672 *
4673 * @internalremarks
4674 *
4675 * TODO:
4676 * - Make hook accept a typed version of Target that accepts any value (not just DOM values)
4677 * - Allow hook to accept single values. ie useAnimatedState(0)
4678 * - Allow providing MotionValues via initialState.
4679 *
4680 * @beta
4681 */
4682export declare function useAnimatedState(initialState: any): any[];
4683
4684/**
4685 * Creates `AnimationControls`, which can be used to manually start, stop
4686 * and sequence animations on one or more components.
4687 *
4688 * The returned `AnimationControls` should be passed to the `animate` property
4689 * of the components you want to animate.
4690 *
4691 * These components can then be animated with the `start` method.
4692 *
4693 * @library
4694 *
4695 * ```jsx
4696 * import * as React from 'react'
4697 * import { Frame, useAnimation } from 'framer'
4698 *
4699 * export function MyComponent(props) {
4700 * const controls = useAnimation()
4701 *
4702 * controls.start({
4703 * x: 100,
4704 * transition: { duration: 0.5 },
4705 * })
4706 *
4707 * return <Frame animate={controls} />
4708 * }
4709 * ```
4710 *
4711 * @motion
4712 *
4713 * ```jsx
4714 * import * as React from 'react'
4715 * import { motion, useAnimation } from 'framer-motion'
4716 *
4717 * export function MyComponent(props) {
4718 * const controls = useAnimation()
4719 *
4720 * controls.start({
4721 * x: 100,
4722 * transition: { duration: 0.5 },
4723 * })
4724 *
4725 * return <motion.div animate={controls} />
4726 * }
4727 * ```
4728 *
4729 * @returns Animation controller with `start` and `stop` methods
4730 *
4731 * @public
4732 */
4733export declare function useAnimation(): AnimationControls;
4734
4735/**
4736 * Cycles through a series of visual properties. Can be used to toggle between or cycle through animations. It works similar to `useState` in React. It is provided an initial array of possible states, and returns an array of two arguments.
4737 *
4738 * @library
4739 *
4740 * ```jsx
4741 * import * as React from "react"
4742 * import { Frame, useCycle } from "framer"
4743 *
4744 * export function MyComponent() {
4745 * const [x, cycleX] = useCycle(0, 50, 100)
4746 *
4747 * return (
4748 * <Frame
4749 * animate={{ x: x }}
4750 * onTap={() => cycleX()}
4751 * />
4752 * )
4753 * }
4754 * ```
4755 *
4756 * @motion
4757 *
4758 * An index value can be passed to the returned `cycle` function to cycle to a specific index.
4759 *
4760 * ```jsx
4761 * import * as React from "react"
4762 * import { motion, useCycle } from "framer-motion"
4763 *
4764 * export const MyComponent = () => {
4765 * const [x, cycleX] = useCycle(0, 50, 100)
4766 *
4767 * return (
4768 * <motion.div
4769 * animate={{ x: x }}
4770 * onTap={() => cycleX()}
4771 * />
4772 * )
4773 * }
4774 * ```
4775 *
4776 * @param items - items to cycle through
4777 * @returns [currentState, cycleState]
4778 *
4779 * @public
4780 */
4781export declare function useCycle<T>(...items: T[]): CycleState<T>;
4782
4783/**
4784 * Attaches an event listener directly to the provided DOM element.
4785 *
4786 * Bypassing React's event system can be desirable, for instance when attaching non-passive
4787 * event handlers.
4788 *
4789 * ```jsx
4790 * const ref = useRef(null)
4791 *
4792 * useDomEvent(ref, 'wheel', onWheel, { passive: false })
4793 *
4794 * return <div ref={ref} />
4795 * ```
4796 *
4797 * @param ref - React.RefObject that's been provided to the element you want to bind the listener to.
4798 * @param eventName - Name of the event you want listen for.
4799 * @param handler - Function to fire when receiving the event.
4800 * @param options - Options to pass to `Event.addEventListener`.
4801 *
4802 * @public
4803 */
4804export declare function useDomEvent(ref: RefObject<Element>, eventName: string, handler?: EventListener | undefined, options?: AddEventListenerOptions): void;
4805
4806/**
4807 * Usually, dragging is initiated by pressing down on a `motion` component with a `drag` prop
4808 * and moving it. For some use-cases, for instance clicking at an arbitrary point on a video scrubber, we
4809 * might want to initiate that dragging from a different component than the draggable one.
4810 *
4811 * By creating a `dragControls` using the `useDragControls` hook, we can pass this into
4812 * the draggable component's `dragControls` prop. It exposes a `start` method
4813 * that can start dragging from pointer events on other components.
4814 *
4815 * @library
4816 *
4817 * ```jsx
4818 * const dragControls = useDragControls()
4819 *
4820 * function startDrag(event) {
4821 * dragControls.start(event, { snapToCursor: true })
4822 * }
4823 *
4824 * return (
4825 * <>
4826 * <Frame onTapStart={startDrag} />
4827 * <Frame drag="x" dragControls={dragControls} />
4828 * </>
4829 * )
4830 * ```
4831 *
4832 * @motion
4833 *
4834 * ```jsx
4835 * const dragControls = useDragControls()
4836 *
4837 * function startDrag(event) {
4838 * dragControls.start(event, { snapToCursor: true })
4839 * }
4840 *
4841 * return (
4842 * <>
4843 * <div onMouseDown={startDrag} />
4844 * <motion.div drag="x" dragControls={dragControls} />
4845 * </>
4846 * )
4847 * ```
4848 *
4849 * @public
4850 */
4851export declare function useDragControls(): DragControls;
4852
4853/**
4854 * Uses the ref that is passed in, or creates a new one
4855 * @param external - External ref
4856 * @internal
4857 */
4858export declare function useExternalRef<E = Element>(externalRef?: Ref<E>): RefObject<E>;
4859
4860/**
4861 * Add pan and tap gesture recognition to an element.
4862 *
4863 * @param props - Gesture event handlers
4864 * @param ref - React `ref` containing a DOM `Element`
4865 * @public
4866 */
4867export declare function useGestures<GestureHandlers>(props: GestureHandlers, ref: RefObject<Element>): void;
4868
4869/**
4870 * Returns a `MotionValue` each for `scaleX` and `scaleY` that update with the inverse
4871 * of their respective parent scales.
4872 *
4873 * This is useful for undoing the distortion of content when scaling a parent component.
4874 *
4875 * By default, `useInvertedScale` will automatically fetch `scaleX` and `scaleY` from the nearest parent.
4876 * By passing other `MotionValue`s in as `useInvertedScale({ scaleX, scaleY })`, it will invert the output
4877 * of those instead.
4878 *
4879 * @motion
4880 *
4881 * ```jsx
4882 * const MyComponent = () => {
4883 * const { scaleX, scaleY } = useInvertedScale()
4884 * return <motion.div style={{ scaleX, scaleY }} />
4885 * }
4886 * ```
4887 *
4888 * @library
4889 *
4890 * ```jsx
4891 * function MyComponent() {
4892 * const { scaleX, scaleY } = useInvertedScale()
4893 * return <Frame scaleX={scaleX} scaleY={scaleY} />
4894 * }
4895 * ```
4896 *
4897 * @public
4898 */
4899export declare function useInvertedScale(scale?: Partial<ScaleMotionValues>): ScaleMotionValues;
4900
4901/**
4902 * Creates a `MotionValue` to track the state and velocity of a value.
4903 *
4904 * Usually, these are created automatically. For advanced use-cases, like use with `useTransform`, you can create `MotionValue`s externally and pass them into the animated component via the `style` prop.
4905 *
4906 * @library
4907 *
4908 * ```jsx
4909 * export function MyComponent() {
4910 * const scale = useMotionValue(1)
4911 *
4912 * return <Frame scale={scale} />
4913 * }
4914 * ```
4915 *
4916 * @motion
4917 *
4918 * ```jsx
4919 * export const MyComponent = () => {
4920 * const scale = useMotionValue(1)
4921 *
4922 * return <motion.div style={{ scale }} />
4923 * }
4924 * ```
4925 *
4926 * @param initial - The initial state.
4927 *
4928 * @public
4929 */
4930export declare function useMotionValue<T>(initial: T): MotionValue<T>;
4931
4932/**
4933 *
4934 * @param handlers -
4935 * @param ref -
4936 *
4937 * @internalremarks
4938 * Currently this sets new pan gesture functions every render. The memo route has been explored
4939 * in the past but ultimately we're still creating new functions every render. An optimisation
4940 * to explore is creating the pan gestures and loading them into a `ref`.
4941 *
4942 * @internal
4943 */
4944export declare function usePanGesture({ onPan, onPanStart, onPanEnd, onPanSessionStart }: PanHandlers, ref: RefObject<Element>): void;
4945
4946/**
4947 * When a component is the child of an `AnimatePresence` component, it has access to
4948 * information about whether it's still present the React tree. `usePresence` can be
4949 * used to access that data and perform operations before the component can be considered
4950 * safe to remove.
4951 *
4952 * It returns two values. `isPresent` is a boolean that is `true` when the component
4953 * is present within the React tree. It is `false` when it's been removed, but still visible.
4954 *
4955 * When `isPresent` is `false`, the `safeToRemove` callback can be used to tell `AnimatePresence`
4956 * that it's safe to remove the component from the DOM, for instance after a animation has completed.
4957 *
4958 * ```jsx
4959 * const [isPresent, safeToRemove] = usePresence()
4960 *
4961 * useEffect(() => {
4962 * !isPresent setTimeout(safeToRemove, 1000)
4963 * }, [isPresent])
4964 * ```
4965 *
4966 * @public
4967 */
4968export declare function usePresence(): Present | NotPresent;
4969
4970/**
4971 * A hook that returns `true` if we should be using reduced motion based on the current device's Reduced Motion setting.
4972 *
4973 * This can be used to implement changes to your UI based on Reduced Motion. For instance, replacing motion-sickness inducing
4974 * `x`/`y` animations with `opacity`, disabling the autoplay of background videos, or turning off parallax motion.
4975 *
4976 * It will actively respond to changes and re-render your components with the latest setting.
4977 *
4978 * ```jsx
4979 * export function Sidebar({ isOpem }) {
4980 * const shouldReduceMotion = useReducedMotion()
4981 * const closedX = shouldReduceMotion ? 0 : "-100%"
4982 *
4983 * return (
4984 * <motion.div animate={{
4985 * opacity: isOpen ? 1 : 0,
4986 * x: isOpen ? 0 : closedX
4987 * }} />
4988 * )
4989 * }
4990 * ```
4991 *
4992 * @return boolean
4993 *
4994 * @public
4995 */
4996export declare function useReducedMotion(): boolean;
4997
4998/**
4999 * Creates a `MotionValue` that, when `set`, will use a spring animation to animate to its new state.
5000 *
5001 * It can either work as a stand-alone `MotionValue` by initialising it with a value, or as a subscriber
5002 * to another `MotionValue`.
5003 *
5004 * @remarks
5005 *
5006 * ```jsx
5007 * const x = useSpring(0, { stiffness: 300 })
5008 * const y = useSpring(x, { damping: 10 })
5009 * ```
5010 *
5011 * @param inputValue - `MotionValue` or number. If provided a `MotionValue`, when the input `MotionValue` changes, the created `MotionValue` will spring towards that value.
5012 * @param springConfig - Configuration options for the spring.
5013 * @returns `MotionValue`
5014 *
5015 * @public
5016 */
5017export declare function useSpring(source: MotionValue | number, config?: SpringProps): MotionValue<any>;
5018
5019/**
5020 * @param handlers -
5021 * @internal
5022 */
5023export declare function useTapGesture({ onTap, onTapStart, onTapCancel, whileTap, controls, }: TapHandlers & ControlsProp, ref: RefObject<Element>): void;
5024
5025/**
5026 * Create a `MotionValue` that transforms the output of another `MotionValue` through a function.
5027 * In this example, `y` will always be double `x`.
5028 *
5029 * @library
5030 *
5031 * ```jsx
5032 * import * as React from "react"
5033 * import { Frame, useMotionValue, useTransform } from "framer"
5034 *
5035 * export function MyComponent() {
5036 * const x = useMotionValue(10)
5037 * const y = useTransform(x, value => value * 2)
5038 *
5039 * return <Frame x={x} y={y} />
5040 * }
5041 * ```
5042 *
5043 * @motion
5044 *
5045 * ```jsx
5046 * export const MyComponent = () => {
5047 * const x = useMotionValue(10)
5048 * const y = useTransform(x, value => value * 2)
5049 *
5050 * return <motion.div style={{ x, y }} />
5051 * }
5052 * ```
5053 *
5054 * @param value - The `MotionValue` to transform the output of.
5055 * @param transform - Function that accepts the output of `value` and returns a new value.
5056 * @returns `MotionValue`
5057 *
5058 * @public
5059 */
5060export declare function useTransform<T>(parent: MotionValue, transform: Transformer_2<T>): MotionValue;
5061
5062/**
5063 * Create a `MotionValue` that transforms the output of another `MotionValue` by mapping it from one range of values into another.
5064 *
5065 * @remarks
5066 *
5067 * Given an input range of `[-200, -100, 100, 200]` and an output range of
5068 * `[0, 1, 1, 0]`, the returned `MotionValue` will:
5069 *
5070 * - When provided a value between `-200` and `-100`, will return a value between `0` and `1`.
5071 * - When provided a value between `-100` and `100`, will return `1`.
5072 * - When provided a value between `100` and `200`, will return a value between `1` and `0`
5073 *
5074 *
5075 * The input range must be a linear series of numbers. The output range
5076 * can be any value type supported by Framer Motion: numbers, colors, shadows, etc.
5077 *
5078 * Every value in the output range must be of the same type and in the same format.
5079 *
5080 * @library
5081 *
5082 * ```jsx
5083 * export function MyComponent() {
5084 * const x = useMotionValue(0)
5085 * const xRange = [-200, -100, 100, 200]
5086 * const opacityRange = [0, 1, 1, 0]
5087 * const opacity = useTransform(x, xRange, opacityRange)
5088 *
5089 * return <Frame drag="x" x={x} opacity={opacity} />
5090 * }
5091 * ```
5092 *
5093 * @motion
5094 *
5095 * ```jsx
5096 * export const MyComponent = () => {
5097 * const x = useMotionValue(0)
5098 * const xRange = [-200, -100, 100, 200]
5099 * const opacityRange = [0, 1, 1, 0]
5100 * const opacity = useTransform(x, xRange, opacityRange)
5101 *
5102 * return <motion.div drag="x" style={{ opacity, x }} />
5103 * }
5104 * ```
5105 *
5106 * @param inputValue - `MotionValue`
5107 * @param inputRange - A linear series of numbers (either all increasing or decreasing)
5108 * @param outputRange - A series of numbers, colors or strings. Must be the same length as `inputRange`.
5109 * @param options -
5110 *
5111 * - clamp: boolean - Clamp values to within the given range. Defaults to `true`
5112 * - ease: EasingFunction[] - Easing functions to use on the interpolations between each value in the input and output ranges. If provided as an array, the array must be one item shorter than the input and output ranges, as the easings apply to the transition **between** each.
5113 *
5114 * @returns `MotionValue`
5115 *
5116 * @public
5117 */
5118export declare function useTransform<T>(parent: MotionValue<number>, from: number[], to: T[], options?: TransformOptions<T>): MotionValue<T>;
5119
5120/**
5121 * Provides `MotionValue`s that update when the viewport scrolls:
5122 *
5123 * - `scrollX` — Horizontal scroll distance in pixels.
5124 * - `scrollY` — Vertical scroll distance in pixels.
5125 * - `scrollXProgress` — Horizontal scroll progress between `0` and `1`.
5126 * - `scrollYProgress` — Vertical scroll progress between `0` and `1`.
5127 *
5128 * **Note:** If the returned scroll `MotionValue`s don't seem to be updating,
5129 * double check if the `body` tag styles are set to `width: 100%; height: 100%` or
5130 * similar, as this can break accurate measurement of viewport scroll.
5131 *
5132 * @library
5133 *
5134 * ```jsx
5135 * import * as React from "react"
5136 * import {
5137 * Frame,
5138 * useViewportScroll,
5139 * useTransform
5140 * } from "framer"
5141 *
5142 * export function MyComponent() {
5143 * const { scrollYProgress } = useViewportScroll()
5144 * return <Frame scaleX={scrollYProgress} />
5145 * }
5146 * ```
5147 *
5148 * @motion
5149 *
5150 * ```jsx
5151 * export const MyComponent = () => {
5152 * const { scrollYProgress } = useViewportScroll()
5153 * return <motion.div style={{ scaleX: scrollYProgress }} />
5154 * }
5155 * ```
5156 *
5157 * @internalremarks
5158 * This isn't technically a hook yet, but in the future it might be nice
5159 * to accept refs to elements and add scroll listeners to those, which
5160 * may involve the use of lifecycle.
5161 *
5162 * @public
5163 */
5164export declare function useViewportScroll(): ScrollMotionValues;
5165
5166declare interface ValueAnimationConfig {
5167 values: MotionValuesMap;
5168 readValueFromSource: ReadValueFromSource;
5169 makeTargetAnimatable?: MakeTargetAnimatable;
5170}
5171
5172/**
5173 * Control animations for a single component
5174 *
5175 * @internal
5176 */
5177declare class ValueAnimationControls<P extends {} = {}, V extends {} = {}> {
5178 /**
5179 * A reference to the component's latest props. We could probably ditch this in
5180 * favour to a reference to the `custom` prop now we don't send all props through
5181 * to target resolvers.
5182 */
5183 private props;
5184 /**
5185 * A reference to the component's motion values
5186 */
5187 private values;
5188 /**
5189 * The default transition to use for `Target`s without any `transition` prop.
5190 */
5191 private defaultTransition?;
5192 /**
5193 * The component's variants, as provided by `variants`
5194 */
5195 private variants;
5196 /**
5197 * A set of values that we animate back to when a value is cleared of all overrides.
5198 */
5199 private baseTarget;
5200 /**
5201 * A series of target overrides that we can animate to/from when overrides are set/cleared.
5202 */
5203 private overrides;
5204 /**
5205 * A series of target overrides as they were originally resolved.
5206 */
5207 private resolvedOverrides;
5208 /**
5209 * A Set of currently active override indexes
5210 */
5211 private activeOverrides;
5212 /**
5213 * A Set of children component controls for variant propagation.
5214 */
5215 private children?;
5216 /**
5217 * A Set of value keys that are currently animating.
5218 */
5219 private isAnimating;
5220 /**
5221 * In the event we attempt to animate a value that doesn't exist yet, we use this
5222 * function to attempt to read it from the source (ie the DOM, or React state etc)
5223 */
5224 private readValueFromSource;
5225 /**
5226 * A chance
5227 */
5228 private makeTargetAnimatable;
5229 constructor({ values, readValueFromSource, makeTargetAnimatable, }: ValueAnimationConfig);
5230 /**
5231 * Set the reference to the component's props.
5232 * @param props -
5233 */
5234 setProps(props: P & MotionProps): void;
5235 /**
5236 * Set the reference to the component's variants
5237 * @param variants -
5238 */
5239 setVariants(variants?: Variants): void;
5240 /**
5241 * Set the component's default transition
5242 * @param transition -
5243 */
5244 setDefaultTransition(transition?: Transition): void;
5245 /**
5246 * Set motion values without animation.
5247 *
5248 * @param definition -
5249 * @param isActive -
5250 */
5251 private setValues;
5252 /**
5253 * Allows `transformValues` to be set by a component that allows us to
5254 * transform the values in a given `Target`. This allows Framer Library
5255 * to extend Framer Motion to animate `Color` variables etc. Currently we have
5256 * to manually support these extended types here in Framer Motion.
5257 *
5258 * @param values -
5259 */
5260 private transformValues;
5261 /**
5262 * Check a `Target` for new values we haven't animated yet, and add them
5263 * to the `MotionValueMap`.
5264 *
5265 * Currently there's functionality here that is DOM-specific, we should allow
5266 * this functionality to be injected by the factory that creates DOM-specific
5267 * components.
5268 *
5269 * @param target -
5270 */
5271 private checkForNewValues;
5272 /**
5273 * Check if the associated `MotionValueMap` has a key with the provided string.
5274 * Pre-bound to the class so we can provide directly to the `filter` in `checkForNewValues`.
5275 */
5276 private hasValue;
5277 /**
5278 * Resolve a variant from its label or resolver into an actual `Target` we can animate to.
5279 * @param variant -
5280 */
5281 private resolveVariant;
5282 /**
5283 * Get the highest active override priority index
5284 */
5285 private getHighestPriority;
5286 /**
5287 * Set an override. We add this layer of indirection so if, for instance, a tap gesture
5288 * starts and overrides a hover gesture, when we clear the tap gesture and fallback to the
5289 * hover gesture, if that hover gesture has changed in the meantime we can go to that rather
5290 * than the one that was resolved when the hover gesture animation started.
5291 *
5292 * @param definition -
5293 * @param overrideIndex -
5294 */
5295 setOverride(definition: AnimationDefinition, overrideIndex: number): void;
5296 /**
5297 * Start an override animation.
5298 * @param overrideIndex -
5299 */
5300 startOverride(overrideIndex: number): Promise<void> | undefined;
5301 /**
5302 * Clear an override. We check every value we animated to in this override to see if
5303 * its present on any lower-priority overrides. If not, we animate it back to its base target.
5304 * @param overrideIndex -
5305 */
5306 clearOverride(overrideIndex: number): void;
5307 /**
5308 * Apply a target/variant without any animation
5309 */
5310 apply(definition: AnimationDefinition): void;
5311 /**
5312 * Apply variant labels without animation
5313 */
5314 private applyVariantLabels;
5315 start(definition: AnimationDefinition, opts?: AnimationOptions): Promise<void>;
5316 private animate;
5317 private animateVariantLabels;
5318 private animateVariant;
5319 private animateChildren;
5320 private onStart;
5321 private onComplete;
5322 private checkOverrideIsAnimating;
5323 private resetIsAnimating;
5324 stop(): void;
5325 /**
5326 * Add the controls of a child component.
5327 * @param controls -
5328 */
5329 addChild(controls: ValueAnimationControls): void;
5330 removeChild(controls: ValueAnimationControls): void;
5331 resetChildren(): void;
5332}
5333
5334/**
5335 * @public
5336 */
5337export declare type ValueTarget = SingleTarget | KeyframesTarget;
5338
5339/**
5340 * @public
5341 */
5342export declare type Variant = TargetAndTransition | TargetResolver;
5343
5344/**
5345 * Either a string, or array of strings, that reference variants defined via the `variants` prop.
5346 * @public
5347 */
5348export declare type VariantLabels = string | string[];
5349
5350/**
5351 * @public
5352 */
5353export declare type Variants = {
5354 [key: string]: Variant;
5355};
5356
5357export { }
5358
\No newline at end of file