framer-motion 6.3.10 → 6.3.13

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 (234) hide show
  1. package/dist/cjs/index.js +18 -25
  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/gestures/use-pan-gesture.mjs +1 -1
  7. package/dist/es/motion/index.mjs +0 -2
  8. package/dist/es/motion/utils/valid-prop.mjs +1 -1
  9. package/dist/es/projection/styles/transform.mjs +13 -2
  10. package/dist/es/render/utils/animation.mjs +0 -3
  11. package/dist/es/render/utils/motion-values.mjs +1 -1
  12. package/dist/es/value/index.mjs +2 -5
  13. package/dist/es/value/use-inverted-scale.mjs +0 -1
  14. package/dist/es/value/utils/resolve-motion-value.mjs +0 -2
  15. package/dist/framer-motion.dev.js +18 -25
  16. package/dist/framer-motion.js +1 -1
  17. package/dist/index.d.ts +4188 -0
  18. package/dist/projection.dev.js +16 -12
  19. package/dist/size-rollup-dom-animation.js +1 -1
  20. package/dist/size-rollup-dom-max.js +1 -1
  21. package/dist/size-webpack-dom-max.js +1 -1
  22. package/dist/three-entry.d.ts +2502 -0
  23. package/package.json +5 -5
  24. package/types/animation/animate.d.ts +0 -54
  25. package/types/animation/animation-controls.d.ts +0 -5
  26. package/types/animation/types.d.ts +0 -79
  27. package/types/animation/use-animated-state.d.ts +0 -6
  28. package/types/animation/use-animation.d.ts +0 -31
  29. package/types/animation/utils/default-transitions.d.ts +0 -19
  30. package/types/animation/utils/easing.d.ts +0 -3
  31. package/types/animation/utils/is-animatable.d.ts +0 -11
  32. package/types/animation/utils/is-animation-controls.d.ts +0 -2
  33. package/types/animation/utils/is-keyframes-target.d.ts +0 -2
  34. package/types/animation/utils/transitions.d.ts +0 -29
  35. package/types/animation/utils/variant-resolvers.d.ts +0 -12
  36. package/types/components/AnimatePresence/PresenceChild.d.ts +0 -12
  37. package/types/components/AnimatePresence/index.d.ts +0 -36
  38. package/types/components/AnimatePresence/types.d.ts +0 -61
  39. package/types/components/AnimatePresence/use-presence.d.ts +0 -52
  40. package/types/components/AnimateSharedLayout.d.ts +0 -2
  41. package/types/components/LayoutGroup/index.d.ts +0 -12
  42. package/types/components/LazyMotion/index.d.ts +0 -38
  43. package/types/components/LazyMotion/types.d.ts +0 -54
  44. package/types/components/MotionConfig/index.d.ts +0 -25
  45. package/types/components/Reorder/Group.d.ts +0 -297
  46. package/types/components/Reorder/Item.d.ts +0 -278
  47. package/types/components/Reorder/index.d.ts +0 -509
  48. package/types/components/Reorder/types.d.ts +0 -10
  49. package/types/components/Reorder/utils/check-reorder.d.ts +0 -2
  50. package/types/context/DeprecatedLayoutGroupContext.d.ts +0 -6
  51. package/types/context/LayoutGroupContext.d.ts +0 -11
  52. package/types/context/LazyContext.d.ts +0 -7
  53. package/types/context/MotionConfigContext.d.ts +0 -36
  54. package/types/context/MotionContext/create.d.ts +0 -3
  55. package/types/context/MotionContext/index.d.ts +0 -9
  56. package/types/context/MotionContext/utils.d.ts +0 -3
  57. package/types/context/PresenceContext.d.ts +0 -17
  58. package/types/context/ReorderContext.d.ts +0 -3
  59. package/types/context/SwitchLayoutGroupContext.d.ts +0 -23
  60. package/types/events/event-info.d.ts +0 -5
  61. package/types/events/types.d.ts +0 -10
  62. package/types/events/use-dom-event.d.ts +0 -24
  63. package/types/events/use-pointer-event.d.ts +0 -4
  64. package/types/events/utils.d.ts +0 -3
  65. package/types/gestures/PanSession.d.ts +0 -127
  66. package/types/gestures/drag/VisualElementDragControls.d.ts +0 -56
  67. package/types/gestures/drag/types.d.ts +0 -294
  68. package/types/gestures/drag/use-drag-controls.d.ts +0 -74
  69. package/types/gestures/drag/use-drag.d.ts +0 -7
  70. package/types/gestures/drag/utils/constraints.d.ts +0 -77
  71. package/types/gestures/drag/utils/lock.d.ts +0 -4
  72. package/types/gestures/types.d.ts +0 -225
  73. package/types/gestures/use-focus-gesture.d.ts +0 -8
  74. package/types/gestures/use-hover-gesture.d.ts +0 -2
  75. package/types/gestures/use-pan-gesture.d.ts +0 -14
  76. package/types/gestures/use-tap-gesture.d.ts +0 -6
  77. package/types/gestures/utils/event-type.d.ts +0 -2
  78. package/types/gestures/utils/is-node-or-child.d.ts +0 -8
  79. package/types/index.d.ts +0 -96
  80. package/types/motion/features/animations.d.ts +0 -2
  81. package/types/motion/features/definitions.d.ts +0 -3
  82. package/types/motion/features/drag.d.ts +0 -2
  83. package/types/motion/features/gestures.d.ts +0 -2
  84. package/types/motion/features/layout/MeasureLayout.d.ts +0 -3
  85. package/types/motion/features/layout/index.d.ts +0 -2
  86. package/types/motion/features/layout/types.d.ts +0 -75
  87. package/types/motion/features/types.d.ts +0 -52
  88. package/types/motion/features/use-features.d.ts +0 -8
  89. package/types/motion/features/use-projection.d.ts +0 -3
  90. package/types/motion/features/viewport/observers.d.ts +0 -3
  91. package/types/motion/features/viewport/types.d.ts +0 -21
  92. package/types/motion/features/viewport/use-viewport.d.ts +0 -2
  93. package/types/motion/index.d.ts +0 -25
  94. package/types/motion/types.d.ts +0 -279
  95. package/types/motion/utils/VisualElementHandler.d.ts +0 -18
  96. package/types/motion/utils/is-forced-motion-value.d.ts +0 -2
  97. package/types/motion/utils/make-renderless-component.d.ts +0 -2
  98. package/types/motion/utils/should-inherit-variant.d.ts +0 -2
  99. package/types/motion/utils/use-motion-ref.d.ts +0 -8
  100. package/types/motion/utils/use-visual-element.d.ts +0 -6
  101. package/types/motion/utils/use-visual-state.d.ts +0 -14
  102. package/types/motion/utils/valid-prop.d.ts +0 -9
  103. package/types/projection/animation/mix-values.d.ts +0 -2
  104. package/types/projection/geometry/conversion.d.ts +0 -14
  105. package/types/projection/geometry/copy.d.ts +0 -13
  106. package/types/projection/geometry/delta-apply.d.ts +0 -37
  107. package/types/projection/geometry/delta-calc.d.ts +0 -10
  108. package/types/projection/geometry/delta-remove.d.ts +0 -20
  109. package/types/projection/geometry/models.d.ts +0 -5
  110. package/types/projection/geometry/types.d.ts +0 -29
  111. package/types/projection/geometry/utils.d.ts +0 -3
  112. package/types/projection/index.d.ts +0 -14
  113. package/types/projection/node/DocumentProjectionNode.d.ts +0 -108
  114. package/types/projection/node/HTMLProjectionNode.d.ts +0 -112
  115. package/types/projection/node/create-projection-node.d.ts +0 -301
  116. package/types/projection/node/group.d.ts +0 -7
  117. package/types/projection/node/id.d.ts +0 -1
  118. package/types/projection/node/types.d.ts +0 -136
  119. package/types/projection/shared/stack.d.ts +0 -17
  120. package/types/projection/styles/scale-border-radius.d.ts +0 -11
  121. package/types/projection/styles/scale-box-shadow.d.ts +0 -2
  122. package/types/projection/styles/scale-correction.d.ts +0 -3
  123. package/types/projection/styles/transform-origin.d.ts +0 -0
  124. package/types/projection/styles/transform.d.ts +0 -4
  125. package/types/projection/styles/types.d.ts +0 -9
  126. package/types/projection/use-instant-layout-transition.d.ts +0 -1
  127. package/types/projection/use-reset-projection.d.ts +0 -1
  128. package/types/projection/utils/each-axis.d.ts +0 -3
  129. package/types/projection/utils/has-transform.d.ts +0 -3
  130. package/types/projection/utils/measure.d.ts +0 -4
  131. package/types/render/dom/create-visual-element.d.ts +0 -2
  132. package/types/render/dom/features-animation.d.ts +0 -5
  133. package/types/render/dom/features-max.d.ts +0 -5
  134. package/types/render/dom/motion-minimal.d.ts +0 -5
  135. package/types/render/dom/motion-proxy.d.ts +0 -30
  136. package/types/render/dom/motion.d.ts +0 -25
  137. package/types/render/dom/types.d.ts +0 -28
  138. package/types/render/dom/use-render.d.ts +0 -4
  139. package/types/render/dom/utils/camel-to-dash.d.ts +0 -4
  140. package/types/render/dom/utils/create-config.d.ts +0 -8
  141. package/types/render/dom/utils/css-variables-conversion.d.ts +0 -22
  142. package/types/render/dom/utils/filter-props.d.ts +0 -4
  143. package/types/render/dom/utils/is-css-variable.d.ts +0 -4
  144. package/types/render/dom/utils/is-svg-component.d.ts +0 -2
  145. package/types/render/dom/utils/parse-dom-variant.d.ts +0 -6
  146. package/types/render/dom/utils/unit-conversion.d.ts +0 -27
  147. package/types/render/dom/value-types/animatable-none.d.ts +0 -1
  148. package/types/render/dom/value-types/defaults.d.ts +0 -9
  149. package/types/render/dom/value-types/dimensions.d.ts +0 -8
  150. package/types/render/dom/value-types/find.d.ts +0 -9
  151. package/types/render/dom/value-types/get-as-type.d.ts +0 -5
  152. package/types/render/dom/value-types/number.d.ts +0 -2
  153. package/types/render/dom/value-types/test.d.ts +0 -5
  154. package/types/render/dom/value-types/type-auto.d.ts +0 -5
  155. package/types/render/dom/value-types/type-int.d.ts +0 -8
  156. package/types/render/dom/value-types/types.d.ts +0 -4
  157. package/types/render/html/config-motion.d.ts +0 -3
  158. package/types/render/html/supported-elements.d.ts +0 -7
  159. package/types/render/html/types.d.ts +0 -61
  160. package/types/render/html/use-props.d.ts +0 -8
  161. package/types/render/html/utils/build-styles.d.ts +0 -5
  162. package/types/render/html/utils/build-transform.d.ts +0 -15
  163. package/types/render/html/utils/create-render-state.d.ts +0 -7
  164. package/types/render/html/utils/render.d.ts +0 -4
  165. package/types/render/html/utils/scrape-motion-values.d.ts +0 -2
  166. package/types/render/html/utils/transform.d.ts +0 -15
  167. package/types/render/html/visual-element.d.ts +0 -6
  168. package/types/render/index.d.ts +0 -2
  169. package/types/render/svg/config-motion.d.ts +0 -3
  170. package/types/render/svg/lowercase-elements.d.ts +0 -5
  171. package/types/render/svg/supported-elements.d.ts +0 -7
  172. package/types/render/svg/types.d.ts +0 -44
  173. package/types/render/svg/use-props.d.ts +0 -7
  174. package/types/render/svg/utils/build-attrs.d.ts +0 -8
  175. package/types/render/svg/utils/camel-case-attrs.d.ts +0 -4
  176. package/types/render/svg/utils/create-render-state.d.ts +0 -2
  177. package/types/render/svg/utils/path.d.ts +0 -9
  178. package/types/render/svg/utils/render.d.ts +0 -4
  179. package/types/render/svg/utils/scrape-motion-values.d.ts +0 -2
  180. package/types/render/svg/utils/transform-origin.d.ts +0 -6
  181. package/types/render/svg/visual-element.d.ts +0 -2
  182. package/types/render/types.d.ts +0 -113
  183. package/types/render/utils/animation-state.d.ts +0 -31
  184. package/types/render/utils/animation.d.ts +0 -21
  185. package/types/render/utils/compare-by-depth.d.ts +0 -5
  186. package/types/render/utils/flat-tree.d.ts +0 -8
  187. package/types/render/utils/is-draggable.d.ts +0 -2
  188. package/types/render/utils/lifecycles.d.ts +0 -114
  189. package/types/render/utils/motion-values.d.ts +0 -3
  190. package/types/render/utils/setters.d.ts +0 -792
  191. package/types/render/utils/types.d.ts +0 -9
  192. package/types/render/utils/variants.d.ts +0 -20
  193. package/types/three-entry.d.ts +0 -19
  194. package/types/types.d.ts +0 -981
  195. package/types/utils/array.d.ts +0 -3
  196. package/types/utils/each-axis.d.ts +0 -1
  197. package/types/utils/is-browser.d.ts +0 -1
  198. package/types/utils/is-numerical-string.d.ts +0 -4
  199. package/types/utils/is-ref-object.d.ts +0 -2
  200. package/types/utils/is-zero-value-string.d.ts +0 -4
  201. package/types/utils/noop.d.ts +0 -1
  202. package/types/utils/process.d.ts +0 -1
  203. package/types/utils/resolve-value.d.ts +0 -3
  204. package/types/utils/shallow-compare.d.ts +0 -1
  205. package/types/utils/subscription-manager.d.ts +0 -9
  206. package/types/utils/time-conversion.d.ts +0 -7
  207. package/types/utils/transform.d.ts +0 -91
  208. package/types/utils/use-animation-frame.d.ts +0 -2
  209. package/types/utils/use-constant.d.ts +0 -10
  210. package/types/utils/use-cycle.d.ts +0 -30
  211. package/types/utils/use-force-update.d.ts +0 -1
  212. package/types/utils/use-id.d.ts +0 -6
  213. package/types/utils/use-instant-transition-state.d.ts +0 -3
  214. package/types/utils/use-instant-transition.d.ts +0 -1
  215. package/types/utils/use-is-mounted.d.ts +0 -2
  216. package/types/utils/use-isomorphic-effect.d.ts +0 -2
  217. package/types/utils/use-reduced-motion.d.ts +0 -28
  218. package/types/utils/use-unmount-effect.d.ts +0 -1
  219. package/types/utils/warn-once.d.ts +0 -2
  220. package/types/value/index.d.ts +0 -260
  221. package/types/value/scroll/use-element-scroll.d.ts +0 -28
  222. package/types/value/scroll/use-viewport-scroll.d.ts +0 -22
  223. package/types/value/scroll/utils.d.ts +0 -19
  224. package/types/value/use-combine-values.d.ts +0 -2
  225. package/types/value/use-inverted-scale.d.ts +0 -28
  226. package/types/value/use-motion-template.d.ts +0 -24
  227. package/types/value/use-motion-value.d.ts +0 -19
  228. package/types/value/use-on-change.d.ts +0 -3
  229. package/types/value/use-spring.d.ts +0 -22
  230. package/types/value/use-time.d.ts +0 -1
  231. package/types/value/use-transform.d.ts +0 -93
  232. package/types/value/use-velocity.d.ts +0 -13
  233. package/types/value/utils/is-motion-value.d.ts +0 -2
  234. package/types/value/utils/resolve-motion-value.d.ts +0 -10
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- import { ReorderContextProps } from "../components/Reorder/types";
3
- export declare const ReorderContext: import("react").Context<ReorderContextProps<any> | null>;
@@ -1,23 +0,0 @@
1
- /// <reference types="react" />
2
- import { IProjectionNode } from "../projection/node/types";
3
- import { Transition } from "../types";
4
- export interface SwitchLayoutGroup {
5
- register?: (member: IProjectionNode) => void;
6
- deregister?: (member: IProjectionNode) => void;
7
- }
8
- export declare type SwitchLayoutGroupContext = SwitchLayoutGroup & InitialPromotionConfig;
9
- export declare type InitialPromotionConfig = {
10
- /**
11
- * The initial transition to use when the elements in this group mount (and automatically promoted).
12
- * Subsequent updates should provide a transition in the promote method.
13
- */
14
- transition?: Transition;
15
- /**
16
- * If the follow tree should preserve its opacity when the lead is promoted on mount
17
- */
18
- shouldPreserveFollowOpacity?: (member: IProjectionNode) => boolean;
19
- };
20
- /**
21
- * @internal
22
- */
23
- export declare const SwitchLayoutGroupContext: import("react").Context<SwitchLayoutGroupContext>;
@@ -1,5 +0,0 @@
1
- import { EventInfo } from "./types";
2
- export declare type EventListenerWithPointInfo = (e: MouseEvent | TouchEvent | PointerEvent, info: EventInfo) => void;
3
- export declare function extractEventInfo(event: MouseEvent | TouchEvent | PointerEvent, pointType?: "page" | "client"): EventInfo;
4
- export declare function getViewportPointFromEvent(event: MouseEvent | TouchEvent | PointerEvent): EventInfo;
5
- export declare const wrapHandler: (handler: EventListenerWithPointInfo, shouldFilterPrimaryPointer?: boolean) => EventListener;
@@ -1,10 +0,0 @@
1
- import { RefObject } from "react";
2
- import { Point } from "../projection/geometry/types";
3
- /** @public */
4
- export interface EventInfo {
5
- point: Point;
6
- }
7
- export declare type EventHandler = (event: MouseEvent | TouchEvent | PointerEvent, info: EventInfo) => void;
8
- export declare type ListenerControls = [() => void, () => void];
9
- export declare type TargetOrRef = EventTarget | RefObject<EventTarget>;
10
- export declare type TargetBasedReturnType<Target> = Target extends EventTarget ? ListenerControls : undefined;
@@ -1,24 +0,0 @@
1
- import { RefObject } from "react";
2
- export declare function addDomEvent(target: EventTarget, eventName: string, handler: EventListener, options?: AddEventListenerOptions): () => void;
3
- /**
4
- * Attaches an event listener directly to the provided DOM element.
5
- *
6
- * Bypassing React's event system can be desirable, for instance when attaching non-passive
7
- * event handlers.
8
- *
9
- * ```jsx
10
- * const ref = useRef(null)
11
- *
12
- * useDomEvent(ref, 'wheel', onWheel, { passive: false })
13
- *
14
- * return <div ref={ref} />
15
- * ```
16
- *
17
- * @param ref - React.RefObject that's been provided to the element you want to bind the listener to.
18
- * @param eventName - Name of the event you want listen for.
19
- * @param handler - Function to fire when receiving the event.
20
- * @param options - Options to pass to `Event.addEventListener`.
21
- *
22
- * @public
23
- */
24
- export declare function useDomEvent(ref: RefObject<EventTarget>, eventName: string, handler?: EventListener | undefined, options?: AddEventListenerOptions): void;
@@ -1,4 +0,0 @@
1
- import { RefObject } from "react";
2
- import { EventListenerWithPointInfo } from "./event-info";
3
- export declare function addPointerEvent(target: EventTarget, eventName: string, handler: EventListenerWithPointInfo, options?: AddEventListenerOptions): () => void;
4
- export declare function usePointerEvent(ref: RefObject<Element>, eventName: string, handler?: EventListenerWithPointInfo | undefined, options?: AddEventListenerOptions): void;
@@ -1,3 +0,0 @@
1
- export declare const supportsPointerEvents: () => boolean;
2
- export declare const supportsTouchEvents: () => boolean;
3
- export declare const supportsMouseEvents: () => boolean;
@@ -1,127 +0,0 @@
1
- import { Point, TransformPoint } from "../projection/geometry/types";
2
- export declare type AnyPointerEvent = MouseEvent | TouchEvent | PointerEvent;
3
- /**
4
- * Passed in to pan event handlers like `onPan` the `PanInfo` object contains
5
- * information about the current state of the tap gesture such as its
6
- * `point`, `delta`, `offset` and `velocity`.
7
- *
8
- * ```jsx
9
- * <motion.div onPan={(event, info) => {
10
- * console.log(info.point.x, info.point.y)
11
- * }} />
12
- * ```
13
- *
14
- * @public
15
- */
16
- export interface PanInfo {
17
- /**
18
- * Contains `x` and `y` values for the current pan position relative
19
- * to the device or page.
20
- *
21
- * ```jsx
22
- * function onPan(event, info) {
23
- * console.log(info.point.x, info.point.y)
24
- * }
25
- *
26
- * <motion.div onPan={onPan} />
27
- * ```
28
- *
29
- * @public
30
- */
31
- point: Point;
32
- /**
33
- * Contains `x` and `y` values for the distance moved since
34
- * the last event.
35
- *
36
- * ```jsx
37
- * function onPan(event, info) {
38
- * console.log(info.delta.x, info.delta.y)
39
- * }
40
- *
41
- * <motion.div onPan={onPan} />
42
- * ```
43
- *
44
- * @public
45
- */
46
- delta: Point;
47
- /**
48
- * Contains `x` and `y` values for the distance moved from
49
- * the first pan event.
50
- *
51
- * ```jsx
52
- * function onPan(event, info) {
53
- * console.log(info.offset.x, info.offset.y)
54
- * }
55
- *
56
- * <motion.div onPan={onPan} />
57
- * ```
58
- *
59
- * @public
60
- */
61
- offset: Point;
62
- /**
63
- * Contains `x` and `y` values for the current velocity of the pointer, in px/ms.
64
- *
65
- * ```jsx
66
- * function onPan(event, info) {
67
- * console.log(info.velocity.x, info.velocity.y)
68
- * }
69
- *
70
- * <motion.div onPan={onPan} />
71
- * ```
72
- *
73
- * @public
74
- */
75
- velocity: Point;
76
- }
77
- export declare type PanHandler = (event: Event, info: PanInfo) => void;
78
- interface PanSessionHandlers {
79
- onSessionStart: PanHandler;
80
- onStart: PanHandler;
81
- onMove: PanHandler;
82
- onEnd: PanHandler;
83
- onSessionEnd: PanHandler;
84
- }
85
- interface PanSessionOptions {
86
- transformPagePoint?: TransformPoint;
87
- }
88
- /**
89
- * @internal
90
- */
91
- export declare class PanSession {
92
- /**
93
- * @internal
94
- */
95
- private history;
96
- /**
97
- * @internal
98
- */
99
- private startEvent;
100
- /**
101
- * @internal
102
- */
103
- private lastMoveEvent;
104
- /**
105
- * @internal
106
- */
107
- private lastMoveEventInfo;
108
- /**
109
- * @internal
110
- */
111
- private transformPagePoint?;
112
- /**
113
- * @internal
114
- */
115
- private handlers;
116
- /**
117
- * @internal
118
- */
119
- private removeListeners;
120
- constructor(event: AnyPointerEvent, handlers: Partial<PanSessionHandlers>, { transformPagePoint }?: PanSessionOptions);
121
- private updatePoint;
122
- private handlePointerMove;
123
- private handlePointerUp;
124
- updateHandlers(handlers: Partial<PanSessionHandlers>): void;
125
- end(): void;
126
- }
127
- export {};
@@ -1,56 +0,0 @@
1
- import { AnyPointerEvent } from "../../gestures/PanSession";
2
- import { VisualElement } from "../../render/types";
3
- import { MotionProps } from "../../motion/types";
4
- import { Point } from "../../projection/geometry/types";
5
- export declare const elementDragControls: WeakMap<VisualElement<any, any>, VisualElementDragControls>;
6
- export interface DragControlOptions {
7
- snapToCursor?: boolean;
8
- cursorProgress?: Point;
9
- }
10
- /**
11
- *
12
- */
13
- export declare class VisualElementDragControls {
14
- private visualElement;
15
- private panSession?;
16
- private openGlobalLock;
17
- isDragging: boolean;
18
- private currentDirection;
19
- private originPoint;
20
- /**
21
- * The permitted boundaries of travel, in pixels.
22
- */
23
- private constraints;
24
- private hasMutatedConstraints;
25
- /**
26
- * The per-axis resolved elastic values.
27
- */
28
- private elastic;
29
- constructor(visualElement: VisualElement);
30
- start(originEvent: AnyPointerEvent, { snapToCursor }?: DragControlOptions): void;
31
- private stop;
32
- private cancel;
33
- private updateAxis;
34
- private resolveConstraints;
35
- private resolveRefConstraints;
36
- private startAnimation;
37
- private startAxisValueAnimation;
38
- private stopAnimation;
39
- /**
40
- * Drag works differently depending on which props are provided.
41
- *
42
- * - If _dragX and _dragY are provided, we output the gesture delta directly to those motion values.
43
- * - Otherwise, we apply the delta to the x/y motion values.
44
- */
45
- private getAxisMotionValue;
46
- private snapToCursor;
47
- /**
48
- * When the viewport resizes we want to check if the measured constraints
49
- * have changed and, if so, reposition the element within those new constraints
50
- * relative to where it was before the resize.
51
- */
52
- scalePositionWithinConstraints(): void;
53
- addListeners(): () => void;
54
- getProps(): MotionProps;
55
- }
56
- export declare function expectsResolvedDragConstraints({ dragConstraints, onMeasureDragConstraints, }: MotionProps): boolean;
@@ -1,294 +0,0 @@
1
- import { RefObject } from "react";
2
- import { PanInfo } from "../PanSession";
3
- import { Inertia, TargetAndTransition } from "../../types";
4
- import { DragControls } from "./use-drag-controls";
5
- import { MotionValue } from "../../value";
6
- import { VariantLabels } from "../../motion/types";
7
- import { Axis, BoundingBox } from "../../projection/geometry/types";
8
- export declare type DragHandler = (event: MouseEvent | TouchEvent | PointerEvent, info: PanInfo) => void;
9
- export declare type DragElastic = boolean | number | Partial<BoundingBox>;
10
- export interface ResolvedConstraints {
11
- x: Partial<Axis>;
12
- y: Partial<Axis>;
13
- }
14
- export interface ResolvedElastic {
15
- x: Axis;
16
- y: Axis;
17
- }
18
- /**
19
- * @public
20
- */
21
- export interface DragHandlers {
22
- /**
23
- * Callback function that fires when dragging starts.
24
- *
25
- * ```jsx
26
- * <motion.div
27
- * drag
28
- * onDragStart={
29
- * (event, info) => console.log(info.point.x, info.point.y)
30
- * }
31
- * />
32
- * ```
33
- *
34
- * @public
35
- */
36
- onDragStart?(event: MouseEvent | TouchEvent | PointerEvent, info: PanInfo): void;
37
- /**
38
- * Callback function that fires when dragging ends.
39
- *
40
- * ```jsx
41
- * <motion.div
42
- * drag
43
- * onDragEnd={
44
- * (event, info) => console.log(info.point.x, info.point.y)
45
- * }
46
- * />
47
- * ```
48
- *
49
- * @public
50
- */
51
- onDragEnd?(event: MouseEvent | TouchEvent | PointerEvent, info: PanInfo): void;
52
- /**
53
- * Callback function that fires when the component is dragged.
54
- *
55
- * ```jsx
56
- * <motion.div
57
- * drag
58
- * onDrag={
59
- * (event, info) => console.log(info.point.x, info.point.y)
60
- * }
61
- * />
62
- * ```
63
- *
64
- * @public
65
- */
66
- onDrag?(event: MouseEvent | TouchEvent | PointerEvent, info: PanInfo): void;
67
- /**
68
- * Callback function that fires a drag direction is determined.
69
- *
70
- * ```jsx
71
- * <motion.div
72
- * drag
73
- * dragDirectionLock
74
- * onDirectionLock={axis => console.log(axis)}
75
- * />
76
- * ```
77
- *
78
- * @public
79
- */
80
- onDirectionLock?(axis: "x" | "y"): void;
81
- /**
82
- * Callback function that fires when drag momentum/bounce transition finishes.
83
- *
84
- * ```jsx
85
- * <motion.div
86
- * drag
87
- * onDragTransitionEnd={() => console.log('Drag transition complete')}
88
- * />
89
- * ```
90
- *
91
- * @public
92
- */
93
- onDragTransitionEnd?(): void;
94
- }
95
- /**
96
- * @public
97
- */
98
- export declare type InertiaOptions = Partial<Omit<Inertia, "velocity" | "type">>;
99
- /**
100
- * @public
101
- */
102
- export interface DraggableProps extends DragHandlers {
103
- /**
104
- * Enable dragging for this element. Set to `false` by default.
105
- * Set `true` to drag in both directions.
106
- * Set `"x"` or `"y"` to only drag in a specific direction.
107
- *
108
- * ```jsx
109
- * <motion.div drag="x" />
110
- * ```
111
- */
112
- drag?: boolean | "x" | "y";
113
- /**
114
- * Properties or variant label to animate to while the drag gesture is recognised.
115
- *
116
- * ```jsx
117
- * <motion.div whileDrag={{ scale: 1.2 }} />
118
- * ```
119
- */
120
- whileDrag?: VariantLabels | TargetAndTransition;
121
- /**
122
- * If `true`, this will lock dragging to the initially-detected direction. Defaults to `false`.
123
- *
124
- * ```jsx
125
- * <motion.div drag dragDirectionLock />
126
- * ```
127
- */
128
- dragDirectionLock?: boolean;
129
- /**
130
- * Allows drag gesture propagation to child components. Set to `false` by
131
- * default.
132
- *
133
- * ```jsx
134
- * <motion.div drag="x" dragPropagation />
135
- * ```
136
- */
137
- dragPropagation?: boolean;
138
- /**
139
- * Applies constraints on the permitted draggable area.
140
- *
141
- * It can accept an object of optional `top`, `left`, `right`, and `bottom` values, measured in pixels.
142
- * This will define a distance the named edge of the draggable component.
143
- *
144
- * Alternatively, it can accept a `ref` to another component created with React's `useRef` hook.
145
- * This `ref` should be passed both to the draggable component's `dragConstraints` prop, and the `ref`
146
- * of the component you want to use as constraints.
147
- *
148
- * ```jsx
149
- * // In pixels
150
- * <motion.div
151
- * drag="x"
152
- * dragConstraints={{ left: 0, right: 300 }}
153
- * />
154
- *
155
- * // As a ref to another component
156
- * const MyComponent = () => {
157
- * const constraintsRef = useRef(null)
158
- *
159
- * return (
160
- * <motion.div ref={constraintsRef}>
161
- * <motion.div drag dragConstraints={constraintsRef} />
162
- * </motion.div>
163
- * )
164
- * }
165
- * ```
166
- */
167
- dragConstraints?: false | Partial<BoundingBox> | RefObject<Element>;
168
- /**
169
- * The degree of movement allowed outside constraints. 0 = no movement, 1 =
170
- * full movement.
171
- *
172
- * Set to `0.5` by default. Can also be set as `false` to disable movement.
173
- *
174
- * By passing an object of `top`/`right`/`bottom`/`left`, individual values can be set
175
- * per constraint. Any missing values will be set to `0`.
176
- *
177
- * ```jsx
178
- * <motion.div
179
- * drag
180
- * dragConstraints={{ left: 0, right: 300 }}
181
- * dragElastic={0.2}
182
- * />
183
- * ```
184
- */
185
- dragElastic?: DragElastic;
186
- /**
187
- * Apply momentum from the pan gesture to the component when dragging
188
- * finishes. Set to `true` by default.
189
- *
190
- * ```jsx
191
- * <motion.div
192
- * drag
193
- * dragConstraints={{ left: 0, right: 300 }}
194
- * dragMomentum={false}
195
- * />
196
- * ```
197
- */
198
- dragMomentum?: boolean;
199
- /**
200
- * Allows you to change dragging inertia parameters.
201
- * When releasing a draggable Frame, an animation with type `inertia` starts. The animation is based on your dragging velocity. This property allows you to customize it.
202
- * See {@link https://framer.com/api/animation/#inertia | Inertia} for all properties you can use.
203
- *
204
- * ```jsx
205
- * <motion.div
206
- * drag
207
- * dragTransition={{ bounceStiffness: 600, bounceDamping: 10 }}
208
- * />
209
- * ```
210
- */
211
- dragTransition?: InertiaOptions;
212
- /**
213
- * Usually, dragging is initiated by pressing down on a component and moving it. For some
214
- * use-cases, for instance clicking at an arbitrary point on a video scrubber, we
215
- * might want to initiate dragging from a different component than the draggable one.
216
- *
217
- * By creating a `dragControls` using the `useDragControls` hook, we can pass this into
218
- * the draggable component's `dragControls` prop. It exposes a `start` method
219
- * that can start dragging from pointer events on other components.
220
- *
221
- * ```jsx
222
- * const dragControls = useDragControls()
223
- *
224
- * function startDrag(event) {
225
- * dragControls.start(event, { snapToCursor: true })
226
- * }
227
- *
228
- * return (
229
- * <>
230
- * <div onPointerDown={startDrag} />
231
- * <motion.div drag="x" dragControls={dragControls} />
232
- * </>
233
- * )
234
- * ```
235
- */
236
- dragControls?: DragControls;
237
- /**
238
- * If true, element will snap back to its origin when dragging ends.
239
- *
240
- * Enabling this is the equivalent of setting all `dragConstraints` axes to `0`
241
- * with `dragElastic={1}`, but when used together `dragConstraints` can define
242
- * a wider draggable area and `dragSnapToOrigin` will ensure the element
243
- * animates back to its origin on release.
244
- */
245
- dragSnapToOrigin?: boolean;
246
- /**
247
- * By default, if `drag` is defined on a component then an event listener will be attached
248
- * to automatically initiate dragging when a user presses down on it.
249
- *
250
- * By setting `dragListener` to `false`, this event listener will not be created.
251
- *
252
- * ```jsx
253
- * const dragControls = useDragControls()
254
- *
255
- * function startDrag(event) {
256
- * dragControls.start(event, { snapToCursor: true })
257
- * }
258
- *
259
- * return (
260
- * <>
261
- * <div onPointerDown={startDrag} />
262
- * <motion.div
263
- * drag="x"
264
- * dragControls={dragControls}
265
- * dragListener={false}
266
- * />
267
- * </>
268
- * )
269
- * ```
270
- */
271
- dragListener?: boolean;
272
- /**
273
- * If `dragConstraints` is set to a React ref, this callback will call with the measured drag constraints.
274
- *
275
- * @public
276
- */
277
- onMeasureDragConstraints?: (constraints: BoundingBox) => BoundingBox | void;
278
- /**
279
- * Usually, dragging uses the layout project engine, and applies transforms to the underlying VisualElement.
280
- * Passing MotionValues as _dragX and _dragY instead applies drag updates to these motion values.
281
- * This allows you to manually control how updates from a drag gesture on an element is applied.
282
- *
283
- * @public
284
- */
285
- _dragX?: MotionValue<number>;
286
- /**
287
- * Usually, dragging uses the layout project engine, and applies transforms to the underlying VisualElement.
288
- * Passing MotionValues as _dragX and _dragY instead applies drag updates to these motion values.
289
- * This allows you to manually control how updates from a drag gesture on an element is applied.
290
- *
291
- * @public
292
- */
293
- _dragY?: MotionValue<number>;
294
- }
@@ -1,74 +0,0 @@
1
- import * as React from "react";
2
- import { VisualElementDragControls, DragControlOptions } from "./VisualElementDragControls";
3
- /**
4
- * Can manually trigger a drag gesture on one or more `drag`-enabled `motion` components.
5
- *
6
- * ```jsx
7
- * const dragControls = useDragControls()
8
- *
9
- * function startDrag(event) {
10
- * dragControls.start(event, { snapToCursor: true })
11
- * }
12
- *
13
- * return (
14
- * <>
15
- * <div onPointerDown={startDrag} />
16
- * <motion.div drag="x" dragControls={dragControls} />
17
- * </>
18
- * )
19
- * ```
20
- *
21
- * @public
22
- */
23
- export declare class DragControls {
24
- private componentControls;
25
- /**
26
- * Subscribe a component's internal `VisualElementDragControls` to the user-facing API.
27
- *
28
- * @internal
29
- */
30
- subscribe(controls: VisualElementDragControls): () => void;
31
- /**
32
- * Start a drag gesture on every `motion` component that has this set of drag controls
33
- * passed into it via the `dragControls` prop.
34
- *
35
- * ```jsx
36
- * dragControls.start(e, {
37
- * snapToCursor: true
38
- * })
39
- * ```
40
- *
41
- * @param event - PointerEvent
42
- * @param options - Options
43
- *
44
- * @public
45
- */
46
- start(event: React.MouseEvent | React.TouchEvent | React.PointerEvent | MouseEvent | TouchEvent | PointerEvent, options?: DragControlOptions): void;
47
- }
48
- /**
49
- * Usually, dragging is initiated by pressing down on a `motion` component with a `drag` prop
50
- * and moving it. For some use-cases, for instance clicking at an arbitrary point on a video scrubber, we
51
- * might want to initiate that dragging from a different component than the draggable one.
52
- *
53
- * By creating a `dragControls` using the `useDragControls` hook, we can pass this into
54
- * the draggable component's `dragControls` prop. It exposes a `start` method
55
- * that can start dragging from pointer events on other components.
56
- *
57
- * ```jsx
58
- * const dragControls = useDragControls()
59
- *
60
- * function startDrag(event) {
61
- * dragControls.start(event, { snapToCursor: true })
62
- * }
63
- *
64
- * return (
65
- * <>
66
- * <div onPointerDown={startDrag} />
67
- * <motion.div drag="x" dragControls={dragControls} />
68
- * </>
69
- * )
70
- * ```
71
- *
72
- * @public
73
- */
74
- export declare function useDragControls(): DragControls;
@@ -1,7 +0,0 @@
1
- import { FeatureProps } from "../../motion/features/types";
2
- /**
3
- * A hook that allows an element to be dragged.
4
- *
5
- * @internal
6
- */
7
- export declare function useDrag(props: FeatureProps): void;