framer-motion 6.3.11 → 6.3.12

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 (230) hide show
  1. package/dist/cjs/index.js +2 -20
  2. package/dist/es/animation/use-animated-state.mjs +0 -1
  3. package/dist/es/animation/utils/transitions.mjs +0 -2
  4. package/dist/es/context/DeprecatedLayoutGroupContext.mjs +0 -1
  5. package/dist/es/context/LayoutGroupContext.mjs +0 -3
  6. package/dist/es/motion/index.mjs +0 -2
  7. package/dist/es/render/utils/animation.mjs +0 -3
  8. package/dist/es/render/utils/motion-values.mjs +1 -1
  9. package/dist/es/value/index.mjs +1 -4
  10. package/dist/es/value/use-inverted-scale.mjs +0 -1
  11. package/dist/es/value/utils/resolve-motion-value.mjs +0 -2
  12. package/dist/framer-motion.dev.js +2 -20
  13. package/dist/framer-motion.js +1 -1
  14. package/dist/index.d.ts +4118 -0
  15. package/dist/projection.dev.js +2 -9
  16. package/dist/size-rollup-dom-animation.js +1 -1
  17. package/dist/size-rollup-dom-max.js +1 -1
  18. package/dist/three-entry.d.ts +2428 -0
  19. package/package.json +4 -4
  20. package/types/animation/animate.d.ts +0 -54
  21. package/types/animation/animation-controls.d.ts +0 -5
  22. package/types/animation/types.d.ts +0 -79
  23. package/types/animation/use-animated-state.d.ts +0 -6
  24. package/types/animation/use-animation.d.ts +0 -31
  25. package/types/animation/utils/default-transitions.d.ts +0 -19
  26. package/types/animation/utils/easing.d.ts +0 -3
  27. package/types/animation/utils/is-animatable.d.ts +0 -11
  28. package/types/animation/utils/is-animation-controls.d.ts +0 -2
  29. package/types/animation/utils/is-keyframes-target.d.ts +0 -2
  30. package/types/animation/utils/transitions.d.ts +0 -29
  31. package/types/animation/utils/variant-resolvers.d.ts +0 -12
  32. package/types/components/AnimatePresence/PresenceChild.d.ts +0 -12
  33. package/types/components/AnimatePresence/index.d.ts +0 -36
  34. package/types/components/AnimatePresence/types.d.ts +0 -61
  35. package/types/components/AnimatePresence/use-presence.d.ts +0 -52
  36. package/types/components/AnimateSharedLayout.d.ts +0 -2
  37. package/types/components/LayoutGroup/index.d.ts +0 -12
  38. package/types/components/LazyMotion/index.d.ts +0 -38
  39. package/types/components/LazyMotion/types.d.ts +0 -54
  40. package/types/components/MotionConfig/index.d.ts +0 -25
  41. package/types/components/Reorder/Group.d.ts +0 -297
  42. package/types/components/Reorder/Item.d.ts +0 -278
  43. package/types/components/Reorder/index.d.ts +0 -509
  44. package/types/components/Reorder/types.d.ts +0 -10
  45. package/types/components/Reorder/utils/check-reorder.d.ts +0 -2
  46. package/types/context/DeprecatedLayoutGroupContext.d.ts +0 -6
  47. package/types/context/LayoutGroupContext.d.ts +0 -11
  48. package/types/context/LazyContext.d.ts +0 -7
  49. package/types/context/MotionConfigContext.d.ts +0 -36
  50. package/types/context/MotionContext/create.d.ts +0 -3
  51. package/types/context/MotionContext/index.d.ts +0 -9
  52. package/types/context/MotionContext/utils.d.ts +0 -3
  53. package/types/context/PresenceContext.d.ts +0 -17
  54. package/types/context/ReorderContext.d.ts +0 -3
  55. package/types/context/SwitchLayoutGroupContext.d.ts +0 -23
  56. package/types/events/event-info.d.ts +0 -5
  57. package/types/events/types.d.ts +0 -10
  58. package/types/events/use-dom-event.d.ts +0 -24
  59. package/types/events/use-pointer-event.d.ts +0 -4
  60. package/types/events/utils.d.ts +0 -3
  61. package/types/gestures/PanSession.d.ts +0 -127
  62. package/types/gestures/drag/VisualElementDragControls.d.ts +0 -56
  63. package/types/gestures/drag/types.d.ts +0 -294
  64. package/types/gestures/drag/use-drag-controls.d.ts +0 -74
  65. package/types/gestures/drag/use-drag.d.ts +0 -7
  66. package/types/gestures/drag/utils/constraints.d.ts +0 -77
  67. package/types/gestures/drag/utils/lock.d.ts +0 -4
  68. package/types/gestures/types.d.ts +0 -225
  69. package/types/gestures/use-focus-gesture.d.ts +0 -8
  70. package/types/gestures/use-hover-gesture.d.ts +0 -2
  71. package/types/gestures/use-pan-gesture.d.ts +0 -14
  72. package/types/gestures/use-tap-gesture.d.ts +0 -6
  73. package/types/gestures/utils/event-type.d.ts +0 -2
  74. package/types/gestures/utils/is-node-or-child.d.ts +0 -8
  75. package/types/index.d.ts +0 -96
  76. package/types/motion/features/animations.d.ts +0 -2
  77. package/types/motion/features/definitions.d.ts +0 -3
  78. package/types/motion/features/drag.d.ts +0 -2
  79. package/types/motion/features/gestures.d.ts +0 -2
  80. package/types/motion/features/layout/MeasureLayout.d.ts +0 -3
  81. package/types/motion/features/layout/index.d.ts +0 -2
  82. package/types/motion/features/layout/types.d.ts +0 -75
  83. package/types/motion/features/types.d.ts +0 -52
  84. package/types/motion/features/use-features.d.ts +0 -8
  85. package/types/motion/features/use-projection.d.ts +0 -3
  86. package/types/motion/features/viewport/observers.d.ts +0 -3
  87. package/types/motion/features/viewport/types.d.ts +0 -21
  88. package/types/motion/features/viewport/use-viewport.d.ts +0 -2
  89. package/types/motion/index.d.ts +0 -25
  90. package/types/motion/types.d.ts +0 -279
  91. package/types/motion/utils/VisualElementHandler.d.ts +0 -18
  92. package/types/motion/utils/is-forced-motion-value.d.ts +0 -2
  93. package/types/motion/utils/make-renderless-component.d.ts +0 -2
  94. package/types/motion/utils/should-inherit-variant.d.ts +0 -2
  95. package/types/motion/utils/use-motion-ref.d.ts +0 -8
  96. package/types/motion/utils/use-visual-element.d.ts +0 -6
  97. package/types/motion/utils/use-visual-state.d.ts +0 -14
  98. package/types/motion/utils/valid-prop.d.ts +0 -9
  99. package/types/projection/animation/mix-values.d.ts +0 -2
  100. package/types/projection/geometry/conversion.d.ts +0 -14
  101. package/types/projection/geometry/copy.d.ts +0 -13
  102. package/types/projection/geometry/delta-apply.d.ts +0 -37
  103. package/types/projection/geometry/delta-calc.d.ts +0 -10
  104. package/types/projection/geometry/delta-remove.d.ts +0 -20
  105. package/types/projection/geometry/models.d.ts +0 -5
  106. package/types/projection/geometry/types.d.ts +0 -29
  107. package/types/projection/geometry/utils.d.ts +0 -3
  108. package/types/projection/index.d.ts +0 -14
  109. package/types/projection/node/DocumentProjectionNode.d.ts +0 -108
  110. package/types/projection/node/HTMLProjectionNode.d.ts +0 -112
  111. package/types/projection/node/create-projection-node.d.ts +0 -301
  112. package/types/projection/node/group.d.ts +0 -7
  113. package/types/projection/node/id.d.ts +0 -1
  114. package/types/projection/node/types.d.ts +0 -136
  115. package/types/projection/shared/stack.d.ts +0 -17
  116. package/types/projection/styles/scale-border-radius.d.ts +0 -11
  117. package/types/projection/styles/scale-box-shadow.d.ts +0 -2
  118. package/types/projection/styles/scale-correction.d.ts +0 -3
  119. package/types/projection/styles/transform-origin.d.ts +0 -0
  120. package/types/projection/styles/transform.d.ts +0 -4
  121. package/types/projection/styles/types.d.ts +0 -9
  122. package/types/projection/use-instant-layout-transition.d.ts +0 -1
  123. package/types/projection/use-reset-projection.d.ts +0 -1
  124. package/types/projection/utils/each-axis.d.ts +0 -3
  125. package/types/projection/utils/has-transform.d.ts +0 -3
  126. package/types/projection/utils/measure.d.ts +0 -4
  127. package/types/render/dom/create-visual-element.d.ts +0 -2
  128. package/types/render/dom/features-animation.d.ts +0 -5
  129. package/types/render/dom/features-max.d.ts +0 -5
  130. package/types/render/dom/motion-minimal.d.ts +0 -5
  131. package/types/render/dom/motion-proxy.d.ts +0 -30
  132. package/types/render/dom/motion.d.ts +0 -25
  133. package/types/render/dom/types.d.ts +0 -28
  134. package/types/render/dom/use-render.d.ts +0 -4
  135. package/types/render/dom/utils/camel-to-dash.d.ts +0 -4
  136. package/types/render/dom/utils/create-config.d.ts +0 -8
  137. package/types/render/dom/utils/css-variables-conversion.d.ts +0 -22
  138. package/types/render/dom/utils/filter-props.d.ts +0 -4
  139. package/types/render/dom/utils/is-css-variable.d.ts +0 -4
  140. package/types/render/dom/utils/is-svg-component.d.ts +0 -2
  141. package/types/render/dom/utils/parse-dom-variant.d.ts +0 -6
  142. package/types/render/dom/utils/unit-conversion.d.ts +0 -27
  143. package/types/render/dom/value-types/animatable-none.d.ts +0 -1
  144. package/types/render/dom/value-types/defaults.d.ts +0 -9
  145. package/types/render/dom/value-types/dimensions.d.ts +0 -8
  146. package/types/render/dom/value-types/find.d.ts +0 -9
  147. package/types/render/dom/value-types/get-as-type.d.ts +0 -5
  148. package/types/render/dom/value-types/number.d.ts +0 -2
  149. package/types/render/dom/value-types/test.d.ts +0 -5
  150. package/types/render/dom/value-types/type-auto.d.ts +0 -5
  151. package/types/render/dom/value-types/type-int.d.ts +0 -8
  152. package/types/render/dom/value-types/types.d.ts +0 -4
  153. package/types/render/html/config-motion.d.ts +0 -3
  154. package/types/render/html/supported-elements.d.ts +0 -7
  155. package/types/render/html/types.d.ts +0 -61
  156. package/types/render/html/use-props.d.ts +0 -8
  157. package/types/render/html/utils/build-styles.d.ts +0 -5
  158. package/types/render/html/utils/build-transform.d.ts +0 -15
  159. package/types/render/html/utils/create-render-state.d.ts +0 -7
  160. package/types/render/html/utils/render.d.ts +0 -4
  161. package/types/render/html/utils/scrape-motion-values.d.ts +0 -2
  162. package/types/render/html/utils/transform.d.ts +0 -15
  163. package/types/render/html/visual-element.d.ts +0 -6
  164. package/types/render/index.d.ts +0 -2
  165. package/types/render/svg/config-motion.d.ts +0 -3
  166. package/types/render/svg/lowercase-elements.d.ts +0 -5
  167. package/types/render/svg/supported-elements.d.ts +0 -7
  168. package/types/render/svg/types.d.ts +0 -44
  169. package/types/render/svg/use-props.d.ts +0 -7
  170. package/types/render/svg/utils/build-attrs.d.ts +0 -8
  171. package/types/render/svg/utils/camel-case-attrs.d.ts +0 -4
  172. package/types/render/svg/utils/create-render-state.d.ts +0 -2
  173. package/types/render/svg/utils/path.d.ts +0 -9
  174. package/types/render/svg/utils/render.d.ts +0 -4
  175. package/types/render/svg/utils/scrape-motion-values.d.ts +0 -2
  176. package/types/render/svg/utils/transform-origin.d.ts +0 -6
  177. package/types/render/svg/visual-element.d.ts +0 -2
  178. package/types/render/types.d.ts +0 -113
  179. package/types/render/utils/animation-state.d.ts +0 -31
  180. package/types/render/utils/animation.d.ts +0 -21
  181. package/types/render/utils/compare-by-depth.d.ts +0 -5
  182. package/types/render/utils/flat-tree.d.ts +0 -8
  183. package/types/render/utils/is-draggable.d.ts +0 -2
  184. package/types/render/utils/lifecycles.d.ts +0 -114
  185. package/types/render/utils/motion-values.d.ts +0 -3
  186. package/types/render/utils/setters.d.ts +0 -792
  187. package/types/render/utils/types.d.ts +0 -9
  188. package/types/render/utils/variants.d.ts +0 -20
  189. package/types/three-entry.d.ts +0 -19
  190. package/types/types.d.ts +0 -981
  191. package/types/utils/array.d.ts +0 -3
  192. package/types/utils/each-axis.d.ts +0 -1
  193. package/types/utils/is-browser.d.ts +0 -1
  194. package/types/utils/is-numerical-string.d.ts +0 -4
  195. package/types/utils/is-ref-object.d.ts +0 -2
  196. package/types/utils/is-zero-value-string.d.ts +0 -4
  197. package/types/utils/noop.d.ts +0 -1
  198. package/types/utils/process.d.ts +0 -1
  199. package/types/utils/resolve-value.d.ts +0 -3
  200. package/types/utils/shallow-compare.d.ts +0 -1
  201. package/types/utils/subscription-manager.d.ts +0 -9
  202. package/types/utils/time-conversion.d.ts +0 -7
  203. package/types/utils/transform.d.ts +0 -91
  204. package/types/utils/use-animation-frame.d.ts +0 -2
  205. package/types/utils/use-constant.d.ts +0 -10
  206. package/types/utils/use-cycle.d.ts +0 -30
  207. package/types/utils/use-force-update.d.ts +0 -1
  208. package/types/utils/use-id.d.ts +0 -6
  209. package/types/utils/use-instant-transition-state.d.ts +0 -3
  210. package/types/utils/use-instant-transition.d.ts +0 -1
  211. package/types/utils/use-is-mounted.d.ts +0 -2
  212. package/types/utils/use-isomorphic-effect.d.ts +0 -2
  213. package/types/utils/use-reduced-motion.d.ts +0 -28
  214. package/types/utils/use-unmount-effect.d.ts +0 -1
  215. package/types/utils/warn-once.d.ts +0 -2
  216. package/types/value/index.d.ts +0 -260
  217. package/types/value/scroll/use-element-scroll.d.ts +0 -28
  218. package/types/value/scroll/use-viewport-scroll.d.ts +0 -22
  219. package/types/value/scroll/utils.d.ts +0 -19
  220. package/types/value/use-combine-values.d.ts +0 -2
  221. package/types/value/use-inverted-scale.d.ts +0 -28
  222. package/types/value/use-motion-template.d.ts +0 -24
  223. package/types/value/use-motion-value.d.ts +0 -19
  224. package/types/value/use-on-change.d.ts +0 -3
  225. package/types/value/use-spring.d.ts +0 -22
  226. package/types/value/use-time.d.ts +0 -1
  227. package/types/value/use-transform.d.ts +0 -93
  228. package/types/value/use-velocity.d.ts +0 -13
  229. package/types/value/utils/is-motion-value.d.ts +0 -2
  230. package/types/value/utils/resolve-motion-value.d.ts +0 -10
@@ -1,3 +0,0 @@
1
- export declare function addUniqueItem<T>(arr: T[], item: T): void;
2
- export declare function removeItem<T>(arr: T[], item: T): void;
3
- export declare function moveItem<T>([...arr]: T[], fromIndex: number, toIndex: number): T[];
@@ -1 +0,0 @@
1
- export declare function eachAxis<T>(handler: (axis: "x" | "y") => T): T[];
@@ -1 +0,0 @@
1
- export declare const isBrowser: boolean;
@@ -1,4 +0,0 @@
1
- /**
2
- * Check if value is a numerical string, ie a string that is purely a number eg "100" or "-100.1"
3
- */
4
- export declare const isNumericalString: (v: string) => boolean;
@@ -1,2 +0,0 @@
1
- import { MutableRefObject } from "react";
2
- export declare function isRefObject<E = any>(ref: any): ref is MutableRefObject<E>;
@@ -1,4 +0,0 @@
1
- /**
2
- * Check if the value is a zero value string like "0px" or "0%"
3
- */
4
- export declare const isZeroValueString: (v: string) => boolean;
@@ -1 +0,0 @@
1
- export declare function noop<T>(any: T): T;
@@ -1 +0,0 @@
1
- export declare const env: string;
@@ -1,3 +0,0 @@
1
- import { CustomValueType, ValueTarget, SingleTarget } from "../types";
2
- export declare const isCustomValue: (v: any) => v is CustomValueType;
3
- export declare const resolveFinalValueInKeyframes: (v: ValueTarget) => SingleTarget;
@@ -1 +0,0 @@
1
- export declare function shallowCompare(next: any[], prev: any[] | null): boolean;
@@ -1,9 +0,0 @@
1
- declare type GenericHandler = (...args: any) => void;
2
- export declare class SubscriptionManager<Handler extends GenericHandler> {
3
- private subscriptions;
4
- add(handler: Handler): () => void;
5
- notify(a?: Parameters<Handler>[0], b?: Parameters<Handler>[1], c?: Parameters<Handler>[2]): void;
6
- getSize(): number;
7
- clear(): void;
8
- }
9
- export {};
@@ -1,7 +0,0 @@
1
- /**
2
- * Converts seconds to milliseconds
3
- *
4
- * @param seconds - Time in seconds.
5
- * @return milliseconds - Converted time in milliseconds.
6
- */
7
- export declare const secondsToMilliseconds: (seconds: number) => number;
@@ -1,91 +0,0 @@
1
- import { Easing } from "popmotion";
2
- /**
3
- * @public
4
- */
5
- export interface TransformOptions<T> {
6
- /**
7
- * Clamp values to within the given range. Defaults to `true`
8
- *
9
- * @public
10
- */
11
- clamp?: boolean;
12
- /**
13
- * Easing functions to use on the interpolations between each value in the input and output ranges.
14
- *
15
- * 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.
16
- *
17
- * @public
18
- */
19
- ease?: Easing | Easing[];
20
- /**
21
- * @internal
22
- */
23
- mixer?: (from: T, to: T) => (v: number) => any;
24
- }
25
- /**
26
- * Transforms numbers into other values by mapping them from an input range to an output range.
27
- * Returns the type of the input provided.
28
- *
29
- * @remarks
30
- *
31
- * Given an input range of `[0, 200]` and an output range of
32
- * `[0, 1]`, this function will return a value between `0` and `1`.
33
- * The input range must be a linear series of numbers. The output range
34
- * can be any supported value type, such as numbers, colors, shadows, arrays, objects and more.
35
- * Every value in the output range must be of the same type and in the same format.
36
- *
37
- * ```jsx
38
- * import * as React from "react"
39
- * import { transform } from "framer-motion"
40
- *
41
- * export function MyComponent() {
42
- * const inputRange = [0, 200]
43
- * const outputRange = [0, 1]
44
- * const output = transform(100, inputRange, outputRange)
45
- *
46
- * // Returns 0.5
47
- * return <div>{output}</div>
48
- * }
49
- * ```
50
- *
51
- * @param inputValue - A number to transform between the input and output ranges.
52
- * @param inputRange - A linear series of numbers (either all increasing or decreasing).
53
- * @param outputRange - A series of numbers, colors, strings, or arrays/objects of those. Must be the same length as `inputRange`.
54
- * @param options - Clamp: Clamp values to within the given range. Defaults to `true`.
55
- *
56
- * @public
57
- */
58
- export declare function transform<T>(inputValue: number, inputRange: number[], outputRange: T[], options?: TransformOptions<T>): T;
59
- /**
60
- *
61
- * Transforms numbers into other values by mapping them from an input range to an output range.
62
- *
63
- * Given an input range of `[0, 200]` and an output range of
64
- * `[0, 1]`, this function will return a value between `0` and `1`.
65
- * The input range must be a linear series of numbers. The output range
66
- * can be any supported value type, such as numbers, colors, shadows, arrays, objects and more.
67
- * Every value in the output range must be of the same type and in the same format.
68
- *
69
- * ```jsx
70
- * import * as React from "react"
71
- * import { Frame, transform } from "framer"
72
- *
73
- * export function MyComponent() {
74
- * const inputRange = [-200, -100, 100, 200]
75
- * const outputRange = [0, 1, 1, 0]
76
- * const convertRange = transform(inputRange, outputRange)
77
- * const output = convertRange(-150)
78
- *
79
- * // Returns 0.5
80
- * return <div>{output}</div>
81
- * }
82
- *
83
- * ```
84
- *
85
- * @param inputRange - A linear series of numbers (either all increasing or decreasing).
86
- * @param outputRange - A series of numbers, colors or strings. Must be the same length as `inputRange`.
87
- * @param options - Clamp: clamp values to within the given range. Defaults to `true`.
88
- *
89
- * @public
90
- */
91
- export declare function transform<T>(inputRange: number[], outputRange: T[], options?: TransformOptions<T>): (inputValue: number) => T;
@@ -1,2 +0,0 @@
1
- export declare type FrameCallback = (timestamp: number) => void;
2
- export declare function useAnimationFrame(callback: FrameCallback): void;
@@ -1,10 +0,0 @@
1
- declare type Init<T> = () => T;
2
- /**
3
- * Creates a constant value over the lifecycle of a component.
4
- *
5
- * Even if `useMemo` is provided an empty array as its final argument, it doesn't offer
6
- * a guarantee that it won't re-run for performance reasons later on. By using `useConstant`
7
- * you can ensure that initialisers don't execute twice or more.
8
- */
9
- export declare function useConstant<T>(init: Init<T>): T;
10
- export {};
@@ -1,30 +0,0 @@
1
- declare type Cycle = (i?: number) => void;
2
- declare type CycleState<T> = [T, Cycle];
3
- /**
4
- * 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.
5
- *
6
- * An index value can be passed to the returned `cycle` function to cycle to a specific index.
7
- *
8
- * ```jsx
9
- * import * as React from "react"
10
- * import { motion, useCycle } from "framer-motion"
11
- *
12
- * export const MyComponent = () => {
13
- * const [x, cycleX] = useCycle(0, 50, 100)
14
- *
15
- * return (
16
- * <motion.div
17
- * animate={{ x: x }}
18
- * onTap={() => cycleX()}
19
- * />
20
- * )
21
- * }
22
- * ```
23
- *
24
- * @param items - items to cycle through
25
- * @returns [currentState, cycleState]
26
- *
27
- * @public
28
- */
29
- export declare function useCycle<T>(...items: T[]): CycleState<T>;
30
- export {};
@@ -1 +0,0 @@
1
- export declare function useForceUpdate(): [VoidFunction, number];
@@ -1,6 +0,0 @@
1
- export declare const useId: () => number;
2
- /**
3
- * Ideally we'd use the following code to support React 18 optionally.
4
- * But this fairly fails in Webpack (otherwise treeshaking wouldn't work at all).
5
- * Need to come up with a different way of figuring this out.
6
- */
@@ -1,3 +0,0 @@
1
- export declare const instantAnimationState: {
2
- current: boolean;
3
- };
@@ -1 +0,0 @@
1
- export declare function useInstantTransition(): (callback: () => void) => void;
@@ -1,2 +0,0 @@
1
- /// <reference types="react" />
2
- export declare function useIsMounted(): import("react").MutableRefObject<boolean>;
@@ -1,2 +0,0 @@
1
- import { useEffect } from "react";
2
- export declare const useIsomorphicLayoutEffect: typeof useEffect;
@@ -1,28 +0,0 @@
1
- /**
2
- * A hook that returns `true` if we should be using reduced motion based on the current device's Reduced Motion setting.
3
- *
4
- * This can be used to implement changes to your UI based on Reduced Motion. For instance, replacing motion-sickness inducing
5
- * `x`/`y` animations with `opacity`, disabling the autoplay of background videos, or turning off parallax motion.
6
- *
7
- * It will actively respond to changes and re-render your components with the latest setting.
8
- *
9
- * ```jsx
10
- * export function Sidebar({ isOpen }) {
11
- * const shouldReduceMotion = useReducedMotion()
12
- * const closedX = shouldReduceMotion ? 0 : "-100%"
13
- *
14
- * return (
15
- * <motion.div animate={{
16
- * opacity: isOpen ? 1 : 0,
17
- * x: isOpen ? 0 : closedX
18
- * }} />
19
- * )
20
- * }
21
- * ```
22
- *
23
- * @return boolean
24
- *
25
- * @public
26
- */
27
- export declare function useReducedMotion(): boolean | null;
28
- export declare function useReducedMotionConfig(): boolean | null;
@@ -1 +0,0 @@
1
- export declare function useUnmountEffect(callback: () => void): void;
@@ -1,2 +0,0 @@
1
- export declare function hasWarned(message: string): boolean;
2
- export declare function warnOnce(condition: boolean, message: string, element?: Element): void;
@@ -1,260 +0,0 @@
1
- import { SubscriptionManager } from "../utils/subscription-manager";
2
- export declare type Transformer<T> = (v: T) => T;
3
- /**
4
- * @public
5
- */
6
- export declare type Subscriber<T> = (v: T) => void;
7
- /**
8
- * @public
9
- */
10
- export declare type PassiveEffect<T> = (v: T, safeSetter: (v: T) => void) => void;
11
- export declare type StartAnimation = (complete: () => void) => () => void;
12
- /**
13
- * `MotionValue` is used to track the state and velocity of motion values.
14
- *
15
- * @public
16
- */
17
- export declare class MotionValue<V = any> {
18
- /**
19
- * This will be replaced by the build step with the latest version number.
20
- * When MotionValues are provided to motion components, warn if versions are mixed.
21
- */
22
- version: string;
23
- /**
24
- * The current state of the `MotionValue`.
25
- *
26
- * @internal
27
- */
28
- private current;
29
- /**
30
- * The previous state of the `MotionValue`.
31
- *
32
- * @internal
33
- */
34
- private prev;
35
- /**
36
- * Duration, in milliseconds, since last updating frame.
37
- *
38
- * @internal
39
- */
40
- private timeDelta;
41
- /**
42
- * Timestamp of the last time this `MotionValue` was updated.
43
- *
44
- * @internal
45
- */
46
- private lastUpdated;
47
- /**
48
- * Functions to notify when the `MotionValue` updates.
49
- *
50
- * @internal
51
- */
52
- private updateSubscribers;
53
- /**
54
- * Functions to notify when the velocity updates.
55
- *
56
- * @internal
57
- */
58
- velocityUpdateSubscribers: SubscriptionManager<Subscriber<number>>;
59
- /**
60
- * Functions to notify when the `MotionValue` updates and `render` is set to `true`.
61
- *
62
- * @internal
63
- */
64
- private renderSubscribers;
65
- /**
66
- * Add a passive effect to this `MotionValue`.
67
- *
68
- * A passive effect intercepts calls to `set`. For instance, `useSpring` adds
69
- * a passive effect that attaches a `spring` to the latest
70
- * set value. Hypothetically there could be a `useSmooth` that attaches an input smoothing effect.
71
- *
72
- * @internal
73
- */
74
- private passiveEffect?;
75
- /**
76
- * A reference to the currently-controlling Popmotion animation
77
- *
78
- * @internal
79
- */
80
- private stopAnimation?;
81
- /**
82
- * Tracks whether this value can output a velocity. Currently this is only true
83
- * if the value is numerical, but we might be able to widen the scope here and support
84
- * other value types.
85
- *
86
- * @internal
87
- */
88
- private canTrackVelocity;
89
- /**
90
- * @param init - The initiating value
91
- * @param config - Optional configuration options
92
- *
93
- * - `transformer`: A function to transform incoming values with.
94
- *
95
- * @internal
96
- */
97
- constructor(init: V);
98
- /**
99
- * Adds a function that will be notified when the `MotionValue` is updated.
100
- *
101
- * It returns a function that, when called, will cancel the subscription.
102
- *
103
- * When calling `onChange` inside a React component, it should be wrapped with the
104
- * `useEffect` hook. As it returns an unsubscribe function, this should be returned
105
- * from the `useEffect` function to ensure you don't add duplicate subscribers..
106
- *
107
- * ```jsx
108
- * export const MyComponent = () => {
109
- * const x = useMotionValue(0)
110
- * const y = useMotionValue(0)
111
- * const opacity = useMotionValue(1)
112
- *
113
- * useEffect(() => {
114
- * function updateOpacity() {
115
- * const maxXY = Math.max(x.get(), y.get())
116
- * const newOpacity = transform(maxXY, [0, 100], [1, 0])
117
- * opacity.set(newOpacity)
118
- * }
119
- *
120
- * const unsubscribeX = x.onChange(updateOpacity)
121
- * const unsubscribeY = y.onChange(updateOpacity)
122
- *
123
- * return () => {
124
- * unsubscribeX()
125
- * unsubscribeY()
126
- * }
127
- * }, [])
128
- *
129
- * return <motion.div style={{ x }} />
130
- * }
131
- * ```
132
- *
133
- * @internalremarks
134
- *
135
- * We could look into a `useOnChange` hook if the above lifecycle management proves confusing.
136
- *
137
- * ```jsx
138
- * useOnChange(x, () => {})
139
- * ```
140
- *
141
- * @param subscriber - A function that receives the latest value.
142
- * @returns A function that, when called, will cancel this subscription.
143
- *
144
- * @public
145
- */
146
- onChange(subscription: Subscriber<V>): () => void;
147
- clearListeners(): void;
148
- /**
149
- * Adds a function that will be notified when the `MotionValue` requests a render.
150
- *
151
- * @param subscriber - A function that's provided the latest value.
152
- * @returns A function that, when called, will cancel this subscription.
153
- *
154
- * @internal
155
- */
156
- onRenderRequest(subscription: Subscriber<V>): () => void;
157
- /**
158
- * Attaches a passive effect to the `MotionValue`.
159
- *
160
- * @internal
161
- */
162
- attach(passiveEffect: PassiveEffect<V>): void;
163
- /**
164
- * Sets the state of the `MotionValue`.
165
- *
166
- * @remarks
167
- *
168
- * ```jsx
169
- * const x = useMotionValue(0)
170
- * x.set(10)
171
- * ```
172
- *
173
- * @param latest - Latest value to set.
174
- * @param render - Whether to notify render subscribers. Defaults to `true`
175
- *
176
- * @public
177
- */
178
- set(v: V, render?: boolean): void;
179
- updateAndNotify: (v: V, render?: boolean) => void;
180
- /**
181
- * Returns the latest state of `MotionValue`
182
- *
183
- * @returns - The latest state of `MotionValue`
184
- *
185
- * @public
186
- */
187
- get(): V;
188
- /**
189
- * @public
190
- */
191
- getPrevious(): V;
192
- /**
193
- * Returns the latest velocity of `MotionValue`
194
- *
195
- * @returns - The latest velocity of `MotionValue`. Returns `0` if the state is non-numerical.
196
- *
197
- * @public
198
- */
199
- getVelocity(): number;
200
- /**
201
- * Schedule a velocity check for the next frame.
202
- *
203
- * This is an instanced and bound function to prevent generating a new
204
- * function once per frame.
205
- *
206
- * @internal
207
- */
208
- private scheduleVelocityCheck;
209
- /**
210
- * Updates `prev` with `current` if the value hasn't been updated this frame.
211
- * This ensures velocity calculations return `0`.
212
- *
213
- * This is an instanced and bound function to prevent generating a new
214
- * function once per frame.
215
- *
216
- * @internal
217
- */
218
- private velocityCheck;
219
- hasAnimated: boolean;
220
- /**
221
- * Registers a new animation to control this `MotionValue`. Only one
222
- * animation can drive a `MotionValue` at one time.
223
- *
224
- * ```jsx
225
- * value.start()
226
- * ```
227
- *
228
- * @param animation - A function that starts the provided animation
229
- *
230
- * @internal
231
- */
232
- start(animation: StartAnimation): Promise<void>;
233
- /**
234
- * Stop the currently active animation.
235
- *
236
- * @public
237
- */
238
- stop(): void;
239
- /**
240
- * Returns `true` if this value is currently animating.
241
- *
242
- * @public
243
- */
244
- isAnimating(): boolean;
245
- private clearAnimation;
246
- /**
247
- * Destroy and clean up subscribers to this `MotionValue`.
248
- *
249
- * The `MotionValue` hooks like `useMotionValue` and `useTransform` automatically
250
- * handle the lifecycle of the returned `MotionValue`, so this method is only necessary if you've manually
251
- * created a `MotionValue` via the `motionValue` function.
252
- *
253
- * @public
254
- */
255
- destroy(): void;
256
- }
257
- /**
258
- * @internal
259
- */
260
- export declare function motionValue<V>(init: V): MotionValue<V>;
@@ -1,28 +0,0 @@
1
- import { RefObject } from "react";
2
- import { ScrollMotionValues } from "./utils";
3
- /**
4
- * Returns MotionValues that update when the provided element scrolls:
5
- *
6
- * - `scrollX` — Horizontal scroll distance in pixels.
7
- * - `scrollY` — Vertical scroll distance in pixels.
8
- * - `scrollXProgress` — Horizontal scroll progress between `0` and `1`.
9
- * - `scrollYProgress` — Vertical scroll progress between `0` and `1`.
10
- *
11
- * This element must be set to `overflow: scroll` on either or both axes to report scroll offset.
12
- *
13
- * ```jsx
14
- * export const MyComponent = () => {
15
- * const ref = useRef()
16
- * const { scrollYProgress } = useElementScroll(ref)
17
- *
18
- * return (
19
- * <div ref={ref}>
20
- * <motion.div style={{ scaleX: scrollYProgress }} />
21
- * </div>
22
- * )
23
- * }
24
- * ```
25
- *
26
- * @public
27
- */
28
- export declare function useElementScroll(ref: RefObject<HTMLElement>): ScrollMotionValues;
@@ -1,22 +0,0 @@
1
- import { ScrollMotionValues } from "./utils";
2
- /**
3
- * Returns MotionValues that update when the viewport scrolls:
4
- *
5
- * - `scrollX` — Horizontal scroll distance in pixels.
6
- * - `scrollY` — Vertical scroll distance in pixels.
7
- * - `scrollXProgress` — Horizontal scroll progress between `0` and `1`.
8
- * - `scrollYProgress` — Vertical scroll progress between `0` and `1`.
9
- *
10
- * **Warning:** Setting `body` or `html` to `height: 100%` or similar will break the `Progress`
11
- * values as this breaks the browser's capability to accurately measure the page length.
12
- *
13
- * ```jsx
14
- * export const MyComponent = () => {
15
- * const { scrollYProgress } = useViewportScroll()
16
- * return <motion.div style={{ scaleX: scrollYProgress }} />
17
- * }
18
- * ```
19
- *
20
- * @public
21
- */
22
- export declare function useViewportScroll(): ScrollMotionValues;
@@ -1,19 +0,0 @@
1
- import { MotionValue } from "../";
2
- /**
3
- * @public
4
- */
5
- export interface ScrollMotionValues {
6
- scrollX: MotionValue<number>;
7
- scrollY: MotionValue<number>;
8
- scrollXProgress: MotionValue<number>;
9
- scrollYProgress: MotionValue<number>;
10
- }
11
- export interface ScrollOffsets {
12
- xOffset: number;
13
- yOffset: number;
14
- xMaxOffset: number;
15
- yMaxOffset: number;
16
- }
17
- export declare type GetScrollOffsets = () => ScrollOffsets;
18
- export declare function createScrollMotionValues(): ScrollMotionValues;
19
- export declare function createScrollUpdater(values: ScrollMotionValues, getOffsets: GetScrollOffsets): () => void;
@@ -1,2 +0,0 @@
1
- import { MotionValue } from ".";
2
- export declare function useCombineMotionValues<R>(values: MotionValue[], combineValues: () => R): MotionValue<R>;
@@ -1,28 +0,0 @@
1
- import { MotionValue } from "./";
2
- interface ScaleMotionValues {
3
- scaleX: MotionValue<number>;
4
- scaleY: MotionValue<number>;
5
- }
6
- export declare const invertScale: (scale: number) => number;
7
- /**
8
- * Returns a `MotionValue` each for `scaleX` and `scaleY` that update with the inverse
9
- * of their respective parent scales.
10
- *
11
- * This is useful for undoing the distortion of content when scaling a parent component.
12
- *
13
- * By default, `useInvertedScale` will automatically fetch `scaleX` and `scaleY` from the nearest parent.
14
- * By passing other `MotionValue`s in as `useInvertedScale({ scaleX, scaleY })`, it will invert the output
15
- * of those instead.
16
- *
17
- * ```jsx
18
- * const MyComponent = () => {
19
- * const { scaleX, scaleY } = useInvertedScale()
20
- * return <motion.div style={{ scaleX, scaleY }} />
21
- * }
22
- * ```
23
- *
24
- * @deprecated
25
- * @internal
26
- */
27
- export declare function useInvertedScale(scale?: Partial<ScaleMotionValues>): ScaleMotionValues;
28
- export {};
@@ -1,24 +0,0 @@
1
- import { MotionValue } from ".";
2
- /**
3
- * Combine multiple motion values into a new one using a string template literal.
4
- *
5
- * ```jsx
6
- * import {
7
- * motion,
8
- * useSpring,
9
- * useMotionValue,
10
- * useMotionTemplate
11
- * } from "framer-motion"
12
- *
13
- * function Component() {
14
- * const shadowX = useSpring(0)
15
- * const shadowY = useMotionValue(0)
16
- * const shadow = useMotionTemplate`drop-shadow(${shadowX}px ${shadowY}px 20px rgba(0,0,0,0.3))`
17
- *
18
- * return <motion.div style={{ filter: shadow }} />
19
- * }
20
- * ```
21
- *
22
- * @public
23
- */
24
- export declare function useMotionTemplate(fragments: TemplateStringsArray, ...values: MotionValue[]): MotionValue<string>;
@@ -1,19 +0,0 @@
1
- import { MotionValue } from ".";
2
- /**
3
- * Creates a `MotionValue` to track the state and velocity of a value.
4
- *
5
- * 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.
6
- *
7
- * ```jsx
8
- * export const MyComponent = () => {
9
- * const scale = useMotionValue(1)
10
- *
11
- * return <motion.div style={{ scale }} />
12
- * }
13
- * ```
14
- *
15
- * @param initial - The initial state.
16
- *
17
- * @public
18
- */
19
- export declare function useMotionValue<T>(initial: T): MotionValue<T>;