framer-motion 7.8.0 → 7.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +6 -5
  2. package/dist/cjs/index.js +2030 -1920
  3. package/dist/es/animation/animate.mjs +2 -2
  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 +124 -0
  9. package/dist/es/animation/legacy-popmotion/decay.mjs +11 -4
  10. package/dist/es/animation/legacy-popmotion/index.mjs +22 -11
  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 +13 -11
  14. package/dist/es/animation/utils/default-transitions.mjs +9 -14
  15. package/dist/es/animation/utils/keyframes.mjs +41 -0
  16. package/dist/es/animation/utils/transitions.mjs +1 -166
  17. package/dist/es/animation/waapi/create-accelerated-animation.mjs +82 -0
  18. package/dist/es/animation/waapi/index.mjs +4 -6
  19. package/dist/es/gestures/drag/VisualElementDragControls.mjs +2 -2
  20. package/dist/es/index.mjs +3 -3
  21. package/dist/es/render/VisualElement.mjs +1 -1
  22. package/dist/es/render/utils/animation.mjs +2 -2
  23. package/dist/es/render/utils/motion-values.mjs +2 -2
  24. package/dist/es/render/utils/setters.mjs +1 -1
  25. package/dist/es/value/index.mjs +11 -5
  26. package/dist/es/value/use-spring.mjs +1 -2
  27. package/dist/framer-motion.dev.js +2051 -1941
  28. package/dist/framer-motion.js +1 -1
  29. package/dist/index.d.ts +409 -348
  30. package/dist/projection.dev.js +1672 -1535
  31. package/dist/size-rollup-dom-animation-assets.js +1 -1
  32. package/dist/size-rollup-dom-animation.js +1 -1
  33. package/dist/size-rollup-dom-max-assets.js +1 -1
  34. package/dist/size-rollup-dom-max.js +1 -1
  35. package/dist/size-rollup-motion.js +1 -1
  36. package/dist/size-webpack-dom-animation.js +1 -1
  37. package/dist/size-webpack-dom-max.js +1 -1
  38. package/dist/three-entry.d.ts +287 -281
  39. package/package.json +8 -8
package/dist/index.d.ts CHANGED
@@ -3,139 +3,6 @@ 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;
141
8
  declare type BezierDefinition = [number, number, number, number];
@@ -1011,67 +878,11 @@ interface CustomValueType {
1011
878
  toValue: () => number | string;
1012
879
  }
1013
880
 
1014
- /**
1015
- * @public
1016
- */
1017
- declare type ControlsAnimationDefinition = string | string[] | TargetAndTransition | TargetResolver;
1018
- /**
1019
- * @public
1020
- */
1021
- interface AnimationControls {
1022
- /**
1023
- * Starts an animation on all linked components.
1024
- *
1025
- * @remarks
1026
- *
1027
- * ```jsx
1028
- * controls.start("variantLabel")
1029
- * controls.start({
1030
- * x: 0,
1031
- * transition: { duration: 1 }
1032
- * })
1033
- * ```
1034
- *
1035
- * @param definition - Properties or variant label to animate to
1036
- * @param transition - Optional `transtion` to apply to a variant
1037
- * @returns - A `Promise` that resolves when all animations have completed.
1038
- *
1039
- * @public
1040
- */
1041
- start(definition: ControlsAnimationDefinition, transitionOverride?: Transition): Promise<any>;
1042
- /**
1043
- * Instantly set to a set of properties or a variant.
1044
- *
1045
- * ```jsx
1046
- * // With properties
1047
- * controls.set({ opacity: 0 })
1048
- *
1049
- * // With variants
1050
- * controls.set("hidden")
1051
- * ```
1052
- *
1053
- * @privateRemarks
1054
- * We could perform a similar trick to `.start` where this can be called before mount
1055
- * and we maintain a list of of pending actions that get applied on mount. But the
1056
- * expectation of `set` is that it happens synchronously and this would be difficult
1057
- * to do before any children have even attached themselves. It's also poor practise
1058
- * and we should discourage render-synchronous `.start` calls rather than lean into this.
1059
- *
1060
- * @public
1061
- */
1062
- set(definition: ControlsAnimationDefinition): void;
1063
- /**
1064
- * Stops animations on all linked components.
1065
- *
1066
- * ```jsx
1067
- * controls.stop()
1068
- * ```
1069
- *
1070
- * @public
1071
- */
1072
- stop(): void;
1073
- mount(): () => void;
1074
- }
881
+ declare type FrameData = {
882
+ delta: number;
883
+ timestamp: number;
884
+ };
885
+ declare type Process = (data: FrameData) => void;
1075
886
 
1076
887
  interface Point {
1077
888
  x: number;
@@ -1103,87 +914,6 @@ interface Delta {
1103
914
  }
1104
915
  declare type TransformPoint = (point: Point) => Point;
1105
916
 
1106
- /**
1107
- * Passed in to pan event handlers like `onPan` the `PanInfo` object contains
1108
- * information about the current state of the tap gesture such as its
1109
- * `point`, `delta`, `offset` and `velocity`.
1110
- *
1111
- * ```jsx
1112
- * <motion.div onPan={(event, info) => {
1113
- * console.log(info.point.x, info.point.y)
1114
- * }} />
1115
- * ```
1116
- *
1117
- * @public
1118
- */
1119
- interface PanInfo {
1120
- /**
1121
- * Contains `x` and `y` values for the current pan position relative
1122
- * to the device or page.
1123
- *
1124
- * ```jsx
1125
- * function onPan(event, info) {
1126
- * console.log(info.point.x, info.point.y)
1127
- * }
1128
- *
1129
- * <motion.div onPan={onPan} />
1130
- * ```
1131
- *
1132
- * @public
1133
- */
1134
- point: Point;
1135
- /**
1136
- * Contains `x` and `y` values for the distance moved since
1137
- * the last event.
1138
- *
1139
- * ```jsx
1140
- * function onPan(event, info) {
1141
- * console.log(info.delta.x, info.delta.y)
1142
- * }
1143
- *
1144
- * <motion.div onPan={onPan} />
1145
- * ```
1146
- *
1147
- * @public
1148
- */
1149
- delta: Point;
1150
- /**
1151
- * Contains `x` and `y` values for the distance moved from
1152
- * the first pan event.
1153
- *
1154
- * ```jsx
1155
- * function onPan(event, info) {
1156
- * console.log(info.offset.x, info.offset.y)
1157
- * }
1158
- *
1159
- * <motion.div onPan={onPan} />
1160
- * ```
1161
- *
1162
- * @public
1163
- */
1164
- offset: Point;
1165
- /**
1166
- * Contains `x` and `y` values for the current velocity of the pointer, in px/ms.
1167
- *
1168
- * ```jsx
1169
- * function onPan(event, info) {
1170
- * console.log(info.velocity.x, info.velocity.y)
1171
- * }
1172
- *
1173
- * <motion.div onPan={onPan} />
1174
- * ```
1175
- *
1176
- * @public
1177
- */
1178
- velocity: Point;
1179
- }
1180
-
1181
- declare type FrameData = {
1182
- delta: number;
1183
- timestamp: number;
1184
- };
1185
- declare type Process = (data: FrameData) => void;
1186
-
1187
917
  declare type ReducedMotionConfig = "always" | "never" | "user";
1188
918
  /**
1189
919
  * @public
@@ -1280,7 +1010,7 @@ interface AnimationPlaybackLifecycles<V> {
1280
1010
  /**
1281
1011
  * @public
1282
1012
  */
1283
- declare type AnimationOptions$1<V> = (Tween | Spring) & AnimationPlaybackLifecycles<V> & {
1013
+ declare type AnimationOptions$2<V> = (Tween | Spring) & AnimationPlaybackLifecycles<V> & {
1284
1014
  delay?: number;
1285
1015
  type?: "tween" | "spring";
1286
1016
  };
@@ -1311,7 +1041,7 @@ declare type AnimationOptions$1<V> = (Tween | Spring) & AnimationPlaybackLifecyc
1311
1041
  *
1312
1042
  * @public
1313
1043
  */
1314
- 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;
1315
1045
 
1316
1046
  interface WithDepth {
1317
1047
  depth: number;
@@ -1542,17 +1272,17 @@ declare enum AnimationType {
1542
1272
  }
1543
1273
 
1544
1274
  declare type AnimationDefinition = VariantLabels | TargetAndTransition | TargetResolver;
1545
- declare type AnimationOptions = {
1275
+ declare type AnimationOptions$1 = {
1546
1276
  delay?: number;
1547
1277
  transitionOverride?: Transition;
1548
1278
  custom?: any;
1549
1279
  type?: AnimationType;
1550
1280
  };
1551
- declare function animateVisualElement(visualElement: VisualElement, definition: AnimationDefinition, options?: AnimationOptions): Promise<void>;
1281
+ declare function animateVisualElement(visualElement: VisualElement, definition: AnimationDefinition, options?: AnimationOptions$1): Promise<void>;
1552
1282
 
1553
1283
  interface AnimationState {
1554
- animateChanges: (options?: AnimationOptions, type?: AnimationType) => Promise<any>;
1555
- 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>;
1556
1286
  setAnimateFunction: (fn: any) => void;
1557
1287
  getState: () => {
1558
1288
  [key: string]: AnimationTypeState;
@@ -1777,73 +1507,423 @@ declare abstract class VisualElement<Instance = unknown, RenderState = unknown,
1777
1507
  * Only measures axis-aligned boxes, rotate and skew must be manually
1778
1508
  * removed with a re-render to work.
1779
1509
  */
1780
- measureViewportBox(): Box;
1781
- getStaticValue(key: string): string | number;
1782
- 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
+ interface MotionValueOptions {
1588
+ owner?: VisualElement;
1589
+ }
1590
+ /**
1591
+ * `MotionValue` is used to track the state and velocity of motion values.
1592
+ *
1593
+ * @public
1594
+ */
1595
+ declare class MotionValue<V = any> {
1596
+ /**
1597
+ * This will be replaced by the build step with the latest version number.
1598
+ * When MotionValues are provided to motion components, warn if versions are mixed.
1599
+ */
1600
+ version: string;
1601
+ /**
1602
+ * If a MotionValue has an owner, it was created internally within Framer Motion
1603
+ * and therefore has no external listeners. It is therefore safe to animate via WAAPI.
1604
+ */
1605
+ owner?: VisualElement;
1606
+ /**
1607
+ * Adds a function that will be notified when the `MotionValue` is updated.
1608
+ *
1609
+ * It returns a function that, when called, will cancel the subscription.
1610
+ *
1611
+ * When calling `onChange` inside a React component, it should be wrapped with the
1612
+ * `useEffect` hook. As it returns an unsubscribe function, this should be returned
1613
+ * from the `useEffect` function to ensure you don't add duplicate subscribers..
1614
+ *
1615
+ * ```jsx
1616
+ * export const MyComponent = () => {
1617
+ * const x = useMotionValue(0)
1618
+ * const y = useMotionValue(0)
1619
+ * const opacity = useMotionValue(1)
1620
+ *
1621
+ * useEffect(() => {
1622
+ * function updateOpacity() {
1623
+ * const maxXY = Math.max(x.get(), y.get())
1624
+ * const newOpacity = transform(maxXY, [0, 100], [1, 0])
1625
+ * opacity.set(newOpacity)
1626
+ * }
1627
+ *
1628
+ * const unsubscribeX = x.onChange(updateOpacity)
1629
+ * const unsubscribeY = y.onChange(updateOpacity)
1630
+ *
1631
+ * return () => {
1632
+ * unsubscribeX()
1633
+ * unsubscribeY()
1634
+ * }
1635
+ * }, [])
1636
+ *
1637
+ * return <motion.div style={{ x }} />
1638
+ * }
1639
+ * ```
1640
+ *
1641
+ * @privateRemarks
1642
+ *
1643
+ * We could look into a `useOnChange` hook if the above lifecycle management proves confusing.
1644
+ *
1645
+ * ```jsx
1646
+ * useOnChange(x, () => {})
1647
+ * ```
1648
+ *
1649
+ * @param subscriber - A function that receives the latest value.
1650
+ * @returns A function that, when called, will cancel this subscription.
1651
+ *
1652
+ * @public
1653
+ */
1654
+ onChange(subscription: Subscriber<V>): () => void;
1655
+ clearListeners(): void;
1656
+ /**
1657
+ * Sets the state of the `MotionValue`.
1658
+ *
1659
+ * @remarks
1660
+ *
1661
+ * ```jsx
1662
+ * const x = useMotionValue(0)
1663
+ * x.set(10)
1664
+ * ```
1665
+ *
1666
+ * @param latest - Latest value to set.
1667
+ * @param render - Whether to notify render subscribers. Defaults to `true`
1668
+ *
1669
+ * @public
1670
+ */
1671
+ set(v: V, render?: boolean): void;
1672
+ setWithVelocity(prev: V, current: V, delta: number): void;
1673
+ updateAndNotify: (v: V, render?: boolean) => void;
1674
+ /**
1675
+ * Returns the latest state of `MotionValue`
1676
+ *
1677
+ * @returns - The latest state of `MotionValue`
1678
+ *
1679
+ * @public
1680
+ */
1681
+ get(): V;
1783
1682
  /**
1784
- * Make a target animatable by Popmotion. For instance, if we're
1785
- * trying to animate width from 100px to 100vw we need to measure 100vw
1786
- * in pixels to determine what we really need to animate to. This is also
1787
- * pluggable to support Framer's custom value types like Color,
1788
- * and CSS variables.
1683
+ * @public
1789
1684
  */
1790
- makeTargetAnimatable(target: TargetAndTransition, canMutate?: boolean): TargetAndTransition;
1685
+ getPrevious(): V;
1791
1686
  /**
1792
- * Update the provided props. Ensure any newly-added motion values are
1793
- * added to our map, old ones removed, and listeners updated.
1687
+ * Returns the latest velocity of `MotionValue`
1688
+ *
1689
+ * @returns - The latest velocity of `MotionValue`. Returns `0` if the state is non-numerical.
1690
+ *
1691
+ * @public
1794
1692
  */
1795
- setProps(props: MotionProps): void;
1796
- getProps(): MotionProps;
1693
+ getVelocity(): number;
1694
+ hasAnimated: boolean;
1797
1695
  /**
1798
- * Returns the variant definition with a given name.
1696
+ * Stop the currently active animation.
1697
+ *
1698
+ * @public
1799
1699
  */
1800
- getVariant(name: string): Variant | undefined;
1700
+ stop(): void;
1801
1701
  /**
1802
- * Returns the defined default transition on this component.
1702
+ * Returns `true` if this value is currently animating.
1703
+ *
1704
+ * @public
1803
1705
  */
1804
- getDefaultTransition(): Transition | undefined;
1805
- getTransformPagePoint(): any;
1806
- getClosestVariantNode(): VisualElement | undefined;
1807
- getVariantContext(startAtParent?: boolean): undefined | VariantStateContext;
1706
+ isAnimating(): boolean;
1707
+ private clearAnimation;
1808
1708
  /**
1809
- * Add a child visual element to our set of children.
1709
+ * Destroy and clean up subscribers to this `MotionValue`.
1710
+ *
1711
+ * The `MotionValue` hooks like `useMotionValue` and `useTransform` automatically
1712
+ * handle the lifecycle of the returned `MotionValue`, so this method is only necessary if you've manually
1713
+ * created a `MotionValue` via the `motionValue` function.
1714
+ *
1715
+ * @public
1810
1716
  */
1811
- addVariantChild(child: VisualElement): (() => boolean) | undefined;
1717
+ destroy(): void;
1718
+ }
1719
+ declare function motionValue<V>(init: V, options?: MotionValueOptions): MotionValue<V>;
1720
+
1721
+ interface Animation$1<V> {
1722
+ next: (t: number) => {
1723
+ value: V;
1724
+ done: boolean;
1725
+ };
1726
+ flipTarget: () => void;
1727
+ }
1728
+ /**
1729
+ * An update function. It accepts a timestamp used to advance the animation.
1730
+ */
1731
+ declare type Update = (timestamp: number) => void;
1732
+ /**
1733
+ * Drivers accept a update function and call it at an interval. This interval
1734
+ * could be a synchronous loop, a setInterval, or tied to the device's framerate.
1735
+ */
1736
+ interface DriverControls {
1737
+ start: () => void;
1738
+ stop: () => void;
1739
+ }
1740
+ declare type Driver = (update: Update) => DriverControls;
1741
+
1742
+ interface VelocityOptions {
1743
+ velocity?: number;
1744
+ restSpeed?: number;
1745
+ restDelta?: number;
1746
+ }
1747
+ interface AnimationLifecycleOptions<V> {
1748
+ onUpdate?: (v: V) => void;
1749
+ onComplete?: VoidFunction;
1750
+ onPlay?: VoidFunction;
1751
+ onRepeat?: VoidFunction;
1752
+ onStop?: VoidFunction;
1753
+ }
1754
+ interface AnimationPlaybackOptions {
1755
+ repeat?: number;
1756
+ repeatType?: "loop" | "reverse" | "mirror";
1757
+ repeatDelay?: number;
1758
+ }
1759
+ interface DurationSpringOptions {
1760
+ duration?: number;
1761
+ bounce?: number;
1762
+ }
1763
+ interface SpringOptions extends DurationSpringOptions, VelocityOptions {
1764
+ stiffness?: number;
1765
+ damping?: number;
1766
+ mass?: number;
1767
+ }
1768
+ interface DecayOptions extends VelocityOptions {
1769
+ keyframes?: number[];
1770
+ power?: number;
1771
+ timeConstant?: number;
1772
+ modifyTarget?: (v: number) => number;
1773
+ }
1774
+ interface InertiaOptions$1 extends DecayOptions {
1775
+ bounceStiffness?: number;
1776
+ bounceDamping?: number;
1777
+ min?: number;
1778
+ max?: number;
1779
+ }
1780
+ interface KeyframeOptions {
1781
+ ease?: Easing | Easing[];
1782
+ times?: number[];
1783
+ }
1784
+ interface AnimationOptions<V = any> extends AnimationLifecycleOptions<V>, AnimationPlaybackOptions, Omit<SpringOptions, "keyframes">, Omit<InertiaOptions$1, "keyframes">, KeyframeOptions {
1785
+ keyframes: V[];
1786
+ elapsed?: number;
1787
+ driver?: Driver;
1788
+ type?: "decay" | "spring" | "keyframes" | "tween";
1789
+ duration?: number;
1790
+ autoplay?: boolean;
1791
+ }
1792
+ /**
1793
+ * @public
1794
+ */
1795
+ declare type ControlsAnimationDefinition = string | string[] | TargetAndTransition | TargetResolver;
1796
+ /**
1797
+ * @public
1798
+ */
1799
+ interface AnimationControls {
1812
1800
  /**
1813
- * Add a motion value and bind it to this visual element.
1801
+ * Starts an animation on all linked components.
1802
+ *
1803
+ * @remarks
1804
+ *
1805
+ * ```jsx
1806
+ * controls.start("variantLabel")
1807
+ * controls.start({
1808
+ * x: 0,
1809
+ * transition: { duration: 1 }
1810
+ * })
1811
+ * ```
1812
+ *
1813
+ * @param definition - Properties or variant label to animate to
1814
+ * @param transition - Optional `transtion` to apply to a variant
1815
+ * @returns - A `Promise` that resolves when all animations have completed.
1816
+ *
1817
+ * @public
1814
1818
  */
1815
- addValue(key: string, value: MotionValue): void;
1819
+ start(definition: ControlsAnimationDefinition, transitionOverride?: Transition): Promise<any>;
1816
1820
  /**
1817
- * Remove a motion value and unbind any active subscriptions.
1821
+ * Instantly set to a set of properties or a variant.
1822
+ *
1823
+ * ```jsx
1824
+ * // With properties
1825
+ * controls.set({ opacity: 0 })
1826
+ *
1827
+ * // With variants
1828
+ * controls.set("hidden")
1829
+ * ```
1830
+ *
1831
+ * @privateRemarks
1832
+ * We could perform a similar trick to `.start` where this can be called before mount
1833
+ * and we maintain a list of of pending actions that get applied on mount. But the
1834
+ * expectation of `set` is that it happens synchronously and this would be difficult
1835
+ * to do before any children have even attached themselves. It's also poor practise
1836
+ * and we should discourage render-synchronous `.start` calls rather than lean into this.
1837
+ *
1838
+ * @public
1818
1839
  */
1819
- removeValue(key: string): void;
1840
+ set(definition: ControlsAnimationDefinition): void;
1820
1841
  /**
1821
- * Check whether we have a motion value for this key
1842
+ * Stops animations on all linked components.
1843
+ *
1844
+ * ```jsx
1845
+ * controls.stop()
1846
+ * ```
1847
+ *
1848
+ * @public
1822
1849
  */
1823
- hasValue(key: string): boolean;
1850
+ stop(): void;
1851
+ mount(): () => void;
1852
+ }
1853
+
1854
+ /**
1855
+ * Passed in to pan event handlers like `onPan` the `PanInfo` object contains
1856
+ * information about the current state of the tap gesture such as its
1857
+ * `point`, `delta`, `offset` and `velocity`.
1858
+ *
1859
+ * ```jsx
1860
+ * <motion.div onPan={(event, info) => {
1861
+ * console.log(info.point.x, info.point.y)
1862
+ * }} />
1863
+ * ```
1864
+ *
1865
+ * @public
1866
+ */
1867
+ interface PanInfo {
1824
1868
  /**
1825
- * Get a motion value for this key. If called with a default
1826
- * value, we'll create one if none exists.
1869
+ * Contains `x` and `y` values for the current pan position relative
1870
+ * to the device or page.
1871
+ *
1872
+ * ```jsx
1873
+ * function onPan(event, info) {
1874
+ * console.log(info.point.x, info.point.y)
1875
+ * }
1876
+ *
1877
+ * <motion.div onPan={onPan} />
1878
+ * ```
1879
+ *
1880
+ * @public
1827
1881
  */
1828
- getValue(key: string, defaultValue?: string | number): MotionValue<any>;
1882
+ point: Point;
1829
1883
  /**
1830
- * If we're trying to animate to a previously unencountered value,
1831
- * we need to check for it in our state and as a last resort read it
1832
- * directly from the instance (which might have performance implications).
1884
+ * Contains `x` and `y` values for the distance moved since
1885
+ * the last event.
1886
+ *
1887
+ * ```jsx
1888
+ * function onPan(event, info) {
1889
+ * console.log(info.delta.x, info.delta.y)
1890
+ * }
1891
+ *
1892
+ * <motion.div onPan={onPan} />
1893
+ * ```
1894
+ *
1895
+ * @public
1833
1896
  */
1834
- readValue(key: string): string | number | null | undefined;
1897
+ delta: Point;
1835
1898
  /**
1836
- * Set the base target to later animate back to. This is currently
1837
- * only hydrated on creation and when we first read a value.
1899
+ * Contains `x` and `y` values for the distance moved from
1900
+ * the first pan event.
1901
+ *
1902
+ * ```jsx
1903
+ * function onPan(event, info) {
1904
+ * console.log(info.offset.x, info.offset.y)
1905
+ * }
1906
+ *
1907
+ * <motion.div onPan={onPan} />
1908
+ * ```
1909
+ *
1910
+ * @public
1838
1911
  */
1839
- setBaseTarget(key: string, value: string | number): void;
1912
+ offset: Point;
1840
1913
  /**
1841
- * Find the base target for a value thats been removed from all animation
1842
- * props.
1914
+ * Contains `x` and `y` values for the current velocity of the pointer, in px/ms.
1915
+ *
1916
+ * ```jsx
1917
+ * function onPan(event, info) {
1918
+ * console.log(info.velocity.x, info.velocity.y)
1919
+ * }
1920
+ *
1921
+ * <motion.div onPan={onPan} />
1922
+ * ```
1923
+ *
1924
+ * @public
1843
1925
  */
1844
- getBaseTarget(key: string): any;
1845
- on<EventName extends keyof VisualElementEventCallbacks>(eventName: EventName, callback: VisualElementEventCallbacks[EventName]): VoidFunction;
1846
- notify<EventName extends keyof VisualElementEventCallbacks>(eventName: EventName, ...args: any): void;
1926
+ velocity: Point;
1847
1927
  }
1848
1928
 
1849
1929
  interface DragControlOptions {
@@ -3868,28 +3948,6 @@ declare function useTransform<I, O>(input: MotionValue<I>, transformer: SingleTr
3868
3948
  */
3869
3949
  declare function useTransform<I, O>(input: MotionValue<string>[] | MotionValue<number>[] | MotionValue<string | number>[], transformer: MultiTransformer<I, O>): MotionValue<O>;
3870
3950
 
3871
- interface Animation$1<V> {
3872
- next: (t: number) => {
3873
- value: V;
3874
- done: boolean;
3875
- };
3876
- flipTarget: () => void;
3877
- }
3878
- interface PhysicsSpringOptions {
3879
- velocity: number;
3880
- stiffness: number;
3881
- damping: number;
3882
- mass: number;
3883
- }
3884
- interface SpringOptions extends Partial<PhysicsSpringOptions> {
3885
- from?: number;
3886
- to?: number;
3887
- duration?: number;
3888
- bounce?: number;
3889
- restSpeed?: number;
3890
- restDelta?: number;
3891
- }
3892
-
3893
3951
  /**
3894
3952
  * Creates a `MotionValue` that, when `set`, will use a spring animation to animate to its new state.
3895
3953
  *
@@ -4231,6 +4289,9 @@ interface NativeAnimationOptions {
4231
4289
  delay?: number;
4232
4290
  duration?: number;
4233
4291
  ease?: EasingDefinition;
4292
+ times?: number[];
4293
+ repeat?: number;
4294
+ repeatType?: "loop" | "reverse" | "mirror";
4234
4295
  }
4235
4296
 
4236
4297
  declare function startOptimizedAppearAnimation(element: HTMLElement, name: string, keyframes: string[] | number[], options: NativeAnimationOptions): Animation | undefined;
@@ -4240,7 +4301,7 @@ declare const optimizedAppearDataAttribute: string;
4240
4301
  /**
4241
4302
  * This is based on the spring implementation of Wobble https://github.com/skevy/wobble
4242
4303
  */
4243
- declare function spring({ from, to, restSpeed, restDelta, ...options }: SpringOptions): Animation$1<number>;
4304
+ declare function spring({ keyframes, restSpeed, restDelta, ...options }: AnimationOptions<number>): Animation$1<number>;
4244
4305
  declare namespace spring {
4245
4306
  var needsInterpolation: (a: any, b: any) => boolean;
4246
4307
  }
@@ -4304,4 +4365,4 @@ interface ScaleMotionValues {
4304
4365
  */
4305
4366
  declare function useInvertedScale(scale?: Partial<ScaleMotionValues>): ScaleMotionValues;
4306
4367
 
4307
- export { AnimatePresence, AnimatePresenceProps, AnimateSharedLayout, AnimationControls, AnimationLifecycles, AnimationOptions$1 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 };
4368
+ 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 };