motion-start 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +39 -0
  3. package/package.json +64 -0
  4. package/src/animation/UseAnimatedState.svelte +86 -0
  5. package/src/animation/UseAnimation.svelte +61 -0
  6. package/src/animation/animate.ts +78 -0
  7. package/src/animation/animation-controls.ts +101 -0
  8. package/src/animation/types.ts +83 -0
  9. package/src/animation/use-animated-state.ts +1 -0
  10. package/src/animation/use-animation.ts +74 -0
  11. package/src/animation/utils/default-transitions.ts +70 -0
  12. package/src/animation/utils/easing.ts +55 -0
  13. package/src/animation/utils/is-animatable.ts +42 -0
  14. package/src/animation/utils/is-animation-controls.ts +17 -0
  15. package/src/animation/utils/is-keyframes-target.ts +17 -0
  16. package/src/animation/utils/transitions.ts +218 -0
  17. package/src/animation/utils/variant-resolvers.ts +15 -0
  18. package/src/components/AnimatePresence/AnimatePresence.svelte +180 -0
  19. package/src/components/AnimatePresence/PresenceChild/PresenceChild.svelte +78 -0
  20. package/src/components/AnimatePresence/PresenceChild/index.ts +7 -0
  21. package/src/components/AnimatePresence/PresenceChild/types.ts +10 -0
  22. package/src/components/AnimatePresence/index.ts +46 -0
  23. package/src/components/AnimatePresence/types.ts +79 -0
  24. package/src/components/AnimatePresence/use-presence.ts +90 -0
  25. package/src/components/AnimateSharedLayout/AnimateSharedLayout.svelte +239 -0
  26. package/src/components/AnimateSharedLayout/index.ts +11 -0
  27. package/src/components/AnimateSharedLayout/types.ts +111 -0
  28. package/src/components/AnimateSharedLayout/utils/batcher.ts +96 -0
  29. package/src/components/AnimateSharedLayout/utils/crossfader.ts +260 -0
  30. package/src/components/AnimateSharedLayout/utils/rotate.ts +48 -0
  31. package/src/components/AnimateSharedLayout/utils/stack.ts +160 -0
  32. package/src/components/LazyMotion/LazyMotion.svelte +82 -0
  33. package/src/components/LazyMotion/index.ts +42 -0
  34. package/src/components/LazyMotion/types.ts +58 -0
  35. package/src/components/MotionConfig/MotionConfig.svelte +56 -0
  36. package/src/components/MotionConfig/MotionConfigScaleCorrection.ts +47 -0
  37. package/src/components/MotionConfig/index.ts +20 -0
  38. package/src/components/MotionDiv.svelte +8 -0
  39. package/src/context/DOMcontext.ts +21 -0
  40. package/src/context/LayoutGroupContext.ts +13 -0
  41. package/src/context/LazyContext.ts +18 -0
  42. package/src/context/MotionConfigContext.ts +48 -0
  43. package/src/context/MotionContext/MotionContext.svelte +27 -0
  44. package/src/context/MotionContext/MotionContextProvider.svelte +22 -0
  45. package/src/context/MotionContext/UseCreateMotionContext.svelte +34 -0
  46. package/src/context/MotionContext/create.ts +1 -0
  47. package/src/context/MotionContext/index.ts +14 -0
  48. package/src/context/MotionContext/utils.ts +29 -0
  49. package/src/context/PresenceContext.ts +26 -0
  50. package/src/context/ScaleCorrectionProvider.svelte +27 -0
  51. package/src/context/SharedLayoutContext.ts +29 -0
  52. package/src/events/UseDomEvent.svelte +67 -0
  53. package/src/events/UsePointerEvent.svelte +76 -0
  54. package/src/events/event-info.ts +69 -0
  55. package/src/events/types.ts +15 -0
  56. package/src/events/use-dom-event.ts +48 -0
  57. package/src/events/use-pointer-event.ts +29 -0
  58. package/src/events/utils.ts +25 -0
  59. package/src/gestures/PanSession.ts +298 -0
  60. package/src/gestures/UseFocusGesture.svelte +31 -0
  61. package/src/gestures/UseGestures.svelte +17 -0
  62. package/src/gestures/UseHoverGesture.svelte +40 -0
  63. package/src/gestures/UsePanGesture.svelte +58 -0
  64. package/src/gestures/UseTapGesture.svelte +77 -0
  65. package/src/gestures/drag/UseDrag.svelte +55 -0
  66. package/src/gestures/drag/UseDragControls.svelte +145 -0
  67. package/src/gestures/drag/VisualElementDragControls.ts +632 -0
  68. package/src/gestures/drag/types.ts +307 -0
  69. package/src/gestures/drag/use-drag-controls.ts +148 -0
  70. package/src/gestures/drag/use-drag.ts +15 -0
  71. package/src/gestures/drag/utils/constraints.ts +157 -0
  72. package/src/gestures/drag/utils/lock.ts +69 -0
  73. package/src/gestures/types.ts +257 -0
  74. package/src/gestures/use-focus-gesture.ts +16 -0
  75. package/src/gestures/use-gestures.ts +2 -0
  76. package/src/gestures/use-hover-gesture.ts +10 -0
  77. package/src/gestures/use-pan-gesture.ts +22 -0
  78. package/src/gestures/use-tap-gesture.ts +14 -0
  79. package/src/gestures/utils/event-type.ts +24 -0
  80. package/src/gestures/utils/is-node-or-child.ts +31 -0
  81. package/src/index.ts +104 -0
  82. package/src/motion/Motion.svelte +246 -0
  83. package/src/motion/MotionSSR.svelte +244 -0
  84. package/src/motion/features/AnimationState.svelte +29 -0
  85. package/src/motion/features/Exit.svelte +32 -0
  86. package/src/motion/features/UseFeatures.svelte +39 -0
  87. package/src/motion/features/animations.ts +22 -0
  88. package/src/motion/features/definitions.ts +49 -0
  89. package/src/motion/features/drag.ts +24 -0
  90. package/src/motion/features/gestures.ts +24 -0
  91. package/src/motion/features/layout/Animate.svelte +314 -0
  92. package/src/motion/features/layout/Animate.ts +9 -0
  93. package/src/motion/features/layout/AnimateLayoutContextProvider.svelte +14 -0
  94. package/src/motion/features/layout/Measure.svelte +98 -0
  95. package/src/motion/features/layout/Measure.ts +9 -0
  96. package/src/motion/features/layout/MeasureContextProvider.svelte +32 -0
  97. package/src/motion/features/layout/index.ts +20 -0
  98. package/src/motion/features/layout/types.ts +71 -0
  99. package/src/motion/features/layout/utils.ts +40 -0
  100. package/src/motion/features/types.ts +53 -0
  101. package/src/motion/features/use-features.ts +16 -0
  102. package/src/motion/index.ts +64 -0
  103. package/src/motion/types.ts +278 -0
  104. package/src/motion/utils/UseLayoutId.svelte +18 -0
  105. package/src/motion/utils/UseVisualElement.svelte +104 -0
  106. package/src/motion/utils/UseVisualState.svelte +137 -0
  107. package/src/motion/utils/is-forced-motion-value.ts +23 -0
  108. package/src/motion/utils/make-renderless-component.ts +17 -0
  109. package/src/motion/utils/should-inhert-variant.ts +6 -0
  110. package/src/motion/utils/use-motion-ref.ts +41 -0
  111. package/src/motion/utils/use-visual-element.ts +13 -0
  112. package/src/motion/utils/use-visual-state.ts +24 -0
  113. package/src/motion/utils/valid-prop.ts +80 -0
  114. package/src/render/dom/M.svelte +16 -0
  115. package/src/render/dom/UseRender.svelte +37 -0
  116. package/src/render/dom/create-motion-class.ts +12 -0
  117. package/src/render/dom/create-visual-element.ts +22 -0
  118. package/src/render/dom/featureBundle.ts +22 -0
  119. package/src/render/dom/motion-minimal.ts +22 -0
  120. package/src/render/dom/motion-proxy.ts +107 -0
  121. package/src/render/dom/motion.ts +62 -0
  122. package/src/render/dom/projection/convert-to-relative.ts +40 -0
  123. package/src/render/dom/projection/default-scale-correctors.ts +138 -0
  124. package/src/render/dom/projection/measure.ts +28 -0
  125. package/src/render/dom/projection/relative-set.ts +27 -0
  126. package/src/render/dom/projection/scale-correction.ts +22 -0
  127. package/src/render/dom/projection/types.ts +13 -0
  128. package/src/render/dom/projection/utils.ts +69 -0
  129. package/src/render/dom/svg-visual-element.ts +114 -0
  130. package/src/render/dom/types.ts +32 -0
  131. package/src/render/dom/use-render.ts +11 -0
  132. package/src/render/dom/utils/UseInitialMotionProps.svelte +26 -0
  133. package/src/render/dom/utils/batch-layout.ts +77 -0
  134. package/src/render/dom/utils/camel-to-dash.ts +20 -0
  135. package/src/render/dom/utils/create-config.ts +33 -0
  136. package/src/render/dom/utils/css-variables-conversion.ts +121 -0
  137. package/src/render/dom/utils/filter-props.ts +55 -0
  138. package/src/render/dom/utils/is-css-variable.ts +18 -0
  139. package/src/render/dom/utils/is-svg-component.ts +41 -0
  140. package/src/render/dom/utils/parse-dom-variant.ts +26 -0
  141. package/src/render/dom/utils/unit-conversion.ts +258 -0
  142. package/src/render/dom/utils/use-html-props.ts +2 -0
  143. package/src/render/dom/utils/use-svg-props.ts +1 -0
  144. package/src/render/dom/value-types/animatable-none.ts +24 -0
  145. package/src/render/dom/value-types/defaults.ts +30 -0
  146. package/src/render/dom/value-types/dimensions.ts +27 -0
  147. package/src/render/dom/value-types/find.ts +31 -0
  148. package/src/render/dom/value-types/get-as-type.ts +21 -0
  149. package/src/render/dom/value-types/number.ts +83 -0
  150. package/src/render/dom/value-types/test.ts +17 -0
  151. package/src/render/dom/value-types/type-auto.ts +21 -0
  152. package/src/render/dom/value-types/type-int.ts +23 -0
  153. package/src/render/dom/value-types/types.ts +8 -0
  154. package/src/render/html/UseHTMLProps.svelte +33 -0
  155. package/src/render/html/UseInitialMotionValues.svelte +27 -0
  156. package/src/render/html/UseStyle.svelte +47 -0
  157. package/src/render/html/config-motion.ts +23 -0
  158. package/src/render/html/supported-elements.ts +10 -0
  159. package/src/render/html/types.ts +64 -0
  160. package/src/render/html/use-props.ts +14 -0
  161. package/src/render/html/utils/build-projection-transform.ts +53 -0
  162. package/src/render/html/utils/build-styles.ts +121 -0
  163. package/src/render/html/utils/build-transform.ts +79 -0
  164. package/src/render/html/utils/create-render-state.ts +18 -0
  165. package/src/render/html/utils/render.ts +22 -0
  166. package/src/render/html/utils/scrape-motion-values.ts +26 -0
  167. package/src/render/html/utils/transform.ts +51 -0
  168. package/src/render/html/visual-element.ts +129 -0
  169. package/src/render/index.ts +703 -0
  170. package/src/render/svg/UseSVGProps.svelte +34 -0
  171. package/src/render/svg/config-motion.ts +51 -0
  172. package/src/render/svg/lowercase-elements.ts +35 -0
  173. package/src/render/svg/supported-elements.ts +10 -0
  174. package/src/render/svg/types.ts +51 -0
  175. package/src/render/svg/use-props.ts +14 -0
  176. package/src/render/svg/utils/build-attrs.ts +58 -0
  177. package/src/render/svg/utils/camel-case-attrs.ts +27 -0
  178. package/src/render/svg/utils/create-render-state.ts +17 -0
  179. package/src/render/svg/utils/path.ts +49 -0
  180. package/src/render/svg/utils/render.ts +22 -0
  181. package/src/render/svg/utils/scrape-motion-values.ts +26 -0
  182. package/src/render/svg/utils/transform-origin.ts +30 -0
  183. package/src/render/svg/visual-element.ts +44 -0
  184. package/src/render/types.ts +148 -0
  185. package/src/render/utils/animation-state.ts +375 -0
  186. package/src/render/utils/animation.ts +167 -0
  187. package/src/render/utils/compare-by-depth.ts +18 -0
  188. package/src/render/utils/flat-tree.ts +35 -0
  189. package/src/render/utils/is-draggable.ts +17 -0
  190. package/src/render/utils/lifecycles.ts +172 -0
  191. package/src/render/utils/motion-values.ts +59 -0
  192. package/src/render/utils/projection.ts +38 -0
  193. package/src/render/utils/setters.ts +910 -0
  194. package/src/render/utils/state.ts +113 -0
  195. package/src/render/utils/types.ts +12 -0
  196. package/src/render/utils/variants.ts +76 -0
  197. package/src/types/geometry.ts +91 -0
  198. package/src/types.ts +1088 -0
  199. package/src/utils/UseUnmountEffect.svelte +11 -0
  200. package/src/utils/array.ts +18 -0
  201. package/src/utils/each-axis.ts +15 -0
  202. package/src/utils/errors.ts +22 -0
  203. package/src/utils/fix-process-env.ts +22 -0
  204. package/src/utils/geometry/delta-apply.ts +162 -0
  205. package/src/utils/geometry/delta-calc.ts +89 -0
  206. package/src/utils/geometry/index.ts +83 -0
  207. package/src/utils/is-browser.ts +12 -0
  208. package/src/utils/is-numerical-string.ts +15 -0
  209. package/src/utils/is-ref-object.ts +16 -0
  210. package/src/utils/noop.ts +15 -0
  211. package/src/utils/resolve-value.ts +23 -0
  212. package/src/utils/shallow-compare.ts +23 -0
  213. package/src/utils/subscription-manager.ts +49 -0
  214. package/src/utils/time-conversion.ts +18 -0
  215. package/src/utils/transform.ts +120 -0
  216. package/src/utils/use-constant.ts +23 -0
  217. package/src/utils/use-cycle.ts +78 -0
  218. package/src/utils/use-force-update.ts +7 -0
  219. package/src/utils/use-isomorphic-effect.ts +8 -0
  220. package/src/utils/use-reduced-motion.ts +70 -0
  221. package/src/utils/use-unmount-effect.ts +8 -0
  222. package/src/value/index.ts +409 -0
  223. package/src/value/scroll/use-element-scroll.ts +73 -0
  224. package/src/value/scroll/use-viewport-scroll.ts +81 -0
  225. package/src/value/scroll/utils.ts +76 -0
  226. package/src/value/use-combine-values.ts +53 -0
  227. package/src/value/use-motion-template.ts +57 -0
  228. package/src/value/use-motion-value.ts +27 -0
  229. package/src/value/use-spring.ts +84 -0
  230. package/src/value/use-transform.ts +216 -0
  231. package/src/value/use-velocity.ts +44 -0
  232. package/src/value/utils/is-motion-value.ts +15 -0
  233. package/src/value/utils/resolve-motion-value.ts +29 -0
@@ -0,0 +1,257 @@
1
+ /**
2
+ based on framer-motion@4.1.17,
3
+ Copyright (c) 2018 Framer B.V.
4
+ */
5
+ import type { EventInfo } from "../events/types";
6
+ import type { VariantLabels } from "../motion/types";
7
+ import type { TargetAndTransition } from "../types";
8
+ import type { Point2D } from "../types/geometry";
9
+ import type { PanInfo } from "./PanSession";
10
+ export type RemoveEvent = () => void;
11
+ /**
12
+ * @public
13
+ */
14
+ export interface FocusHandlers {
15
+ /**
16
+ * Properties or variant label to animate to while the focus gesture is recognised.
17
+ *
18
+ * @motion
19
+ *
20
+ * ```jsx
21
+ * <motion.input whileFocus={{ scale: 1.2 }} />
22
+ * ```
23
+ */
24
+ whileFocus?: VariantLabels | TargetAndTransition;
25
+ }
26
+ /**
27
+ * Passed in to tap event handlers like `onTap` the `TapInfo` object contains
28
+ * information about the tap gesture such as it‘s location.
29
+ *
30
+ * @motion
31
+ *
32
+ * ```jsx
33
+ * function onTap(event, info) {
34
+ * console.log(info.point.x, info.point.y)
35
+ * }
36
+ *
37
+ * <MotionDiv onTap={onTap} />
38
+ * ```
39
+ *
40
+ * @public
41
+ */
42
+ export interface TapInfo {
43
+ /**
44
+ * Contains `x` and `y` values for the tap gesture relative to the
45
+ * device or page.
46
+ *
47
+ * @motion
48
+ *
49
+ * ```jsx
50
+ * function onTapStart(event, info) {
51
+ * console.log(info.point.x, info.point.y)
52
+ * }
53
+ *
54
+ * <MotionDiv onTapStart={onTapStart} />
55
+ * ```
56
+ *
57
+ * @public
58
+ */
59
+ point: Point2D;
60
+ }
61
+ /**
62
+ * @public
63
+ */
64
+ export interface TapHandlers {
65
+ /**
66
+ * Callback when the tap gesture successfully ends on this element.
67
+ *
68
+ * @motion
69
+ *
70
+ * ```jsx
71
+ * function onTap(event, info) {
72
+ * console.log(info.point.x, info.point.y)
73
+ * }
74
+ *
75
+ * <MotionDiv onTap={onTap} />
76
+ * ```
77
+ *
78
+ * @param event - The originating pointer event.
79
+ * @param info - An {@link TapInfo} object containing `x` and `y` values for the `point` relative to the device or page.
80
+ */
81
+ onTap?(event: MouseEvent | TouchEvent | PointerEvent, info: TapInfo): void;
82
+ /**
83
+ * Callback when the tap gesture starts on this element.
84
+ *
85
+ * @motion
86
+ *
87
+ * ```jsx
88
+ * function onTapStart(event, info) {
89
+ * console.log(info.point.x, info.point.y)
90
+ * }
91
+ *
92
+ * <MotionDiv onTapStart={onTapStart} />
93
+ * ```
94
+ *
95
+ * @param event - The originating pointer event.
96
+ * @param info - An {@link TapInfo} object containing `x` and `y` values for the `point` relative to the device or page.
97
+ */
98
+ onTapStart?(event: MouseEvent | TouchEvent | PointerEvent, info: TapInfo): void;
99
+ /**
100
+ * Callback when the tap gesture ends outside this element.
101
+ *
102
+ * @motion
103
+ *
104
+ * ```jsx
105
+ * function onTapCancel(event, info) {
106
+ * console.log(info.point.x, info.point.y)
107
+ * }
108
+ *
109
+ * <MotionDiv onTapCancel={onTapCancel} />
110
+ * ```
111
+ *
112
+ * @param event - The originating pointer event.
113
+ * @param info - An {@link TapInfo} object containing `x` and `y` values for the `point` relative to the device or page.
114
+ */
115
+ onTapCancel?(event: MouseEvent | TouchEvent | PointerEvent, info: TapInfo): void;
116
+ /**
117
+ * Properties or variant label to animate to while the component is pressed.
118
+ *
119
+ * @motion
120
+ *
121
+ * ```jsx
122
+ * <MotionDiv whileTap={{ scale: 0.8 }} />
123
+ * ```
124
+ */
125
+ whileTap?: VariantLabels | TargetAndTransition;
126
+ }
127
+ export type PanHandler = (event: Event, info: PanInfo) => void;
128
+ /**
129
+ * @public
130
+ */
131
+ export interface PanHandlers {
132
+ /**
133
+ * Callback function that fires when the pan gesture is recognised on this element.
134
+ *
135
+ * **Note:** For pan gestures to work correctly with touch input, the element needs
136
+ * touch scrolling to be disabled on either x/y or both axis with the
137
+ * [touch-action](https://developer.mozilla.org/en-US/docs/Web/CSS/touch-action) CSS rule.
138
+ *
139
+ * @motion
140
+ *
141
+ * ```jsx
142
+ * function onPan(event, info) {
143
+ * console.log(info.point.x, info.point.y)
144
+ * }
145
+ *
146
+ * <MotionDiv onPan={onPan} />
147
+ * ```
148
+ *
149
+ * @param event - The originating pointer event.
150
+ * @param info - A {@link PanInfo} object containing `x` and `y` values for:
151
+ *
152
+ * - `point`: Relative to the device or page.
153
+ * - `delta`: Distance moved since the last event.
154
+ * - `offset`: Offset from the original pan event.
155
+ * - `velocity`: Current velocity of the pointer.
156
+ */
157
+ onPan?(event: MouseEvent | TouchEvent | PointerEvent, info: PanInfo): void;
158
+ /**
159
+ * Callback function that fires when the pan gesture begins on this element.
160
+ *
161
+ * @motion
162
+ *
163
+ * ```jsx
164
+ * function onPanStart(event, info) {
165
+ * console.log(info.point.x, info.point.y)
166
+ * }
167
+ *
168
+ * <MotionDiv onPanStart={onPanStart} />
169
+ * ```
170
+ *
171
+ * @param event - The originating pointer event.
172
+ * @param info - A {@link PanInfo} object containing `x`/`y` values for:
173
+ *
174
+ * - `point`: Relative to the device or page.
175
+ * - `delta`: Distance moved since the last event.
176
+ * - `offset`: Offset from the original pan event.
177
+ * - `velocity`: Current velocity of the pointer.
178
+ */
179
+ onPanStart?(event: MouseEvent | TouchEvent | PointerEvent, info: PanInfo): void;
180
+ /**
181
+ * Callback function that fires when we begin detecting a pan gesture. This
182
+ * is analogous to `onMouseStart` or `onTouchStart`.
183
+ *
184
+ * @motion
185
+ *
186
+ * ```jsx
187
+ * function onPanSessionStart(event, info) {
188
+ * console.log(info.point.x, info.point.y)
189
+ * }
190
+ *
191
+ * <MotionDiv onPanSessionStart={onPanSessionStart} />
192
+ * ```
193
+ *
194
+ * @param event - The originating pointer event.
195
+ * @param info - An {@link EventInfo} object containing `x`/`y` values for:
196
+ *
197
+ * - `point`: Relative to the device or page.
198
+ */
199
+ onPanSessionStart?(event: MouseEvent | TouchEvent | PointerEvent, info: EventInfo): void;
200
+ /**
201
+ * Callback function that fires when the pan gesture ends on this element.
202
+ *
203
+ * @motion
204
+ *
205
+ * ```jsx
206
+ * function onPanEnd(event, info) {
207
+ * console.log(info.point.x, info.point.y)
208
+ * }
209
+ *
210
+ * <MotionDiv onPanEnd={onPanEnd} />
211
+ * ```
212
+ *
213
+ * @param event - The originating pointer event.
214
+ * @param info - A {@link PanInfo} object containing `x`/`y` values for:
215
+ *
216
+ * - `point`: Relative to the device or page.
217
+ * - `delta`: Distance moved since the last event.
218
+ * - `offset`: Offset from the original pan event.
219
+ * - `velocity`: Current velocity of the pointer.
220
+ */
221
+ onPanEnd?(event: MouseEvent | TouchEvent | PointerEvent, info: PanInfo): void;
222
+ }
223
+ /**
224
+ * @public
225
+ */
226
+ export interface HoverHandlers {
227
+ /**
228
+ * Properties or variant label to animate to while the hover gesture is recognised.
229
+ *
230
+ * @motion
231
+ *
232
+ * ```jsx
233
+ * <MotionDiv whileHover={{ scale: 1.2 }} />
234
+ * ```
235
+ */
236
+ whileHover?: VariantLabels | TargetAndTransition;
237
+ /**
238
+ * Callback function that fires when pointer starts hovering over the component.
239
+ *
240
+ * @motion
241
+ *
242
+ * ```jsx
243
+ * <MotionDiv onHoverStart={() => console.log('Hover starts')} />
244
+ * ```
245
+ */
246
+ onHoverStart?(event: MouseEvent, info: EventInfo): void;
247
+ /**
248
+ * Callback function that fires when pointer stops hovering over the component.
249
+ *
250
+ * @motion
251
+ *
252
+ * ```jsx
253
+ * <MotionDiv onHoverEnd={() => console.log("Hover ends")} />
254
+ * ```
255
+ */
256
+ onHoverEnd?(event: MouseEvent, info: EventInfo): void;
257
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ based on framer-motion@4.1.17,
3
+ Copyright (c) 2018 Framer B.V.
4
+ */
5
+ import type { FeatureProps } from "../motion/features/types";
6
+ /**
7
+ *
8
+ * @param props
9
+ * @param ref
10
+ * @internal
11
+ */
12
+ export type useFocusGesture = ({ whileFocus, visualElement }: FeatureProps)=> void;
13
+
14
+
15
+ export { default as UseFocusGesture } from './UseFocusGesture.svelte';
16
+
@@ -0,0 +1,2 @@
1
+
2
+ export { default as UseGestures } from "./UseGestures.svelte";
@@ -0,0 +1,10 @@
1
+ /**
2
+ based on framer-motion@4.1.17,
3
+ Copyright (c) 2018 Framer B.V.
4
+ */
5
+ import type { FeatureProps } from "../motion/features/types";
6
+ export type useHoverGesture = ({ onHoverStart, onHoverEnd, whileHover, visualElement, }: FeatureProps) => void;
7
+
8
+
9
+ export { default as UseHoverGesture } from './UseHoverGesture.svelte';
10
+
@@ -0,0 +1,22 @@
1
+ /**
2
+ based on framer-motion@4.1.17,
3
+ Copyright (c) 2018 Framer B.V.
4
+ */
5
+ import type { FeatureProps } from "../motion/features/types";
6
+ /**
7
+ *
8
+ * @param handlers -
9
+ * @param ref -
10
+ *
11
+ * @internalremarks
12
+ * Currently this sets new pan gesture functions every render. The memo route has been explored
13
+ * in the past but ultimately we're still creating new functions every render. An optimisation
14
+ * to explore is creating the pan gestures and loading them into a `ref`.
15
+ *
16
+ * @internal
17
+ */
18
+ export type usePanGesture = ({ onPan, onPanStart, onPanEnd, onPanSessionStart, visualElement, }: FeatureProps) => void;
19
+
20
+
21
+ export { default as UsePanGesture } from './UsePanGesture.svelte';
22
+
@@ -0,0 +1,14 @@
1
+ /**
2
+ based on framer-motion@4.1.17,
3
+ Copyright (c) 2018 Framer B.V.
4
+ */
5
+ import type { FeatureProps } from "../motion/features/types";
6
+ /**
7
+ * @param handlers -
8
+ * @internal
9
+ */
10
+ export type useTapGesture = ({ onTap, onTapStart, onTapCancel, whileTap, visualElement, }: FeatureProps) => void;
11
+
12
+
13
+ export { default as UseTapGesture } from './UseTapGesture.svelte';
14
+
@@ -0,0 +1,24 @@
1
+ /**
2
+ based on framer-motion@4.1.17,
3
+ Copyright (c) 2018 Framer B.V.
4
+ */
5
+
6
+
7
+ /**
8
+ based on framer-motion@4.0.3,
9
+ Copyright (c) 2018 Framer B.V.
10
+ */
11
+
12
+ function isMouseEvent(event: MouseEvent | TouchEvent | PointerEvent): event is MouseEvent {
13
+ // PointerEvent inherits from MouseEvent so we can't use a straight instanceof check.
14
+ if (typeof PointerEvent !== "undefined" && event instanceof PointerEvent) {
15
+ return !!(event.pointerType === "mouse");
16
+ }
17
+ return event instanceof MouseEvent;
18
+ }
19
+ function isTouchEvent(event: MouseEvent | TouchEvent | PointerEvent): event is TouchEvent {
20
+ var hasTouches = !!(event as any).touches;
21
+ return hasTouches;
22
+ }
23
+
24
+ export { isMouseEvent, isTouchEvent };
@@ -0,0 +1,31 @@
1
+ /**
2
+ based on framer-motion@4.1.17,
3
+ Copyright (c) 2018 Framer B.V.
4
+ */
5
+
6
+
7
+ /**
8
+ based on framer-motion@4.0.3,
9
+ Copyright (c) 2018 Framer B.V.
10
+ */
11
+
12
+ /**
13
+ * Recursively traverse up the tree to check whether the provided child node
14
+ * is the parent or a descendant of it.
15
+ *
16
+ * @param parent - Element to find
17
+ * @param child - Element to test against parent
18
+ */
19
+ var isNodeOrChild = function (parent: Element, child?: Element | null | undefined) {
20
+ if (!child) {
21
+ return false;
22
+ }
23
+ else if (parent === child) {
24
+ return true;
25
+ }
26
+ else {
27
+ return isNodeOrChild(parent, child.parentElement);
28
+ }
29
+ };
30
+
31
+ export { isNodeOrChild };
package/src/index.ts ADDED
@@ -0,0 +1,104 @@
1
+ /**
2
+ based on framer-motion@4.0.3,
3
+ Copyright (c) 2018 Framer B.V.
4
+ */
5
+ export { FramerTreeLayoutContext } from './context/SharedLayoutContext.js';
6
+
7
+ export { UseGestures } from './gestures/use-gestures.js';
8
+ export { UsePanGesture } from './gestures/use-pan-gesture.js';
9
+ export { UseTapGesture } from './gestures/use-tap-gesture.js';
10
+
11
+ export { default as MotionSSR } from './motion/MotionSSR.svelte';
12
+
13
+ export { UseAnimation } from './animation/use-animation.js';
14
+
15
+ export { default as Mdiv, default as MotionDiv } from './components/MotionDiv.svelte';
16
+
17
+ // ----------------------------------------------------------------------------------------------
18
+
19
+ /**
20
+ based on framer-motion@4.1.17,
21
+ Copyright (c) 2018 Framer B.V.
22
+ */
23
+ /**
24
+ * Components
25
+ */
26
+ export { AnimatePresence } from "./components/AnimatePresence/index.js";
27
+ export { AnimateSharedLayout } from "./components/AnimateSharedLayout/index.js";
28
+ export { LazyMotion } from "./components/LazyMotion/index.js";
29
+ export { MotionConfig } from "./components/MotionConfig/index.js";
30
+ export { M } from "./render/dom/motion-proxy.js";
31
+ export { Motion /*, createDomMotionComponent*/, Motion as MotionSVG } from "./render/dom/motion.js";
32
+ /**
33
+ * Features
34
+ */
35
+ // export { domMax, domAnimation } from "./render/dom/featureBundle.js";
36
+ /**
37
+ * Motion values
38
+ */
39
+ export { MotionValue, motionValue, type PassiveEffect, type Subscriber } from "./value/index.js";
40
+ export { useElementScroll } from "./value/scroll/use-element-scroll.js";
41
+ export { useViewportScroll } from "./value/scroll/use-viewport-scroll.js";
42
+ export { useMotionTemplate } from "./value/use-motion-template.js";
43
+ export { useMotionValue } from "./value/use-motion-value.js";
44
+ export { useSpring } from "./value/use-spring.js";
45
+ export { useTransform } from "./value/use-transform.js";
46
+ export { useVelocity } from "./value/use-velocity.js";
47
+ export { resolveMotionValue } from "./value/utils/resolve-motion-value.js";
48
+ /**
49
+ * Accessibility
50
+ */
51
+ export { useReducedMotion } from "./utils/use-reduced-motion.js";
52
+ /**
53
+ * Utils
54
+ */
55
+ export { animate } from "./animation/animate.js";
56
+ export { animationControls } from "./animation/animation-controls.js";
57
+ export type { AnimationControls } from "./animation/types.js";
58
+ export { useAnimation } from "./animation/use-animation.js";
59
+ export { useIsPresent, usePresence } from "./components/AnimatePresence/use-presence.js";
60
+ export { createCrossfader } from "./components/AnimateSharedLayout/utils/crossfader.js";
61
+ export { UseDomEvent } from "./events/use-dom-event.js";
62
+ export { type PanInfo } from "./gestures/PanSession.js";
63
+ export { DragControls, useDragControls } from "./gestures/drag/use-drag-controls.js";
64
+ export type { FocusHandlers, HoverHandlers, PanHandlers, TapHandlers, TapInfo } from "./gestures/types.js";
65
+ export { createMotionComponent } from "./motion/index.js";
66
+ export { isValidMotionProp } from "./motion/utils/valid-prop.js";
67
+ export { addScaleCorrection } from "./render/dom/projection/scale-correction.js";
68
+ export { snapshotViewportBox } from "./render/dom/projection/utils.js";
69
+ export { batchLayout, flushLayout } from "./render/dom/utils/batch-layout.js";
70
+ export { visualElement } from "./render/index.js";
71
+ export type { VisualElement } from "./render/types.js";
72
+ export { animateVisualElement } from "./render/utils/animation.js";
73
+ export { transform } from "./utils/transform.js";
74
+ export { useCycle } from "./utils/use-cycle.js";
75
+ /**
76
+ * Contexts
77
+ */
78
+ export { LayoutGroupContext } from "./context/LayoutGroupContext.js";
79
+ export { MotionConfigContext } from "./context/MotionConfigContext.js";
80
+ export { PresenceContext } from "./context/PresenceContext.js";
81
+ /**
82
+ * Types
83
+ */
84
+ export type { AnimationOptions, AnimationPlaybackControls } from "./animation/animate.js";
85
+ export type { AnimatePresenceProps } from "./components/AnimatePresence/types.js";
86
+ export type { SharedLayoutAnimationConfig, SharedLayoutProps, SharedLayoutSyncMethods, SyncLayoutLifecycles, VisibilityAction } from "./components/AnimateSharedLayout/types.js";
87
+ export { createBatcher } from "./components/AnimateSharedLayout/utils/batcher.js";
88
+ export type { LazyProps } from "./components/LazyMotion/types.js";
89
+ export type { MotionConfigProps } from "./components/MotionConfig/index.js";
90
+ export type { SharedLayoutContext } from "./context/SharedLayoutContext.js";
91
+ export type { EventInfo } from "./events/types.js";
92
+ export type { DragElastic, DragHandlers, DraggableProps } from "./gestures/drag/types.js";
93
+ export type { LayoutProps } from "./motion/features/layout/types.js";
94
+ export * from "./motion/features/types.js";
95
+ export type { AnimationProps, MotionAdvancedProps, MotionProps, MotionStyle, MotionTransform, RelayoutInfo, ResolveLayoutTransition, VariantLabels } from "./motion/types.js";
96
+ export type { CustomDomComponent } from "./render/dom/motion-proxy.js";
97
+ export type { ForwardRefComponent, HTMLMotionProps } from "./render/html/types.js";
98
+ export type { SVGAttributesAsMotionValues, SVGMotionProps } from "./render/svg/types.js";
99
+ export { FlatTree } from "./render/utils/flat-tree.js";
100
+ export type { VisualElementLifecycles } from "./render/utils/lifecycles.js";
101
+ export type { CustomValueType, EasingFunction, Inertia, Keyframes, KeyframesTarget, None, Orchestration, Repeat, ResolvedKeyframesTarget, ResolvedSingleTarget, ResolvedValueTarget, SingleTarget, Spring, Target, TargetAndTransition, Transition, Tween, ValueTarget, Variant, Variants } from "./types.js";
102
+ export * from "./types/geometry.js";
103
+ export type { ScrollMotionValues } from "./value/scroll/utils.js";
104
+