framer-motion 7.7.3 → 7.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/cjs/index.js +1966 -1860
  2. package/dist/es/animation/animate.mjs +2 -2
  3. package/dist/es/animation/create-accelerated-animation.mjs +8 -0
  4. package/dist/es/animation/create-instant-animation.mjs +12 -0
  5. package/dist/es/animation/{animation-controls.mjs → hooks/animation-controls.mjs} +2 -2
  6. package/dist/es/animation/{use-animated-state.mjs → hooks/use-animated-state.mjs} +6 -6
  7. package/dist/es/animation/{use-animation.mjs → hooks/use-animation.mjs} +1 -1
  8. package/dist/es/animation/index.mjs +121 -0
  9. package/dist/es/animation/legacy-popmotion/decay.mjs +11 -4
  10. package/dist/es/animation/legacy-popmotion/index.mjs +23 -15
  11. package/dist/es/animation/legacy-popmotion/inertia.mjs +14 -8
  12. package/dist/es/animation/legacy-popmotion/keyframes.mjs +21 -13
  13. package/dist/es/animation/legacy-popmotion/spring.mjs +33 -39
  14. package/dist/es/animation/optimized-appear/data-id.mjs +6 -0
  15. package/dist/es/animation/optimized-appear/handoff.mjs +34 -0
  16. package/dist/es/animation/optimized-appear/start.mjs +15 -0
  17. package/dist/es/animation/optimized-appear/store-id.mjs +3 -0
  18. package/dist/es/animation/utils/default-transitions.mjs +9 -14
  19. package/dist/es/animation/utils/keyframes.mjs +41 -0
  20. package/dist/es/animation/utils/transitions.mjs +1 -171
  21. package/dist/es/animation/waapi/easing.mjs +3 -0
  22. package/dist/es/animation/waapi/index.mjs +16 -0
  23. package/dist/es/animation/waapi/supports.mjs +17 -0
  24. package/dist/es/gestures/drag/VisualElementDragControls.mjs +2 -2
  25. package/dist/es/index.mjs +6 -3
  26. package/dist/es/render/utils/animation.mjs +15 -3
  27. package/dist/es/render/utils/motion-values.mjs +1 -1
  28. package/dist/es/utils/delay.mjs +3 -0
  29. package/dist/es/value/index.mjs +2 -2
  30. package/dist/es/value/use-spring.mjs +1 -2
  31. package/dist/framer-motion.dev.js +1971 -1865
  32. package/dist/framer-motion.js +1 -1
  33. package/dist/index.d.ts +424 -341
  34. package/dist/projection.dev.js +1655 -1623
  35. package/dist/size-rollup-dom-animation-assets.js +1 -1
  36. package/dist/size-rollup-dom-animation.js +1 -1
  37. package/dist/size-rollup-dom-max-assets.js +1 -1
  38. package/dist/size-rollup-dom-max.js +1 -1
  39. package/dist/size-rollup-motion.js +1 -1
  40. package/dist/size-webpack-dom-animation.js +1 -1
  41. package/dist/size-webpack-dom-max.js +1 -1
  42. package/dist/three-entry.d.ts +289 -282
  43. package/package.json +11 -9
package/dist/index.d.ts CHANGED
@@ -3,141 +3,10 @@ import * as React$1 from 'react';
3
3
  import { SVGAttributes, CSSProperties, RefObject, ForwardRefExoticComponent, PropsWithoutRef, RefAttributes, ReactHTML, DetailedHTMLFactory, HTMLAttributes, useEffect } from 'react';
4
4
  import { ScrollOptions, InViewOptions } from '@motionone/dom';
5
5
 
6
- /**
7
- * @public
8
- */
9
- declare type Subscriber<T> = (v: T) => void;
10
- /**
11
- * @public
12
- */
13
- declare type PassiveEffect<T> = (v: T, safeSetter: (v: T) => void) => void;
14
- /**
15
- * `MotionValue` is used to track the state and velocity of motion values.
16
- *
17
- * @public
18
- */
19
- declare class MotionValue<V = any> {
20
- /**
21
- * This will be replaced by the build step with the latest version number.
22
- * When MotionValues are provided to motion components, warn if versions are mixed.
23
- */
24
- version: string;
25
- /**
26
- * Adds a function that will be notified when the `MotionValue` is updated.
27
- *
28
- * It returns a function that, when called, will cancel the subscription.
29
- *
30
- * When calling `onChange` inside a React component, it should be wrapped with the
31
- * `useEffect` hook. As it returns an unsubscribe function, this should be returned
32
- * from the `useEffect` function to ensure you don't add duplicate subscribers..
33
- *
34
- * ```jsx
35
- * export const MyComponent = () => {
36
- * const x = useMotionValue(0)
37
- * const y = useMotionValue(0)
38
- * const opacity = useMotionValue(1)
39
- *
40
- * useEffect(() => {
41
- * function updateOpacity() {
42
- * const maxXY = Math.max(x.get(), y.get())
43
- * const newOpacity = transform(maxXY, [0, 100], [1, 0])
44
- * opacity.set(newOpacity)
45
- * }
46
- *
47
- * const unsubscribeX = x.onChange(updateOpacity)
48
- * const unsubscribeY = y.onChange(updateOpacity)
49
- *
50
- * return () => {
51
- * unsubscribeX()
52
- * unsubscribeY()
53
- * }
54
- * }, [])
55
- *
56
- * return <motion.div style={{ x }} />
57
- * }
58
- * ```
59
- *
60
- * @privateRemarks
61
- *
62
- * We could look into a `useOnChange` hook if the above lifecycle management proves confusing.
63
- *
64
- * ```jsx
65
- * useOnChange(x, () => {})
66
- * ```
67
- *
68
- * @param subscriber - A function that receives the latest value.
69
- * @returns A function that, when called, will cancel this subscription.
70
- *
71
- * @public
72
- */
73
- onChange(subscription: Subscriber<V>): () => void;
74
- clearListeners(): void;
75
- /**
76
- * Sets the state of the `MotionValue`.
77
- *
78
- * @remarks
79
- *
80
- * ```jsx
81
- * const x = useMotionValue(0)
82
- * x.set(10)
83
- * ```
84
- *
85
- * @param latest - Latest value to set.
86
- * @param render - Whether to notify render subscribers. Defaults to `true`
87
- *
88
- * @public
89
- */
90
- set(v: V, render?: boolean): void;
91
- updateAndNotify: (v: V, render?: boolean) => void;
92
- /**
93
- * Returns the latest state of `MotionValue`
94
- *
95
- * @returns - The latest state of `MotionValue`
96
- *
97
- * @public
98
- */
99
- get(): V;
100
- /**
101
- * @public
102
- */
103
- getPrevious(): V;
104
- /**
105
- * Returns the latest velocity of `MotionValue`
106
- *
107
- * @returns - The latest velocity of `MotionValue`. Returns `0` if the state is non-numerical.
108
- *
109
- * @public
110
- */
111
- getVelocity(): number;
112
- hasAnimated: boolean;
113
- /**
114
- * Stop the currently active animation.
115
- *
116
- * @public
117
- */
118
- stop(): void;
119
- /**
120
- * Returns `true` if this value is currently animating.
121
- *
122
- * @public
123
- */
124
- isAnimating(): boolean;
125
- private clearAnimation;
126
- /**
127
- * Destroy and clean up subscribers to this `MotionValue`.
128
- *
129
- * The `MotionValue` hooks like `useMotionValue` and `useTransform` automatically
130
- * handle the lifecycle of the returned `MotionValue`, so this method is only necessary if you've manually
131
- * created a `MotionValue` via the `motionValue` function.
132
- *
133
- * @public
134
- */
135
- destroy(): void;
136
- }
137
- declare function motionValue<V>(init: V): MotionValue<V>;
138
-
139
6
  declare type EasingFunction = (v: number) => number;
140
7
  declare type EasingModifier = (easing: EasingFunction) => EasingFunction;
8
+ declare type BezierDefinition = [number, number, number, number];
9
+ declare type EasingDefinition = BezierDefinition | "linear" | "easeIn" | "easeOut" | "easeInOut" | "circIn" | "circOut" | "circInOut" | "backIn" | "backOut" | "backInOut" | "anticipate";
141
10
  /**
142
11
  * The easing function to use. Set as one of:
143
12
  *
@@ -147,7 +16,7 @@ declare type EasingModifier = (easing: EasingFunction) => EasingFunction;
147
16
  *
148
17
  * @public
149
18
  */
150
- declare type Easing = [number, number, number, number] | "linear" | "easeIn" | "easeOut" | "easeInOut" | "circIn" | "circOut" | "circInOut" | "backIn" | "backOut" | "backInOut" | "anticipate" | EasingFunction;
19
+ declare type Easing = EasingDefinition | EasingFunction;
151
20
 
152
21
  /**
153
22
  * @public
@@ -1009,67 +878,11 @@ interface CustomValueType {
1009
878
  toValue: () => number | string;
1010
879
  }
1011
880
 
1012
- /**
1013
- * @public
1014
- */
1015
- declare type ControlsAnimationDefinition = string | string[] | TargetAndTransition | TargetResolver;
1016
- /**
1017
- * @public
1018
- */
1019
- interface AnimationControls {
1020
- /**
1021
- * Starts an animation on all linked components.
1022
- *
1023
- * @remarks
1024
- *
1025
- * ```jsx
1026
- * controls.start("variantLabel")
1027
- * controls.start({
1028
- * x: 0,
1029
- * transition: { duration: 1 }
1030
- * })
1031
- * ```
1032
- *
1033
- * @param definition - Properties or variant label to animate to
1034
- * @param transition - Optional `transtion` to apply to a variant
1035
- * @returns - A `Promise` that resolves when all animations have completed.
1036
- *
1037
- * @public
1038
- */
1039
- start(definition: ControlsAnimationDefinition, transitionOverride?: Transition): Promise<any>;
1040
- /**
1041
- * Instantly set to a set of properties or a variant.
1042
- *
1043
- * ```jsx
1044
- * // With properties
1045
- * controls.set({ opacity: 0 })
1046
- *
1047
- * // With variants
1048
- * controls.set("hidden")
1049
- * ```
1050
- *
1051
- * @privateRemarks
1052
- * We could perform a similar trick to `.start` where this can be called before mount
1053
- * and we maintain a list of of pending actions that get applied on mount. But the
1054
- * expectation of `set` is that it happens synchronously and this would be difficult
1055
- * to do before any children have even attached themselves. It's also poor practise
1056
- * and we should discourage render-synchronous `.start` calls rather than lean into this.
1057
- *
1058
- * @public
1059
- */
1060
- set(definition: ControlsAnimationDefinition): void;
1061
- /**
1062
- * Stops animations on all linked components.
1063
- *
1064
- * ```jsx
1065
- * controls.stop()
1066
- * ```
1067
- *
1068
- * @public
1069
- */
1070
- stop(): void;
1071
- mount(): () => void;
1072
- }
881
+ declare type FrameData = {
882
+ delta: number;
883
+ timestamp: number;
884
+ };
885
+ declare type Process = (data: FrameData) => void;
1073
886
 
1074
887
  interface Point {
1075
888
  x: number;
@@ -1101,87 +914,6 @@ interface Delta {
1101
914
  }
1102
915
  declare type TransformPoint = (point: Point) => Point;
1103
916
 
1104
- /**
1105
- * Passed in to pan event handlers like `onPan` the `PanInfo` object contains
1106
- * information about the current state of the tap gesture such as its
1107
- * `point`, `delta`, `offset` and `velocity`.
1108
- *
1109
- * ```jsx
1110
- * <motion.div onPan={(event, info) => {
1111
- * console.log(info.point.x, info.point.y)
1112
- * }} />
1113
- * ```
1114
- *
1115
- * @public
1116
- */
1117
- interface PanInfo {
1118
- /**
1119
- * Contains `x` and `y` values for the current pan position relative
1120
- * to the device or page.
1121
- *
1122
- * ```jsx
1123
- * function onPan(event, info) {
1124
- * console.log(info.point.x, info.point.y)
1125
- * }
1126
- *
1127
- * <motion.div onPan={onPan} />
1128
- * ```
1129
- *
1130
- * @public
1131
- */
1132
- point: Point;
1133
- /**
1134
- * Contains `x` and `y` values for the distance moved since
1135
- * the last event.
1136
- *
1137
- * ```jsx
1138
- * function onPan(event, info) {
1139
- * console.log(info.delta.x, info.delta.y)
1140
- * }
1141
- *
1142
- * <motion.div onPan={onPan} />
1143
- * ```
1144
- *
1145
- * @public
1146
- */
1147
- delta: Point;
1148
- /**
1149
- * Contains `x` and `y` values for the distance moved from
1150
- * the first pan event.
1151
- *
1152
- * ```jsx
1153
- * function onPan(event, info) {
1154
- * console.log(info.offset.x, info.offset.y)
1155
- * }
1156
- *
1157
- * <motion.div onPan={onPan} />
1158
- * ```
1159
- *
1160
- * @public
1161
- */
1162
- offset: Point;
1163
- /**
1164
- * Contains `x` and `y` values for the current velocity of the pointer, in px/ms.
1165
- *
1166
- * ```jsx
1167
- * function onPan(event, info) {
1168
- * console.log(info.velocity.x, info.velocity.y)
1169
- * }
1170
- *
1171
- * <motion.div onPan={onPan} />
1172
- * ```
1173
- *
1174
- * @public
1175
- */
1176
- velocity: Point;
1177
- }
1178
-
1179
- declare type FrameData = {
1180
- delta: number;
1181
- timestamp: number;
1182
- };
1183
- declare type Process = (data: FrameData) => void;
1184
-
1185
917
  declare type ReducedMotionConfig = "always" | "never" | "user";
1186
918
  /**
1187
919
  * @public
@@ -1278,7 +1010,7 @@ interface AnimationPlaybackLifecycles<V> {
1278
1010
  /**
1279
1011
  * @public
1280
1012
  */
1281
- declare type AnimationOptions$1<V> = (Tween | Spring) & AnimationPlaybackLifecycles<V> & {
1013
+ declare type AnimationOptions$2<V> = (Tween | Spring) & AnimationPlaybackLifecycles<V> & {
1282
1014
  delay?: number;
1283
1015
  type?: "tween" | "spring";
1284
1016
  };
@@ -1309,7 +1041,7 @@ declare type AnimationOptions$1<V> = (Tween | Spring) & AnimationPlaybackLifecyc
1309
1041
  *
1310
1042
  * @public
1311
1043
  */
1312
- declare function animate<V>(from: MotionValue<V> | V, to: V | V[], transition?: AnimationOptions$1<V>): AnimationPlaybackControls;
1044
+ declare function animate<V>(from: MotionValue<V> | V, to: V | V[], transition?: AnimationOptions$2<V>): AnimationPlaybackControls;
1313
1045
 
1314
1046
  interface WithDepth {
1315
1047
  depth: number;
@@ -1540,17 +1272,17 @@ declare enum AnimationType {
1540
1272
  }
1541
1273
 
1542
1274
  declare type AnimationDefinition = VariantLabels | TargetAndTransition | TargetResolver;
1543
- declare type AnimationOptions = {
1275
+ declare type AnimationOptions$1 = {
1544
1276
  delay?: number;
1545
1277
  transitionOverride?: Transition;
1546
1278
  custom?: any;
1547
1279
  type?: AnimationType;
1548
1280
  };
1549
- declare function animateVisualElement(visualElement: VisualElement, definition: AnimationDefinition, options?: AnimationOptions): Promise<void>;
1281
+ declare function animateVisualElement(visualElement: VisualElement, definition: AnimationDefinition, options?: AnimationOptions$1): Promise<void>;
1550
1282
 
1551
1283
  interface AnimationState {
1552
- animateChanges: (options?: AnimationOptions, type?: AnimationType) => Promise<any>;
1553
- setActive: (type: AnimationType, isActive: boolean, options?: AnimationOptions) => Promise<any>;
1284
+ animateChanges: (options?: AnimationOptions$1, type?: AnimationType) => Promise<any>;
1285
+ setActive: (type: AnimationType, isActive: boolean, options?: AnimationOptions$1) => Promise<any>;
1554
1286
  setAnimateFunction: (fn: any) => void;
1555
1287
  getState: () => {
1556
1288
  [key: string]: AnimationTypeState;
@@ -1775,73 +1507,418 @@ declare abstract class VisualElement<Instance = unknown, RenderState = unknown,
1775
1507
  * Only measures axis-aligned boxes, rotate and skew must be manually
1776
1508
  * removed with a re-render to work.
1777
1509
  */
1778
- measureViewportBox(): Box;
1779
- getStaticValue(key: string): string | number;
1780
- setStaticValue(key: string, value: string | number): void;
1510
+ measureViewportBox(): Box;
1511
+ getStaticValue(key: string): string | number;
1512
+ setStaticValue(key: string, value: string | number): void;
1513
+ /**
1514
+ * Make a target animatable by Popmotion. For instance, if we're
1515
+ * trying to animate width from 100px to 100vw we need to measure 100vw
1516
+ * in pixels to determine what we really need to animate to. This is also
1517
+ * pluggable to support Framer's custom value types like Color,
1518
+ * and CSS variables.
1519
+ */
1520
+ makeTargetAnimatable(target: TargetAndTransition, canMutate?: boolean): TargetAndTransition;
1521
+ /**
1522
+ * Update the provided props. Ensure any newly-added motion values are
1523
+ * added to our map, old ones removed, and listeners updated.
1524
+ */
1525
+ setProps(props: MotionProps): void;
1526
+ getProps(): MotionProps;
1527
+ /**
1528
+ * Returns the variant definition with a given name.
1529
+ */
1530
+ getVariant(name: string): Variant | undefined;
1531
+ /**
1532
+ * Returns the defined default transition on this component.
1533
+ */
1534
+ getDefaultTransition(): Transition | undefined;
1535
+ getTransformPagePoint(): any;
1536
+ getClosestVariantNode(): VisualElement | undefined;
1537
+ getVariantContext(startAtParent?: boolean): undefined | VariantStateContext;
1538
+ /**
1539
+ * Add a child visual element to our set of children.
1540
+ */
1541
+ addVariantChild(child: VisualElement): (() => boolean) | undefined;
1542
+ /**
1543
+ * Add a motion value and bind it to this visual element.
1544
+ */
1545
+ addValue(key: string, value: MotionValue): void;
1546
+ /**
1547
+ * Remove a motion value and unbind any active subscriptions.
1548
+ */
1549
+ removeValue(key: string): void;
1550
+ /**
1551
+ * Check whether we have a motion value for this key
1552
+ */
1553
+ hasValue(key: string): boolean;
1554
+ /**
1555
+ * Get a motion value for this key. If called with a default
1556
+ * value, we'll create one if none exists.
1557
+ */
1558
+ getValue(key: string, defaultValue?: string | number): MotionValue<any>;
1559
+ /**
1560
+ * If we're trying to animate to a previously unencountered value,
1561
+ * we need to check for it in our state and as a last resort read it
1562
+ * directly from the instance (which might have performance implications).
1563
+ */
1564
+ readValue(key: string): string | number | null | undefined;
1565
+ /**
1566
+ * Set the base target to later animate back to. This is currently
1567
+ * only hydrated on creation and when we first read a value.
1568
+ */
1569
+ setBaseTarget(key: string, value: string | number): void;
1570
+ /**
1571
+ * Find the base target for a value thats been removed from all animation
1572
+ * props.
1573
+ */
1574
+ getBaseTarget(key: string): any;
1575
+ on<EventName extends keyof VisualElementEventCallbacks>(eventName: EventName, callback: VisualElementEventCallbacks[EventName]): VoidFunction;
1576
+ notify<EventName extends keyof VisualElementEventCallbacks>(eventName: EventName, ...args: any): void;
1577
+ }
1578
+
1579
+ /**
1580
+ * @public
1581
+ */
1582
+ declare type Subscriber<T> = (v: T) => void;
1583
+ /**
1584
+ * @public
1585
+ */
1586
+ declare type PassiveEffect<T> = (v: T, safeSetter: (v: T) => void) => void;
1587
+ /**
1588
+ * `MotionValue` is used to track the state and velocity of motion values.
1589
+ *
1590
+ * @public
1591
+ */
1592
+ declare class MotionValue<V = any> {
1593
+ /**
1594
+ * This will be replaced by the build step with the latest version number.
1595
+ * When MotionValues are provided to motion components, warn if versions are mixed.
1596
+ */
1597
+ version: string;
1598
+ /**
1599
+ * If a MotionValue has an owner, it was created internally within Framer Motion
1600
+ * and therefore has no external listeners. It is therefore safe to animate via WAAPI.
1601
+ */
1602
+ owner?: VisualElement;
1603
+ /**
1604
+ * Adds a function that will be notified when the `MotionValue` is updated.
1605
+ *
1606
+ * It returns a function that, when called, will cancel the subscription.
1607
+ *
1608
+ * When calling `onChange` inside a React component, it should be wrapped with the
1609
+ * `useEffect` hook. As it returns an unsubscribe function, this should be returned
1610
+ * from the `useEffect` function to ensure you don't add duplicate subscribers..
1611
+ *
1612
+ * ```jsx
1613
+ * export const MyComponent = () => {
1614
+ * const x = useMotionValue(0)
1615
+ * const y = useMotionValue(0)
1616
+ * const opacity = useMotionValue(1)
1617
+ *
1618
+ * useEffect(() => {
1619
+ * function updateOpacity() {
1620
+ * const maxXY = Math.max(x.get(), y.get())
1621
+ * const newOpacity = transform(maxXY, [0, 100], [1, 0])
1622
+ * opacity.set(newOpacity)
1623
+ * }
1624
+ *
1625
+ * const unsubscribeX = x.onChange(updateOpacity)
1626
+ * const unsubscribeY = y.onChange(updateOpacity)
1627
+ *
1628
+ * return () => {
1629
+ * unsubscribeX()
1630
+ * unsubscribeY()
1631
+ * }
1632
+ * }, [])
1633
+ *
1634
+ * return <motion.div style={{ x }} />
1635
+ * }
1636
+ * ```
1637
+ *
1638
+ * @privateRemarks
1639
+ *
1640
+ * We could look into a `useOnChange` hook if the above lifecycle management proves confusing.
1641
+ *
1642
+ * ```jsx
1643
+ * useOnChange(x, () => {})
1644
+ * ```
1645
+ *
1646
+ * @param subscriber - A function that receives the latest value.
1647
+ * @returns A function that, when called, will cancel this subscription.
1648
+ *
1649
+ * @public
1650
+ */
1651
+ onChange(subscription: Subscriber<V>): () => void;
1652
+ clearListeners(): void;
1653
+ /**
1654
+ * Sets the state of the `MotionValue`.
1655
+ *
1656
+ * @remarks
1657
+ *
1658
+ * ```jsx
1659
+ * const x = useMotionValue(0)
1660
+ * x.set(10)
1661
+ * ```
1662
+ *
1663
+ * @param latest - Latest value to set.
1664
+ * @param render - Whether to notify render subscribers. Defaults to `true`
1665
+ *
1666
+ * @public
1667
+ */
1668
+ set(v: V, render?: boolean): void;
1669
+ updateAndNotify: (v: V, render?: boolean) => void;
1670
+ /**
1671
+ * Returns the latest state of `MotionValue`
1672
+ *
1673
+ * @returns - The latest state of `MotionValue`
1674
+ *
1675
+ * @public
1676
+ */
1677
+ get(): V;
1781
1678
  /**
1782
- * Make a target animatable by Popmotion. For instance, if we're
1783
- * trying to animate width from 100px to 100vw we need to measure 100vw
1784
- * in pixels to determine what we really need to animate to. This is also
1785
- * pluggable to support Framer's custom value types like Color,
1786
- * and CSS variables.
1679
+ * @public
1787
1680
  */
1788
- makeTargetAnimatable(target: TargetAndTransition, canMutate?: boolean): TargetAndTransition;
1681
+ getPrevious(): V;
1789
1682
  /**
1790
- * Update the provided props. Ensure any newly-added motion values are
1791
- * added to our map, old ones removed, and listeners updated.
1683
+ * Returns the latest velocity of `MotionValue`
1684
+ *
1685
+ * @returns - The latest velocity of `MotionValue`. Returns `0` if the state is non-numerical.
1686
+ *
1687
+ * @public
1792
1688
  */
1793
- setProps(props: MotionProps): void;
1794
- getProps(): MotionProps;
1689
+ getVelocity(): number;
1690
+ hasAnimated: boolean;
1795
1691
  /**
1796
- * Returns the variant definition with a given name.
1692
+ * Stop the currently active animation.
1693
+ *
1694
+ * @public
1797
1695
  */
1798
- getVariant(name: string): Variant | undefined;
1696
+ stop(): void;
1799
1697
  /**
1800
- * Returns the defined default transition on this component.
1698
+ * Returns `true` if this value is currently animating.
1699
+ *
1700
+ * @public
1801
1701
  */
1802
- getDefaultTransition(): Transition | undefined;
1803
- getTransformPagePoint(): any;
1804
- getClosestVariantNode(): VisualElement | undefined;
1805
- getVariantContext(startAtParent?: boolean): undefined | VariantStateContext;
1702
+ isAnimating(): boolean;
1703
+ private clearAnimation;
1806
1704
  /**
1807
- * Add a child visual element to our set of children.
1705
+ * Destroy and clean up subscribers to this `MotionValue`.
1706
+ *
1707
+ * The `MotionValue` hooks like `useMotionValue` and `useTransform` automatically
1708
+ * handle the lifecycle of the returned `MotionValue`, so this method is only necessary if you've manually
1709
+ * created a `MotionValue` via the `motionValue` function.
1710
+ *
1711
+ * @public
1808
1712
  */
1809
- addVariantChild(child: VisualElement): (() => boolean) | undefined;
1713
+ destroy(): void;
1714
+ }
1715
+ declare function motionValue<V>(init: V): MotionValue<V>;
1716
+
1717
+ interface Animation$1<V> {
1718
+ next: (t: number) => {
1719
+ value: V;
1720
+ done: boolean;
1721
+ };
1722
+ flipTarget: () => void;
1723
+ }
1724
+ /**
1725
+ * An update function. It accepts a timestamp used to advance the animation.
1726
+ */
1727
+ declare type Update = (timestamp: number) => void;
1728
+ /**
1729
+ * Drivers accept a update function and call it at an interval. This interval
1730
+ * could be a synchronous loop, a setInterval, or tied to the device's framerate.
1731
+ */
1732
+ interface DriverControls {
1733
+ start: () => void;
1734
+ stop: () => void;
1735
+ }
1736
+ declare type Driver = (update: Update) => DriverControls;
1737
+
1738
+ interface VelocityOptions {
1739
+ velocity?: number;
1740
+ restSpeed?: number;
1741
+ restDelta?: number;
1742
+ }
1743
+ interface AnimationLifecycleOptions<V> {
1744
+ onUpdate?: (v: V) => void;
1745
+ onComplete?: VoidFunction;
1746
+ onPlay?: VoidFunction;
1747
+ onRepeat?: VoidFunction;
1748
+ onStop?: VoidFunction;
1749
+ }
1750
+ interface AnimationPlaybackOptions {
1751
+ repeat?: number;
1752
+ repeatType?: "loop" | "reverse" | "mirror";
1753
+ repeatDelay?: number;
1754
+ }
1755
+ interface DurationSpringOptions {
1756
+ duration?: number;
1757
+ bounce?: number;
1758
+ }
1759
+ interface SpringOptions extends DurationSpringOptions, VelocityOptions {
1760
+ stiffness?: number;
1761
+ damping?: number;
1762
+ mass?: number;
1763
+ }
1764
+ interface DecayOptions extends VelocityOptions {
1765
+ keyframes?: number[];
1766
+ power?: number;
1767
+ timeConstant?: number;
1768
+ modifyTarget?: (v: number) => number;
1769
+ }
1770
+ interface InertiaOptions$1 extends DecayOptions {
1771
+ bounceStiffness?: number;
1772
+ bounceDamping?: number;
1773
+ min?: number;
1774
+ max?: number;
1775
+ }
1776
+ interface KeyframeOptions {
1777
+ ease?: Easing | Easing[];
1778
+ times?: number[];
1779
+ }
1780
+ interface AnimationOptions<V = any> extends AnimationLifecycleOptions<V>, AnimationPlaybackOptions, Omit<SpringOptions, "keyframes">, Omit<InertiaOptions$1, "keyframes">, KeyframeOptions {
1781
+ keyframes: V[];
1782
+ elapsed?: number;
1783
+ driver?: Driver;
1784
+ type?: "decay" | "spring" | "keyframes" | "tween";
1785
+ duration?: number;
1786
+ }
1787
+ /**
1788
+ * @public
1789
+ */
1790
+ declare type ControlsAnimationDefinition = string | string[] | TargetAndTransition | TargetResolver;
1791
+ /**
1792
+ * @public
1793
+ */
1794
+ interface AnimationControls {
1810
1795
  /**
1811
- * Add a motion value and bind it to this visual element.
1796
+ * Starts an animation on all linked components.
1797
+ *
1798
+ * @remarks
1799
+ *
1800
+ * ```jsx
1801
+ * controls.start("variantLabel")
1802
+ * controls.start({
1803
+ * x: 0,
1804
+ * transition: { duration: 1 }
1805
+ * })
1806
+ * ```
1807
+ *
1808
+ * @param definition - Properties or variant label to animate to
1809
+ * @param transition - Optional `transtion` to apply to a variant
1810
+ * @returns - A `Promise` that resolves when all animations have completed.
1811
+ *
1812
+ * @public
1812
1813
  */
1813
- addValue(key: string, value: MotionValue): void;
1814
+ start(definition: ControlsAnimationDefinition, transitionOverride?: Transition): Promise<any>;
1814
1815
  /**
1815
- * Remove a motion value and unbind any active subscriptions.
1816
+ * Instantly set to a set of properties or a variant.
1817
+ *
1818
+ * ```jsx
1819
+ * // With properties
1820
+ * controls.set({ opacity: 0 })
1821
+ *
1822
+ * // With variants
1823
+ * controls.set("hidden")
1824
+ * ```
1825
+ *
1826
+ * @privateRemarks
1827
+ * We could perform a similar trick to `.start` where this can be called before mount
1828
+ * and we maintain a list of of pending actions that get applied on mount. But the
1829
+ * expectation of `set` is that it happens synchronously and this would be difficult
1830
+ * to do before any children have even attached themselves. It's also poor practise
1831
+ * and we should discourage render-synchronous `.start` calls rather than lean into this.
1832
+ *
1833
+ * @public
1816
1834
  */
1817
- removeValue(key: string): void;
1835
+ set(definition: ControlsAnimationDefinition): void;
1818
1836
  /**
1819
- * Check whether we have a motion value for this key
1837
+ * Stops animations on all linked components.
1838
+ *
1839
+ * ```jsx
1840
+ * controls.stop()
1841
+ * ```
1842
+ *
1843
+ * @public
1820
1844
  */
1821
- hasValue(key: string): boolean;
1845
+ stop(): void;
1846
+ mount(): () => void;
1847
+ }
1848
+
1849
+ /**
1850
+ * Passed in to pan event handlers like `onPan` the `PanInfo` object contains
1851
+ * information about the current state of the tap gesture such as its
1852
+ * `point`, `delta`, `offset` and `velocity`.
1853
+ *
1854
+ * ```jsx
1855
+ * <motion.div onPan={(event, info) => {
1856
+ * console.log(info.point.x, info.point.y)
1857
+ * }} />
1858
+ * ```
1859
+ *
1860
+ * @public
1861
+ */
1862
+ interface PanInfo {
1822
1863
  /**
1823
- * Get a motion value for this key. If called with a default
1824
- * value, we'll create one if none exists.
1864
+ * Contains `x` and `y` values for the current pan position relative
1865
+ * to the device or page.
1866
+ *
1867
+ * ```jsx
1868
+ * function onPan(event, info) {
1869
+ * console.log(info.point.x, info.point.y)
1870
+ * }
1871
+ *
1872
+ * <motion.div onPan={onPan} />
1873
+ * ```
1874
+ *
1875
+ * @public
1825
1876
  */
1826
- getValue(key: string, defaultValue?: string | number): MotionValue<any>;
1877
+ point: Point;
1827
1878
  /**
1828
- * If we're trying to animate to a previously unencountered value,
1829
- * we need to check for it in our state and as a last resort read it
1830
- * directly from the instance (which might have performance implications).
1879
+ * Contains `x` and `y` values for the distance moved since
1880
+ * the last event.
1881
+ *
1882
+ * ```jsx
1883
+ * function onPan(event, info) {
1884
+ * console.log(info.delta.x, info.delta.y)
1885
+ * }
1886
+ *
1887
+ * <motion.div onPan={onPan} />
1888
+ * ```
1889
+ *
1890
+ * @public
1831
1891
  */
1832
- readValue(key: string): string | number | null | undefined;
1892
+ delta: Point;
1833
1893
  /**
1834
- * Set the base target to later animate back to. This is currently
1835
- * only hydrated on creation and when we first read a value.
1894
+ * Contains `x` and `y` values for the distance moved from
1895
+ * the first pan event.
1896
+ *
1897
+ * ```jsx
1898
+ * function onPan(event, info) {
1899
+ * console.log(info.offset.x, info.offset.y)
1900
+ * }
1901
+ *
1902
+ * <motion.div onPan={onPan} />
1903
+ * ```
1904
+ *
1905
+ * @public
1836
1906
  */
1837
- setBaseTarget(key: string, value: string | number): void;
1907
+ offset: Point;
1838
1908
  /**
1839
- * Find the base target for a value thats been removed from all animation
1840
- * props.
1909
+ * Contains `x` and `y` values for the current velocity of the pointer, in px/ms.
1910
+ *
1911
+ * ```jsx
1912
+ * function onPan(event, info) {
1913
+ * console.log(info.velocity.x, info.velocity.y)
1914
+ * }
1915
+ *
1916
+ * <motion.div onPan={onPan} />
1917
+ * ```
1918
+ *
1919
+ * @public
1841
1920
  */
1842
- getBaseTarget(key: string): any;
1843
- on<EventName extends keyof VisualElementEventCallbacks>(eventName: EventName, callback: VisualElementEventCallbacks[EventName]): VoidFunction;
1844
- notify<EventName extends keyof VisualElementEventCallbacks>(eventName: EventName, ...args: any): void;
1921
+ velocity: Point;
1845
1922
  }
1846
1923
 
1847
1924
  interface DragControlOptions {
@@ -3866,21 +3943,6 @@ declare function useTransform<I, O>(input: MotionValue<I>, transformer: SingleTr
3866
3943
  */
3867
3944
  declare function useTransform<I, O>(input: MotionValue<string>[] | MotionValue<number>[] | MotionValue<string | number>[], transformer: MultiTransformer<I, O>): MotionValue<O>;
3868
3945
 
3869
- interface PhysicsSpringOptions {
3870
- velocity: number;
3871
- stiffness: number;
3872
- damping: number;
3873
- mass: number;
3874
- }
3875
- interface SpringOptions extends Partial<PhysicsSpringOptions> {
3876
- from?: number;
3877
- to?: number;
3878
- duration?: number;
3879
- bounce?: number;
3880
- restSpeed?: number;
3881
- restDelta?: number;
3882
- }
3883
-
3884
3946
  /**
3885
3947
  * Creates a `MotionValue` that, when `set`, will use a spring animation to animate to its new state.
3886
3948
  *
@@ -4204,6 +4266,9 @@ declare function buildTransform({ transform, transformKeys, }: Pick<HTMLRenderSt
4204
4266
  declare const clamp: (min: number, max: number, v: number) => number;
4205
4267
 
4206
4268
  declare type DelayedFunction = (overshoot: number) => void;
4269
+ /**
4270
+ * Timeout defined in ms
4271
+ */
4207
4272
  declare function delay(callback: DelayedFunction, timeout: number): () => void;
4208
4273
 
4209
4274
  declare const distance: (a: number, b: number) => number;
@@ -4215,6 +4280,24 @@ declare const pipe: (...transformers: Function[]) => Function;
4215
4280
 
4216
4281
  declare const wrap: (min: number, max: number, v: number) => number;
4217
4282
 
4283
+ interface NativeAnimationOptions {
4284
+ delay?: number;
4285
+ duration?: number;
4286
+ ease?: EasingDefinition;
4287
+ }
4288
+
4289
+ declare function startOptimizedAppearAnimation(element: HTMLElement, name: string, keyframes: string[] | number[], options: NativeAnimationOptions): Animation | undefined;
4290
+
4291
+ declare const optimizedAppearDataAttribute: string;
4292
+
4293
+ /**
4294
+ * This is based on the spring implementation of Wobble https://github.com/skevy/wobble
4295
+ */
4296
+ declare function spring({ keyframes, restSpeed, restDelta, ...options }: AnimationOptions<number>): Animation$1<number>;
4297
+ declare namespace spring {
4298
+ var needsInterpolation: (a: any, b: any) => boolean;
4299
+ }
4300
+
4218
4301
  interface NodeGroup {
4219
4302
  add: (node: IProjectionNode) => void;
4220
4303
  remove: (node: IProjectionNode) => void;
@@ -4274,4 +4357,4 @@ interface ScaleMotionValues {
4274
4357
  */
4275
4358
  declare function useInvertedScale(scale?: Partial<ScaleMotionValues>): ScaleMotionValues;
4276
4359
 
4277
- export { AnimatePresence, AnimatePresenceProps, AnimateSharedLayout, AnimationControls, AnimationLifecycles, AnimationOptions$1 as AnimationOptions, AnimationPlaybackControls, AnimationProps, AnimationType, Axis, AxisDelta, BoundingBox, Box, CreateVisualElement, CustomDomComponent, CustomValueType, Cycle, CycleState, DelayedFunction, Delta, DeprecatedLayoutGroupContext, DragControls, DragElastic, DragHandlers, DraggableProps, Easing, EasingFunction, EasingModifier, EventInfo, FeatureBundle, FeatureComponent, FeatureComponents, FeatureDefinition, FeatureDefinitions, FeatureNames, FeatureProps, FlatTree, FocusHandlers, ForwardRefComponent, HTMLMotionProps, HoverHandlers, IProjectionNode, Inertia, Keyframes, KeyframesTarget, LayoutGroup, LayoutGroupContext, LayoutProps, LazyFeatureBundle$1 as LazyFeatureBundle, LazyMotion, LazyProps, LoadedFeatures, MotionAdvancedProps, MotionConfig, MotionConfigContext, MotionConfigProps, MotionContext, MotionProps, MotionStyle, MotionTransform, MotionValue, None, Orchestration, PanHandlers, PanInfo, PassiveEffect, Point, PresenceContext, RelayoutInfo, RenderComponent, Reorder, Repeat, ResolveLayoutTransition, ResolvedKeyframesTarget, ResolvedSingleTarget, ResolvedValueTarget, ResolvedValues, SVGAttributesAsMotionValues, SVGMotionProps, ScrapeMotionValuesFromProps, ScrollMotionValues, SingleTarget, Spring, Subscriber, SwitchLayoutGroupContext, TapHandlers, TapInfo, Target, TargetAndTransition, TransformPoint, Transition, Tween, ValueTarget, Variant, VariantLabels, Variants, VisualElement, VisualState, addPointerEvent, addScaleCorrector, animate, animateVisualElement, animationControls, animations, buildTransform, calcLength, checkTargetForNewValues, clamp, createBox, createDomMotionComponent, createMotionComponent, delay, distance, distance2D, domAnimation, domMax, filterProps, isBrowser, isDragActive, isMotionComponent, isMotionValue, isValidMotionProp, m, makeUseVisualState, mix, motion, motionValue, pipe, resolveMotionValue, transform, unwrapMotionComponent, useAnimation, useAnimationControls, useAnimationFrame, useCycle, useAnimatedState as useDeprecatedAnimatedState, useInvertedScale as useDeprecatedInvertedScale, useDomEvent, useDragControls, useElementScroll, useForceUpdate, useInView, useInstantLayoutTransition, useInstantTransition, useIsPresent, useIsomorphicLayoutEffect, useMotionTemplate, useMotionValue, usePresence, useReducedMotion, useReducedMotionConfig, useResetProjection, useScroll, useSpring, useTime, useTransform, useUnmountEffect, useVelocity, useViewportScroll, useVisualElementContext, useWillChange, wrap, wrapHandler };
4360
+ export { AnimatePresence, AnimatePresenceProps, AnimateSharedLayout, AnimationControls, AnimationLifecycles, AnimationOptions$2 as AnimationOptions, AnimationPlaybackControls, AnimationProps, AnimationType, Axis, AxisDelta, BezierDefinition, BoundingBox, Box, CreateVisualElement, CustomDomComponent, CustomValueType, Cycle, CycleState, DelayedFunction, Delta, DeprecatedLayoutGroupContext, DragControls, DragElastic, DragHandlers, DraggableProps, Easing, EasingDefinition, EasingFunction, EasingModifier, EventInfo, FeatureBundle, FeatureComponent, FeatureComponents, FeatureDefinition, FeatureDefinitions, FeatureNames, FeatureProps, FlatTree, FocusHandlers, ForwardRefComponent, HTMLMotionProps, HoverHandlers, IProjectionNode, Inertia, Keyframes, KeyframesTarget, LayoutGroup, LayoutGroupContext, LayoutProps, LazyFeatureBundle$1 as LazyFeatureBundle, LazyMotion, LazyProps, LoadedFeatures, MotionAdvancedProps, MotionConfig, MotionConfigContext, MotionConfigProps, MotionContext, MotionProps, MotionStyle, MotionTransform, MotionValue, None, Orchestration, PanHandlers, PanInfo, PassiveEffect, Point, PresenceContext, RelayoutInfo, RenderComponent, Reorder, Repeat, ResolveLayoutTransition, ResolvedKeyframesTarget, ResolvedSingleTarget, ResolvedValueTarget, ResolvedValues, SVGAttributesAsMotionValues, SVGMotionProps, ScrapeMotionValuesFromProps, ScrollMotionValues, SingleTarget, Spring, Subscriber, SwitchLayoutGroupContext, TapHandlers, TapInfo, Target, TargetAndTransition, TransformPoint, Transition, Tween, ValueTarget, Variant, VariantLabels, Variants, VisualElement, VisualState, addPointerEvent, addScaleCorrector, animate, animateVisualElement, animationControls, animations, buildTransform, calcLength, checkTargetForNewValues, clamp, createBox, createDomMotionComponent, createMotionComponent, delay, distance, distance2D, domAnimation, domMax, filterProps, isBrowser, isDragActive, isMotionComponent, isMotionValue, isValidMotionProp, m, makeUseVisualState, mix, motion, motionValue, optimizedAppearDataAttribute, pipe, resolveMotionValue, spring, startOptimizedAppearAnimation, transform, unwrapMotionComponent, useAnimation, useAnimationControls, useAnimationFrame, useCycle, useAnimatedState as useDeprecatedAnimatedState, useInvertedScale as useDeprecatedInvertedScale, useDomEvent, useDragControls, useElementScroll, useForceUpdate, useInView, useInstantLayoutTransition, useInstantTransition, useIsPresent, useIsomorphicLayoutEffect, useMotionTemplate, useMotionValue, usePresence, useReducedMotion, useReducedMotionConfig, useResetProjection, useScroll, useSpring, useTime, useTransform, useUnmountEffect, useVelocity, useViewportScroll, useVisualElementContext, useWillChange, wrap, wrapHandler };