@0xsequence/marketplace-sdk 2.0.1 → 2.0.2
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.
- package/CHANGELOG.md +10 -0
- package/dist/BellIcon.js +1 -1
- package/dist/Card.js +1 -1
- package/dist/ShopCard.d.ts +4 -4
- package/dist/builder-api.js +1 -1
- package/dist/collectible.js +1 -1
- package/dist/collection.js +1 -1
- package/dist/create-config.d.ts +597 -201
- package/dist/create-config.js +1 -1
- package/dist/currency.js +1 -1
- package/dist/dist.js +167 -148
- package/dist/dist.js.map +1 -1
- package/dist/expirationDateSelect.js +1 -1
- package/dist/filter-state.d.ts +1 -1
- package/dist/filters.d.ts +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/index10.d.ts +3 -3
- package/dist/index11.d.ts +17 -17
- package/dist/index12.d.ts +26 -26
- package/dist/index14.d.ts +3 -3
- package/dist/index15.d.ts +3 -3
- package/dist/index16.d.ts +2 -2
- package/dist/index17.d.ts +86 -86
- package/dist/index18.d.ts +40 -40
- package/dist/index19.d.ts +5 -5
- package/dist/index2.d.ts +4 -1
- package/dist/index21.d.ts +15 -15
- package/dist/index22.d.ts +8 -65
- package/dist/index23.d.ts +21 -13
- package/dist/index26.d.ts +4 -4
- package/dist/index27.d.ts +4 -4
- package/dist/index28.d.ts +10 -10
- package/dist/index3.d.ts +2 -2194
- package/dist/index31.d.ts +5 -5
- package/dist/index33.d.ts +3 -3
- package/dist/index34.d.ts +4 -4
- package/dist/index35.d.ts +1 -1
- package/dist/index36.d.ts +7 -7
- package/dist/index37.d.ts +6 -6
- package/dist/index38.d.ts +8 -8
- package/dist/index39.d.ts +1 -1
- package/dist/index4.d.ts +995 -995
- package/dist/index40.d.ts +2 -2
- package/dist/index8.d.ts +2 -2
- package/dist/index9.d.ts +2811 -3
- package/dist/inventory.d.ts +4 -4
- package/dist/inventory.js +2 -2
- package/dist/marketplace2.js +2 -2
- package/dist/metadata.d.ts +73 -73
- package/dist/primary-sale-checkout-options.d.ts +4 -4
- package/dist/quantityInput.js +1 -1
- package/dist/ranges.d.ts +17 -17
- package/dist/react/_internal/index.d.ts +1 -1
- package/dist/react/_internal/index.js +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react/queries/collectible/index.d.ts +1 -1
- package/dist/react/queries/index.d.ts +1 -1
- package/dist/react/ssr/index.d.ts +1 -1
- package/dist/react/ssr/index.js +2 -2
- package/dist/react/ui/components/marketplace-collectible-card/index.d.ts +1 -1
- package/dist/react/ui/components/marketplace-logos/index.d.ts +21 -21
- package/dist/react/ui/modals/CreateListingModal/internal/hooks/index.d.ts +1 -1
- package/dist/react/ui/modals/MakeOfferModal/internal/hooks/index.d.ts +1 -1
- package/dist/react/ui/modals/_internal/components/alertMessage/index.d.ts +2 -2
- package/dist/react/ui/modals/_internal/components/baseModal/index.d.ts +6 -6
- package/dist/react/ui/modals/_internal/components/calendar/index.d.ts +2 -2
- package/dist/react/ui/modals/_internal/components/calendarDropdown/index.d.ts +2 -2
- package/dist/react/ui/modals/_internal/components/currencyImage/index.d.ts +2 -2
- package/dist/react/ui/modals/_internal/components/currencyOptionsSelect/index.d.ts +3 -3
- package/dist/react/ui/modals/_internal/components/floorPriceText/index.d.ts +2 -2
- package/dist/react/ui/modals/_internal/components/priceInput/index.d.ts +3 -3
- package/dist/react/ui/modals/_internal/components/quantityInput/index.d.ts +2 -2
- package/dist/react/ui/modals/_internal/components/selectWaasFeeOptions/index.d.ts +2 -2
- package/dist/react/ui/modals/_internal/components/switchChainErrorModal/index.d.ts +2 -2
- package/dist/react/ui/modals/_internal/components/timeAgo/index.d.ts +2 -2
- package/dist/react/ui/modals/_internal/components/tokenPreview/index.d.ts +3 -3
- package/dist/react/ui/modals/_internal/components/transaction-footer/index.d.ts +3 -3
- package/dist/react/ui/modals/_internal/components/transactionDetails/index.d.ts +3 -3
- package/dist/react/ui/modals/_internal/components/transactionPreview/index.d.ts +3 -3
- package/dist/react/ui/modals/_internal/components/transactionStatusModal/index.d.ts +3 -3
- package/dist/react.js +2192 -1903
- package/dist/react.js.map +1 -1
- package/dist/token-balances.d.ts +28 -28
- package/dist/transaction-footer.js +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/url-state.js +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils.js +20 -4
- package/dist/utils.js.map +1 -1
- package/package.json +7 -5
- package/src/react/hooks/config/useMarketplaceConfig.test.tsx +1 -0
- package/src/react/hooks/transactions/useCancelTransactionSteps.tsx +4 -1
- package/src/react/hooks/utils/useEnsureCorrectChain.ts +10 -5
- package/src/react/ui/modals/BuyModal/components/BuyModalContent.tsx +34 -31
- package/src/react/ui/modals/BuyModal/components/CryptoPaymentModal.tsx +74 -11
- package/src/react/ui/modals/BuyModal/components/Modal.tsx +62 -1
- package/src/react/ui/modals/BuyModal/hooks/useExecuteBundledTransactions.ts +13 -26
- package/src/react/ui/modals/BuyModal/internal/__tests__/buildTrailsMarketBuyActions.test.ts +213 -0
- package/src/react/ui/modals/BuyModal/internal/buildTrailsMarketBuyActions.ts +259 -0
- package/src/react/ui/modals/BuyModal/internal/buyModalContext.ts +79 -10
- package/src/react/ui/modals/BuyModal/internal/cryptoPaymentModalContext.tsx +44 -17
- package/src/react/ui/modals/MakeOfferModal/internal/context.ts +2 -1
- package/src/react/ui/modals/_internal/components/currencyOptionsSelect/index.tsx +2 -1
- package/src/react/ui/modals/_internal/components/priceInput/index.tsx +12 -11
- package/src/react/ui/modals/_internal/helpers/currency.test.ts +27 -0
- package/src/react/ui/modals/_internal/helpers/currency.ts +4 -2
- package/src/utils/__tests__/getMarketplaceDetails.test.ts +10 -0
- package/src/utils/__tests__/getWebRPCErrorMessage.test.ts +28 -0
- package/src/utils/__tests__/marketplaceNormalization.test.ts +38 -0
- package/src/utils/getConduitAddressForOrderbook.ts +2 -10
- package/src/utils/getMarketplaceDetails.ts +11 -4
- package/src/utils/getWebRPCErrorMessage.ts +21 -0
- package/src/utils/normalizeMarketplace.ts +31 -0
package/dist/index9.d.ts
CHANGED
|
@@ -1,10 +1,2818 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { t as ClassProp } from "./index3.js";
|
|
3
|
+
import { CSSProperties, ComponentProps, ComponentType, JSX, ReactNode, SVGProps, useEffect } from "react";
|
|
3
4
|
import * as react_jsx_runtime from "react/jsx-runtime";
|
|
4
5
|
import { VariantProps } from "class-variance-authority";
|
|
5
6
|
|
|
6
|
-
//#region ../node_modules/.pnpm
|
|
7
|
+
//#region ../node_modules/.pnpm/motion-utils@12.39.0/node_modules/motion-utils/dist/index.d.ts
|
|
7
8
|
|
|
9
|
+
type EasingFunction = (v: number) => number;
|
|
10
|
+
type BezierDefinition = readonly [number, number, number, number];
|
|
11
|
+
type EasingDefinition = BezierDefinition | "linear" | "easeIn" | "easeOut" | "easeInOut" | "circIn" | "circOut" | "circInOut" | "backIn" | "backOut" | "backInOut" | "anticipate";
|
|
12
|
+
/**
|
|
13
|
+
* The easing function to use. Set as one of:
|
|
14
|
+
*
|
|
15
|
+
* - The name of an in-built easing function.
|
|
16
|
+
* - An array of four numbers to define a cubic bezier curve.
|
|
17
|
+
* - An easing function, that accepts and returns a progress value between `0` and `1`.
|
|
18
|
+
*
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
type Easing = EasingDefinition | EasingFunction;
|
|
22
|
+
interface Point {
|
|
23
|
+
x: number;
|
|
24
|
+
y: number;
|
|
25
|
+
}
|
|
26
|
+
interface Axis {
|
|
27
|
+
min: number;
|
|
28
|
+
max: number;
|
|
29
|
+
}
|
|
30
|
+
interface Box {
|
|
31
|
+
x: Axis;
|
|
32
|
+
y: Axis;
|
|
33
|
+
}
|
|
34
|
+
interface BoundingBox {
|
|
35
|
+
top: number;
|
|
36
|
+
right: number;
|
|
37
|
+
bottom: number;
|
|
38
|
+
left: number;
|
|
39
|
+
}
|
|
40
|
+
interface AxisDelta {
|
|
41
|
+
translate: number;
|
|
42
|
+
scale: number;
|
|
43
|
+
origin: number;
|
|
44
|
+
originPoint: number;
|
|
45
|
+
}
|
|
46
|
+
interface Delta {
|
|
47
|
+
x: AxisDelta;
|
|
48
|
+
y: AxisDelta;
|
|
49
|
+
}
|
|
50
|
+
type TransformPoint = (point: Point) => Point;
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region ../node_modules/.pnpm/motion-dom@12.40.0/node_modules/motion-dom/dist/index.d.ts
|
|
53
|
+
/**
|
|
54
|
+
* Passed in to pan event handlers like `onPan` the `PanInfo` object contains
|
|
55
|
+
* information about the current state of the tap gesture such as its
|
|
56
|
+
* `point`, `delta`, `offset` and `velocity`.
|
|
57
|
+
*
|
|
58
|
+
* ```jsx
|
|
59
|
+
* <motion.div onPan={(event, info) => {
|
|
60
|
+
* console.log(info.point.x, info.point.y)
|
|
61
|
+
* }} />
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @public
|
|
65
|
+
*/
|
|
66
|
+
interface PanInfo {
|
|
67
|
+
/**
|
|
68
|
+
* Contains `x` and `y` values for the current pan position relative
|
|
69
|
+
* to the device or page.
|
|
70
|
+
*
|
|
71
|
+
* ```jsx
|
|
72
|
+
* function onPan(event, info) {
|
|
73
|
+
* console.log(info.point.x, info.point.y)
|
|
74
|
+
* }
|
|
75
|
+
*
|
|
76
|
+
* <motion.div onPan={onPan} />
|
|
77
|
+
* ```
|
|
78
|
+
*
|
|
79
|
+
* @public
|
|
80
|
+
*/
|
|
81
|
+
point: Point;
|
|
82
|
+
/**
|
|
83
|
+
* Contains `x` and `y` values for the distance moved since
|
|
84
|
+
* the last event.
|
|
85
|
+
*
|
|
86
|
+
* ```jsx
|
|
87
|
+
* function onPan(event, info) {
|
|
88
|
+
* console.log(info.delta.x, info.delta.y)
|
|
89
|
+
* }
|
|
90
|
+
*
|
|
91
|
+
* <motion.div onPan={onPan} />
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* @public
|
|
95
|
+
*/
|
|
96
|
+
delta: Point;
|
|
97
|
+
/**
|
|
98
|
+
* Contains `x` and `y` values for the distance moved from
|
|
99
|
+
* the first pan event.
|
|
100
|
+
*
|
|
101
|
+
* ```jsx
|
|
102
|
+
* function onPan(event, info) {
|
|
103
|
+
* console.log(info.offset.x, info.offset.y)
|
|
104
|
+
* }
|
|
105
|
+
*
|
|
106
|
+
* <motion.div onPan={onPan} />
|
|
107
|
+
* ```
|
|
108
|
+
*
|
|
109
|
+
* @public
|
|
110
|
+
*/
|
|
111
|
+
offset: Point;
|
|
112
|
+
/**
|
|
113
|
+
* Contains `x` and `y` values for the current velocity of the pointer, in px/ms.
|
|
114
|
+
*
|
|
115
|
+
* ```jsx
|
|
116
|
+
* function onPan(event, info) {
|
|
117
|
+
* console.log(info.velocity.x, info.velocity.y)
|
|
118
|
+
* }
|
|
119
|
+
*
|
|
120
|
+
* <motion.div onPan={onPan} />
|
|
121
|
+
* ```
|
|
122
|
+
*
|
|
123
|
+
* @public
|
|
124
|
+
*/
|
|
125
|
+
velocity: Point;
|
|
126
|
+
}
|
|
127
|
+
type DragElastic = boolean | number | Partial<BoundingBox>;
|
|
128
|
+
interface EventInfo {
|
|
129
|
+
point: Point;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* A generic set of string/number values
|
|
133
|
+
*/
|
|
134
|
+
interface ResolvedValues$1 {
|
|
135
|
+
[key: string]: AnyResolvedKeyframe;
|
|
136
|
+
}
|
|
137
|
+
type AnimationDefinition = VariantLabels | TargetAndTransition | TargetResolver;
|
|
138
|
+
/**
|
|
139
|
+
* An object that specifies values to animate to. Each value may be set either as
|
|
140
|
+
* a single value, or an array of values.
|
|
141
|
+
*
|
|
142
|
+
* It may also option contain these properties:
|
|
143
|
+
*
|
|
144
|
+
* - `transition`: Specifies transitions for all or individual values.
|
|
145
|
+
* - `transitionEnd`: Specifies values to set when the animation finishes.
|
|
146
|
+
*
|
|
147
|
+
* ```jsx
|
|
148
|
+
* const target = {
|
|
149
|
+
* x: "0%",
|
|
150
|
+
* opacity: 0,
|
|
151
|
+
* transition: { duration: 1 },
|
|
152
|
+
* transitionEnd: { display: "none" }
|
|
153
|
+
* }
|
|
154
|
+
* ```
|
|
155
|
+
*
|
|
156
|
+
* @public
|
|
157
|
+
*/
|
|
158
|
+
type TargetAndTransition = Target & {
|
|
159
|
+
transition?: Transition;
|
|
160
|
+
transitionEnd?: ResolvedValues$1;
|
|
161
|
+
};
|
|
162
|
+
type TargetResolver = (custom: any, current: ResolvedValues$1, velocity: ResolvedValues$1) => TargetAndTransition | string;
|
|
163
|
+
/**
|
|
164
|
+
* Either a string, or array of strings, that reference variants defined via the `variants` prop.
|
|
165
|
+
* @public
|
|
166
|
+
*/
|
|
167
|
+
type VariantLabels = string | string[];
|
|
168
|
+
type Variant = TargetAndTransition | TargetResolver;
|
|
169
|
+
interface Variants {
|
|
170
|
+
[key: string]: Variant;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* @deprecated
|
|
174
|
+
*/
|
|
175
|
+
type LegacyAnimationControls = {
|
|
176
|
+
/**
|
|
177
|
+
* Subscribes a component's animation controls to this.
|
|
178
|
+
*
|
|
179
|
+
* @param controls - The controls to subscribe
|
|
180
|
+
* @returns An unsubscribe function.
|
|
181
|
+
*/
|
|
182
|
+
subscribe(visualElement: any): () => void;
|
|
183
|
+
/**
|
|
184
|
+
* Starts an animation on all linked components.
|
|
185
|
+
*
|
|
186
|
+
* @remarks
|
|
187
|
+
*
|
|
188
|
+
* ```jsx
|
|
189
|
+
* controls.start("variantLabel")
|
|
190
|
+
* controls.start({
|
|
191
|
+
* x: 0,
|
|
192
|
+
* transition: { duration: 1 }
|
|
193
|
+
* })
|
|
194
|
+
* ```
|
|
195
|
+
*
|
|
196
|
+
* @param definition - Properties or variant label to animate to
|
|
197
|
+
* @param transition - Optional `transition` to apply to a variant
|
|
198
|
+
* @returns - A `Promise` that resolves when all animations have completed.
|
|
199
|
+
*
|
|
200
|
+
* @public
|
|
201
|
+
*/
|
|
202
|
+
start(definition: AnimationDefinition, transitionOverride?: Transition): Promise<any>;
|
|
203
|
+
/**
|
|
204
|
+
* Instantly set to a set of properties or a variant.
|
|
205
|
+
*
|
|
206
|
+
* ```jsx
|
|
207
|
+
* // With properties
|
|
208
|
+
* controls.set({ opacity: 0 })
|
|
209
|
+
*
|
|
210
|
+
* // With variants
|
|
211
|
+
* controls.set("hidden")
|
|
212
|
+
* ```
|
|
213
|
+
*
|
|
214
|
+
* @privateRemarks
|
|
215
|
+
* We could perform a similar trick to `.start` where this can be called before mount
|
|
216
|
+
* and we maintain a list of of pending actions that get applied on mount. But the
|
|
217
|
+
* expectation of `set` is that it happens synchronously and this would be difficult
|
|
218
|
+
* to do before any children have even attached themselves. It's also poor practise
|
|
219
|
+
* and we should discourage render-synchronous `.start` calls rather than lean into this.
|
|
220
|
+
*
|
|
221
|
+
* @public
|
|
222
|
+
*/
|
|
223
|
+
set(definition: AnimationDefinition): void;
|
|
224
|
+
/**
|
|
225
|
+
* Stops animations on all linked components.
|
|
226
|
+
*
|
|
227
|
+
* ```jsx
|
|
228
|
+
* controls.stop()
|
|
229
|
+
* ```
|
|
230
|
+
*
|
|
231
|
+
* @public
|
|
232
|
+
*/
|
|
233
|
+
stop(): void;
|
|
234
|
+
mount(): () => void;
|
|
235
|
+
};
|
|
236
|
+
interface MotionNodeAnimationOptions {
|
|
237
|
+
/**
|
|
238
|
+
* Properties, variant label or array of variant labels to start in.
|
|
239
|
+
*
|
|
240
|
+
* Set to `false` to initialise with the values in `animate` (disabling the mount animation)
|
|
241
|
+
*
|
|
242
|
+
* ```jsx
|
|
243
|
+
* // As values
|
|
244
|
+
* <motion.div initial={{ opacity: 1 }} />
|
|
245
|
+
*
|
|
246
|
+
* // As variant
|
|
247
|
+
* <motion.div initial="visible" variants={variants} />
|
|
248
|
+
*
|
|
249
|
+
* // Multiple variants
|
|
250
|
+
* <motion.div initial={["visible", "active"]} variants={variants} />
|
|
251
|
+
*
|
|
252
|
+
* // As false (disable mount animation)
|
|
253
|
+
* <motion.div initial={false} animate={{ opacity: 0 }} />
|
|
254
|
+
* ```
|
|
255
|
+
*/
|
|
256
|
+
initial?: TargetAndTransition | VariantLabels | boolean;
|
|
257
|
+
/**
|
|
258
|
+
* Values to animate to, variant label(s), or `LegacyAnimationControls`.
|
|
259
|
+
*
|
|
260
|
+
* ```jsx
|
|
261
|
+
* // As values
|
|
262
|
+
* <motion.div animate={{ opacity: 1 }} />
|
|
263
|
+
*
|
|
264
|
+
* // As variant
|
|
265
|
+
* <motion.div animate="visible" variants={variants} />
|
|
266
|
+
*
|
|
267
|
+
* // Multiple variants
|
|
268
|
+
* <motion.div animate={["visible", "active"]} variants={variants} />
|
|
269
|
+
*
|
|
270
|
+
* // LegacyAnimationControls
|
|
271
|
+
* <motion.div animate={animation} />
|
|
272
|
+
* ```
|
|
273
|
+
*/
|
|
274
|
+
animate?: TargetAndTransition | VariantLabels | boolean | LegacyAnimationControls;
|
|
275
|
+
/**
|
|
276
|
+
* A target to animate to when this component is removed from the tree.
|
|
277
|
+
*
|
|
278
|
+
* This component **must** be the first animatable child of an `AnimatePresence` to enable this exit animation.
|
|
279
|
+
*
|
|
280
|
+
* This limitation exists because React doesn't allow components to defer unmounting until after
|
|
281
|
+
* an animation is complete. Once this limitation is fixed, the `AnimatePresence` component will be unnecessary.
|
|
282
|
+
*
|
|
283
|
+
* ```jsx
|
|
284
|
+
* import { AnimatePresence, motion } from 'framer-motion'
|
|
285
|
+
*
|
|
286
|
+
* export const MyComponent = ({ isVisible }) => {
|
|
287
|
+
* return (
|
|
288
|
+
* <AnimatePresence>
|
|
289
|
+
* {isVisible && (
|
|
290
|
+
* <motion.div
|
|
291
|
+
* initial={{ opacity: 0 }}
|
|
292
|
+
* animate={{ opacity: 1 }}
|
|
293
|
+
* exit={{ opacity: 0 }}
|
|
294
|
+
* />
|
|
295
|
+
* )}
|
|
296
|
+
* </AnimatePresence>
|
|
297
|
+
* )
|
|
298
|
+
* }
|
|
299
|
+
* ```
|
|
300
|
+
*/
|
|
301
|
+
exit?: TargetAndTransition | VariantLabels;
|
|
302
|
+
/**
|
|
303
|
+
* Variants allow you to define animation states and organise them by name. They allow
|
|
304
|
+
* you to control animations throughout a component tree by switching a single `animate` prop.
|
|
305
|
+
*
|
|
306
|
+
* Using `transition` options like `delayChildren` and `when`, you can orchestrate
|
|
307
|
+
* when children animations play relative to their parent.
|
|
308
|
+
*
|
|
309
|
+
* After passing variants to one or more `motion` component's `variants` prop, these variants
|
|
310
|
+
* can be used in place of values on the `animate`, `initial`, `whileFocus`, `whileTap` and `whileHover` props.
|
|
311
|
+
*
|
|
312
|
+
* ```jsx
|
|
313
|
+
* const variants = {
|
|
314
|
+
* active: {
|
|
315
|
+
* backgroundColor: "#f00"
|
|
316
|
+
* },
|
|
317
|
+
* inactive: {
|
|
318
|
+
* backgroundColor: "#fff",
|
|
319
|
+
* transition: { duration: 2 }
|
|
320
|
+
* }
|
|
321
|
+
* }
|
|
322
|
+
*
|
|
323
|
+
* <motion.div variants={variants} animate="active" />
|
|
324
|
+
* ```
|
|
325
|
+
*/
|
|
326
|
+
variants?: Variants;
|
|
327
|
+
/**
|
|
328
|
+
* Default transition. If no `transition` is defined in `animate`, it will use the transition defined here.
|
|
329
|
+
* ```jsx
|
|
330
|
+
* const spring = {
|
|
331
|
+
* type: "spring",
|
|
332
|
+
* damping: 10,
|
|
333
|
+
* stiffness: 100
|
|
334
|
+
* }
|
|
335
|
+
*
|
|
336
|
+
* <motion.div transition={spring} animate={{ scale: 1.2 }} />
|
|
337
|
+
* ```
|
|
338
|
+
*/
|
|
339
|
+
transition?: Transition;
|
|
340
|
+
}
|
|
341
|
+
interface MotionNodeEventOptions {
|
|
342
|
+
/**
|
|
343
|
+
* Callback with latest motion values, fired max once per frame.
|
|
344
|
+
*
|
|
345
|
+
* ```jsx
|
|
346
|
+
* function onUpdate(latest) {
|
|
347
|
+
* console.log(latest.x, latest.opacity)
|
|
348
|
+
* }
|
|
349
|
+
*
|
|
350
|
+
* <motion.div animate={{ x: 100, opacity: 0 }} onUpdate={onUpdate} />
|
|
351
|
+
* ```
|
|
352
|
+
*/
|
|
353
|
+
onUpdate?(latest: ResolvedValues$1): void;
|
|
354
|
+
/**
|
|
355
|
+
* Callback when animation defined in `animate` begins.
|
|
356
|
+
*
|
|
357
|
+
* The provided callback will be called with the triggering animation definition.
|
|
358
|
+
* If this is a variant, it'll be the variant name, and if a target object
|
|
359
|
+
* then it'll be the target object.
|
|
360
|
+
*
|
|
361
|
+
* This way, it's possible to figure out which animation has started.
|
|
362
|
+
*
|
|
363
|
+
* ```jsx
|
|
364
|
+
* function onStart() {
|
|
365
|
+
* console.log("Animation started")
|
|
366
|
+
* }
|
|
367
|
+
*
|
|
368
|
+
* <motion.div animate={{ x: 100 }} onAnimationStart={onStart} />
|
|
369
|
+
* ```
|
|
370
|
+
*/
|
|
371
|
+
onAnimationStart?(definition: AnimationDefinition): void;
|
|
372
|
+
/**
|
|
373
|
+
* Callback when animation defined in `animate` is complete.
|
|
374
|
+
*
|
|
375
|
+
* The provided callback will be called with the triggering animation definition.
|
|
376
|
+
* If this is a variant, it'll be the variant name, and if a target object
|
|
377
|
+
* then it'll be the target object.
|
|
378
|
+
*
|
|
379
|
+
* This way, it's possible to figure out which animation has completed.
|
|
380
|
+
*
|
|
381
|
+
* ```jsx
|
|
382
|
+
* function onComplete() {
|
|
383
|
+
* console.log("Animation completed")
|
|
384
|
+
* }
|
|
385
|
+
*
|
|
386
|
+
* <motion.div
|
|
387
|
+
* animate={{ x: 100 }}
|
|
388
|
+
* onAnimationComplete={definition => {
|
|
389
|
+
* console.log('Completed animating', definition)
|
|
390
|
+
* }}
|
|
391
|
+
* />
|
|
392
|
+
* ```
|
|
393
|
+
*/
|
|
394
|
+
onAnimationComplete?(definition: AnimationDefinition): void;
|
|
395
|
+
onBeforeLayoutMeasure?(box: Box): void;
|
|
396
|
+
onLayoutMeasure?(box: Box, prevBox: Box): void;
|
|
397
|
+
onLayoutAnimationStart?(): void;
|
|
398
|
+
onLayoutAnimationComplete?(): void;
|
|
399
|
+
}
|
|
400
|
+
interface MotionNodePanHandlers {
|
|
401
|
+
/**
|
|
402
|
+
* Callback function that fires when the pan gesture is recognised on this element.
|
|
403
|
+
*
|
|
404
|
+
* **Note:** For pan gestures to work correctly with touch input, the element needs
|
|
405
|
+
* touch scrolling to be disabled on either x/y or both axis with the
|
|
406
|
+
* [touch-action](https://developer.mozilla.org/en-US/docs/Web/CSS/touch-action) CSS rule.
|
|
407
|
+
*
|
|
408
|
+
* ```jsx
|
|
409
|
+
* function onPan(event, info) {
|
|
410
|
+
* console.log(info.point.x, info.point.y)
|
|
411
|
+
* }
|
|
412
|
+
*
|
|
413
|
+
* <motion.div onPan={onPan} />
|
|
414
|
+
* ```
|
|
415
|
+
*
|
|
416
|
+
* @param event - The originating pointer event.
|
|
417
|
+
* @param info - A {@link PanInfo} object containing `x` and `y` values for:
|
|
418
|
+
*
|
|
419
|
+
* - `point`: Relative to the device or page.
|
|
420
|
+
* - `delta`: Distance moved since the last event.
|
|
421
|
+
* - `offset`: Offset from the original pan event.
|
|
422
|
+
* - `velocity`: Current velocity of the pointer.
|
|
423
|
+
*/
|
|
424
|
+
onPan?(event: PointerEvent, info: PanInfo): void;
|
|
425
|
+
/**
|
|
426
|
+
* Callback function that fires when the pan gesture begins on this element.
|
|
427
|
+
*
|
|
428
|
+
* ```jsx
|
|
429
|
+
* function onPanStart(event, info) {
|
|
430
|
+
* console.log(info.point.x, info.point.y)
|
|
431
|
+
* }
|
|
432
|
+
*
|
|
433
|
+
* <motion.div onPanStart={onPanStart} />
|
|
434
|
+
* ```
|
|
435
|
+
*
|
|
436
|
+
* @param event - The originating pointer event.
|
|
437
|
+
* @param info - A {@link PanInfo} object containing `x`/`y` values for:
|
|
438
|
+
*
|
|
439
|
+
* - `point`: Relative to the device or page.
|
|
440
|
+
* - `delta`: Distance moved since the last event.
|
|
441
|
+
* - `offset`: Offset from the original pan event.
|
|
442
|
+
* - `velocity`: Current velocity of the pointer.
|
|
443
|
+
*/
|
|
444
|
+
onPanStart?(event: PointerEvent, info: PanInfo): void;
|
|
445
|
+
/**
|
|
446
|
+
* Callback function that fires when we begin detecting a pan gesture. This
|
|
447
|
+
* is analogous to `onMouseStart` or `onTouchStart`.
|
|
448
|
+
*
|
|
449
|
+
* ```jsx
|
|
450
|
+
* function onPanSessionStart(event, info) {
|
|
451
|
+
* console.log(info.point.x, info.point.y)
|
|
452
|
+
* }
|
|
453
|
+
*
|
|
454
|
+
* <motion.div onPanSessionStart={onPanSessionStart} />
|
|
455
|
+
* ```
|
|
456
|
+
*
|
|
457
|
+
* @param event - The originating pointer event.
|
|
458
|
+
* @param info - An {@link EventInfo} object containing `x`/`y` values for:
|
|
459
|
+
*
|
|
460
|
+
* - `point`: Relative to the device or page.
|
|
461
|
+
*/
|
|
462
|
+
onPanSessionStart?(event: PointerEvent, info: EventInfo): void;
|
|
463
|
+
/**
|
|
464
|
+
* Callback function that fires when the pan gesture ends on this element.
|
|
465
|
+
*
|
|
466
|
+
* ```jsx
|
|
467
|
+
* function onPanEnd(event, info) {
|
|
468
|
+
* console.log(info.point.x, info.point.y)
|
|
469
|
+
* }
|
|
470
|
+
*
|
|
471
|
+
* <motion.div onPanEnd={onPanEnd} />
|
|
472
|
+
* ```
|
|
473
|
+
*
|
|
474
|
+
* @param event - The originating pointer event.
|
|
475
|
+
* @param info - A {@link PanInfo} object containing `x`/`y` values for:
|
|
476
|
+
*
|
|
477
|
+
* - `point`: Relative to the device or page.
|
|
478
|
+
* - `delta`: Distance moved since the last event.
|
|
479
|
+
* - `offset`: Offset from the original pan event.
|
|
480
|
+
* - `velocity`: Current velocity of the pointer.
|
|
481
|
+
*/
|
|
482
|
+
onPanEnd?(event: PointerEvent, info: PanInfo): void;
|
|
483
|
+
}
|
|
484
|
+
interface MotionNodeHoverHandlers {
|
|
485
|
+
/**
|
|
486
|
+
* Properties or variant label to animate to while the hover gesture is recognised.
|
|
487
|
+
*
|
|
488
|
+
* ```jsx
|
|
489
|
+
* <motion.div whileHover={{ scale: 1.2 }} />
|
|
490
|
+
* ```
|
|
491
|
+
*/
|
|
492
|
+
whileHover?: VariantLabels | TargetAndTransition;
|
|
493
|
+
/**
|
|
494
|
+
* Callback function that fires when pointer starts hovering over the component.
|
|
495
|
+
*
|
|
496
|
+
* ```jsx
|
|
497
|
+
* <motion.div onHoverStart={() => console.log('Hover starts')} />
|
|
498
|
+
* ```
|
|
499
|
+
*/
|
|
500
|
+
onHoverStart?(event: PointerEvent, info: EventInfo): void;
|
|
501
|
+
/**
|
|
502
|
+
* Callback function that fires when pointer stops hovering over the component.
|
|
503
|
+
*
|
|
504
|
+
* ```jsx
|
|
505
|
+
* <motion.div onHoverEnd={() => console.log("Hover ends")} />
|
|
506
|
+
* ```
|
|
507
|
+
*/
|
|
508
|
+
onHoverEnd?(event: PointerEvent, info: EventInfo): void;
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* Passed in to tap event handlers like `onTap` the `TapInfo` object contains
|
|
512
|
+
* information about the tap gesture such as it‘s location.
|
|
513
|
+
*
|
|
514
|
+
* ```jsx
|
|
515
|
+
* function onTap(event, info) {
|
|
516
|
+
* console.log(info.point.x, info.point.y)
|
|
517
|
+
* }
|
|
518
|
+
*
|
|
519
|
+
* <motion.div onTap={onTap} />
|
|
520
|
+
* ```
|
|
521
|
+
*
|
|
522
|
+
* @public
|
|
523
|
+
*/
|
|
524
|
+
interface TapInfo {
|
|
525
|
+
/**
|
|
526
|
+
* Contains `x` and `y` values for the tap gesture relative to the
|
|
527
|
+
* device or page.
|
|
528
|
+
*
|
|
529
|
+
* ```jsx
|
|
530
|
+
* function onTapStart(event, info) {
|
|
531
|
+
* console.log(info.point.x, info.point.y)
|
|
532
|
+
* }
|
|
533
|
+
*
|
|
534
|
+
* <motion.div onTapStart={onTapStart} />
|
|
535
|
+
* ```
|
|
536
|
+
*
|
|
537
|
+
* @public
|
|
538
|
+
*/
|
|
539
|
+
point: Point;
|
|
540
|
+
}
|
|
541
|
+
interface MotionNodeTapHandlers {
|
|
542
|
+
/**
|
|
543
|
+
* Callback when the tap gesture successfully ends on this element.
|
|
544
|
+
*
|
|
545
|
+
* ```jsx
|
|
546
|
+
* function onTap(event, info) {
|
|
547
|
+
* console.log(info.point.x, info.point.y)
|
|
548
|
+
* }
|
|
549
|
+
*
|
|
550
|
+
* <motion.div onTap={onTap} />
|
|
551
|
+
* ```
|
|
552
|
+
*
|
|
553
|
+
* @param event - The originating pointer event.
|
|
554
|
+
* @param info - An {@link TapInfo} object containing `x` and `y` values for the `point` relative to the device or page.
|
|
555
|
+
*/
|
|
556
|
+
onTap?(event: MouseEvent | TouchEvent | PointerEvent, info: TapInfo): void;
|
|
557
|
+
/**
|
|
558
|
+
* Callback when the tap gesture starts on this element.
|
|
559
|
+
*
|
|
560
|
+
* ```jsx
|
|
561
|
+
* function onTapStart(event, info) {
|
|
562
|
+
* console.log(info.point.x, info.point.y)
|
|
563
|
+
* }
|
|
564
|
+
*
|
|
565
|
+
* <motion.div onTapStart={onTapStart} />
|
|
566
|
+
* ```
|
|
567
|
+
*
|
|
568
|
+
* @param event - The originating pointer event.
|
|
569
|
+
* @param info - An {@link TapInfo} object containing `x` and `y` values for the `point` relative to the device or page.
|
|
570
|
+
*/
|
|
571
|
+
onTapStart?(event: MouseEvent | TouchEvent | PointerEvent, info: TapInfo): void;
|
|
572
|
+
/**
|
|
573
|
+
* Callback when the tap gesture ends outside this element.
|
|
574
|
+
*
|
|
575
|
+
* ```jsx
|
|
576
|
+
* function onTapCancel(event, info) {
|
|
577
|
+
* console.log(info.point.x, info.point.y)
|
|
578
|
+
* }
|
|
579
|
+
*
|
|
580
|
+
* <motion.div onTapCancel={onTapCancel} />
|
|
581
|
+
* ```
|
|
582
|
+
*
|
|
583
|
+
* @param event - The originating pointer event.
|
|
584
|
+
* @param info - An {@link TapInfo} object containing `x` and `y` values for the `point` relative to the device or page.
|
|
585
|
+
*/
|
|
586
|
+
onTapCancel?(event: MouseEvent | TouchEvent | PointerEvent, info: TapInfo): void;
|
|
587
|
+
/**
|
|
588
|
+
* Properties or variant label to animate to while the component is pressed.
|
|
589
|
+
*
|
|
590
|
+
* ```jsx
|
|
591
|
+
* <motion.div whileTap={{ scale: 0.8 }} />
|
|
592
|
+
* ```
|
|
593
|
+
*/
|
|
594
|
+
whileTap?: VariantLabels | TargetAndTransition;
|
|
595
|
+
/**
|
|
596
|
+
* If `true`, the tap gesture will attach its start listener to window.
|
|
597
|
+
*
|
|
598
|
+
* Note: This is not supported publically.
|
|
599
|
+
*/
|
|
600
|
+
globalTapTarget?: boolean;
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* @deprecated - Use MotionNodeTapHandlers
|
|
604
|
+
*/
|
|
605
|
+
|
|
606
|
+
interface MotionNodeFocusHandlers {
|
|
607
|
+
/**
|
|
608
|
+
* Properties or variant label to animate to while the focus gesture is recognised.
|
|
609
|
+
*
|
|
610
|
+
* ```jsx
|
|
611
|
+
* <motion.input whileFocus={{ scale: 1.2 }} />
|
|
612
|
+
* ```
|
|
613
|
+
*/
|
|
614
|
+
whileFocus?: VariantLabels | TargetAndTransition;
|
|
615
|
+
}
|
|
616
|
+
/**
|
|
617
|
+
* TODO: Replace with types from inView()
|
|
618
|
+
*/
|
|
619
|
+
type ViewportEventHandler = (entry: IntersectionObserverEntry | null) => void;
|
|
620
|
+
interface ViewportOptions {
|
|
621
|
+
root?: {
|
|
622
|
+
current: Element | null;
|
|
623
|
+
};
|
|
624
|
+
once?: boolean;
|
|
625
|
+
margin?: string;
|
|
626
|
+
amount?: "some" | "all" | number;
|
|
627
|
+
}
|
|
628
|
+
interface MotionNodeViewportOptions {
|
|
629
|
+
whileInView?: VariantLabels | TargetAndTransition;
|
|
630
|
+
onViewportEnter?: ViewportEventHandler;
|
|
631
|
+
onViewportLeave?: ViewportEventHandler;
|
|
632
|
+
viewport?: ViewportOptions;
|
|
633
|
+
}
|
|
634
|
+
interface MotionNodeDraggableOptions {
|
|
635
|
+
/**
|
|
636
|
+
* Enable dragging for this element. Set to `false` by default.
|
|
637
|
+
* Set `true` to drag in both directions.
|
|
638
|
+
* Set `"x"` or `"y"` to only drag in a specific direction.
|
|
639
|
+
*
|
|
640
|
+
* ```jsx
|
|
641
|
+
* <motion.div drag="x" />
|
|
642
|
+
* ```
|
|
643
|
+
*/
|
|
644
|
+
drag?: boolean | "x" | "y";
|
|
645
|
+
/**
|
|
646
|
+
* Properties or variant label to animate to while the drag gesture is recognised.
|
|
647
|
+
*
|
|
648
|
+
* ```jsx
|
|
649
|
+
* <motion.div whileDrag={{ scale: 1.2 }} />
|
|
650
|
+
* ```
|
|
651
|
+
*/
|
|
652
|
+
whileDrag?: VariantLabels | TargetAndTransition;
|
|
653
|
+
/**
|
|
654
|
+
* If `true`, this will lock dragging to the initially-detected direction. Defaults to `false`.
|
|
655
|
+
*
|
|
656
|
+
* ```jsx
|
|
657
|
+
* <motion.div drag dragDirectionLock />
|
|
658
|
+
* ```
|
|
659
|
+
*/
|
|
660
|
+
dragDirectionLock?: boolean;
|
|
661
|
+
/**
|
|
662
|
+
* Allows drag gesture propagation to child components. Set to `false` by
|
|
663
|
+
* default.
|
|
664
|
+
*
|
|
665
|
+
* ```jsx
|
|
666
|
+
* <motion.div drag="x" dragPropagation />
|
|
667
|
+
* ```
|
|
668
|
+
*/
|
|
669
|
+
dragPropagation?: boolean;
|
|
670
|
+
/**
|
|
671
|
+
* Applies constraints on the permitted draggable area.
|
|
672
|
+
*
|
|
673
|
+
* It can accept an object of optional `top`, `left`, `right`, and `bottom` values, measured in pixels.
|
|
674
|
+
* This will define a distance from the named edge of the draggable component.
|
|
675
|
+
*
|
|
676
|
+
* Alternatively, it can accept a `ref` to another component created with React's `useRef` hook.
|
|
677
|
+
* This `ref` should be passed both to the draggable component's `dragConstraints` prop, and the `ref`
|
|
678
|
+
* of the component you want to use as constraints.
|
|
679
|
+
*
|
|
680
|
+
* ```jsx
|
|
681
|
+
* // In pixels
|
|
682
|
+
* <motion.div
|
|
683
|
+
* drag="x"
|
|
684
|
+
* dragConstraints={{ left: 0, right: 300 }}
|
|
685
|
+
* />
|
|
686
|
+
*
|
|
687
|
+
* // As a ref to another component
|
|
688
|
+
* const MyComponent = () => {
|
|
689
|
+
* const constraintsRef = useRef(null)
|
|
690
|
+
*
|
|
691
|
+
* return (
|
|
692
|
+
* <motion.div ref={constraintsRef}>
|
|
693
|
+
* <motion.div drag dragConstraints={constraintsRef} />
|
|
694
|
+
* </motion.div>
|
|
695
|
+
* )
|
|
696
|
+
* }
|
|
697
|
+
* ```
|
|
698
|
+
*/
|
|
699
|
+
dragConstraints?: false | Partial<BoundingBox> | {
|
|
700
|
+
current: Element | null;
|
|
701
|
+
};
|
|
702
|
+
/**
|
|
703
|
+
* The degree of movement allowed outside constraints. 0 = no movement, 1 =
|
|
704
|
+
* full movement.
|
|
705
|
+
*
|
|
706
|
+
* Set to `0.5` by default. Can also be set as `false` to disable movement.
|
|
707
|
+
*
|
|
708
|
+
* By passing an object of `top`/`right`/`bottom`/`left`, individual values can be set
|
|
709
|
+
* per constraint. Any missing values will be set to `0`.
|
|
710
|
+
*
|
|
711
|
+
* ```jsx
|
|
712
|
+
* <motion.div
|
|
713
|
+
* drag
|
|
714
|
+
* dragConstraints={{ left: 0, right: 300 }}
|
|
715
|
+
* dragElastic={0.2}
|
|
716
|
+
* />
|
|
717
|
+
* ```
|
|
718
|
+
*/
|
|
719
|
+
dragElastic?: DragElastic;
|
|
720
|
+
/**
|
|
721
|
+
* Apply momentum from the pan gesture to the component when dragging
|
|
722
|
+
* finishes. Set to `true` by default.
|
|
723
|
+
*
|
|
724
|
+
* ```jsx
|
|
725
|
+
* <motion.div
|
|
726
|
+
* drag
|
|
727
|
+
* dragConstraints={{ left: 0, right: 300 }}
|
|
728
|
+
* dragMomentum={false}
|
|
729
|
+
* />
|
|
730
|
+
* ```
|
|
731
|
+
*/
|
|
732
|
+
dragMomentum?: boolean;
|
|
733
|
+
/**
|
|
734
|
+
* Allows you to change dragging inertia parameters.
|
|
735
|
+
* 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.
|
|
736
|
+
* See {@link https://motion.dev/docs/react-motion-component#dragtransition | Inertia} for all properties you can use.
|
|
737
|
+
*
|
|
738
|
+
* ```jsx
|
|
739
|
+
* <motion.div
|
|
740
|
+
* drag
|
|
741
|
+
* dragTransition={{ bounceStiffness: 600, bounceDamping: 10 }}
|
|
742
|
+
* />
|
|
743
|
+
* ```
|
|
744
|
+
*/
|
|
745
|
+
dragTransition?: InertiaOptions;
|
|
746
|
+
/**
|
|
747
|
+
* Usually, dragging is initiated by pressing down on a component and moving it. For some
|
|
748
|
+
* use-cases, for instance clicking at an arbitrary point on a video scrubber, we
|
|
749
|
+
* might want to initiate dragging from a different component than the draggable one.
|
|
750
|
+
*
|
|
751
|
+
* By creating a `dragControls` using the `useDragControls` hook, we can pass this into
|
|
752
|
+
* the draggable component's `dragControls` prop. It exposes a `start` method
|
|
753
|
+
* that can start dragging from pointer events on other components.
|
|
754
|
+
*
|
|
755
|
+
* ```jsx
|
|
756
|
+
* const dragControls = useDragControls()
|
|
757
|
+
*
|
|
758
|
+
* function startDrag(event) {
|
|
759
|
+
* dragControls.start(event, { snapToCursor: true })
|
|
760
|
+
* }
|
|
761
|
+
*
|
|
762
|
+
* return (
|
|
763
|
+
* <>
|
|
764
|
+
* <div onPointerDown={startDrag} />
|
|
765
|
+
* <motion.div drag="x" dragControls={dragControls} />
|
|
766
|
+
* </>
|
|
767
|
+
* )
|
|
768
|
+
* ```
|
|
769
|
+
*/
|
|
770
|
+
dragControls?: any;
|
|
771
|
+
/**
|
|
772
|
+
* If `true`, element will snap back to its origin when dragging ends.
|
|
773
|
+
* Set to `"x"` or `"y"` to only snap back on a specific axis.
|
|
774
|
+
*
|
|
775
|
+
* Enabling this is the equivalent of setting all `dragConstraints` axes to `0`
|
|
776
|
+
* with `dragElastic={1}`, but when used together `dragConstraints` can define
|
|
777
|
+
* a wider draggable area and `dragSnapToOrigin` will ensure the element
|
|
778
|
+
* animates back to its origin on release.
|
|
779
|
+
*/
|
|
780
|
+
dragSnapToOrigin?: boolean | "x" | "y";
|
|
781
|
+
/**
|
|
782
|
+
* By default, if `drag` is defined on a component then an event listener will be attached
|
|
783
|
+
* to automatically initiate dragging when a user presses down on it.
|
|
784
|
+
*
|
|
785
|
+
* By setting `dragListener` to `false`, this event listener will not be created.
|
|
786
|
+
*
|
|
787
|
+
* ```jsx
|
|
788
|
+
* const dragControls = useDragControls()
|
|
789
|
+
*
|
|
790
|
+
* function startDrag(event) {
|
|
791
|
+
* dragControls.start(event, { snapToCursor: true })
|
|
792
|
+
* }
|
|
793
|
+
*
|
|
794
|
+
* return (
|
|
795
|
+
* <>
|
|
796
|
+
* <div onPointerDown={startDrag} />
|
|
797
|
+
* <motion.div
|
|
798
|
+
* drag="x"
|
|
799
|
+
* dragControls={dragControls}
|
|
800
|
+
* dragListener={false}
|
|
801
|
+
* />
|
|
802
|
+
* </>
|
|
803
|
+
* )
|
|
804
|
+
* ```
|
|
805
|
+
*/
|
|
806
|
+
dragListener?: boolean;
|
|
807
|
+
/**
|
|
808
|
+
* If `dragConstraints` is set to a React ref, this callback will call with the measured drag constraints.
|
|
809
|
+
*
|
|
810
|
+
* @public
|
|
811
|
+
*/
|
|
812
|
+
onMeasureDragConstraints?: (constraints: BoundingBox) => BoundingBox | void;
|
|
813
|
+
/**
|
|
814
|
+
* Usually, dragging uses the layout project engine, and applies transforms to the underlying VisualElement.
|
|
815
|
+
* Passing MotionValues as _dragX and _dragY instead applies drag updates to these motion values.
|
|
816
|
+
* This allows you to manually control how updates from a drag gesture on an element is applied.
|
|
817
|
+
*
|
|
818
|
+
* @public
|
|
819
|
+
*/
|
|
820
|
+
_dragX?: MotionValue<number>;
|
|
821
|
+
/**
|
|
822
|
+
* Usually, dragging uses the layout project engine, and applies transforms to the underlying VisualElement.
|
|
823
|
+
* Passing MotionValues as _dragX and _dragY instead applies drag updates to these motion values.
|
|
824
|
+
* This allows you to manually control how updates from a drag gesture on an element is applied.
|
|
825
|
+
*
|
|
826
|
+
* @public
|
|
827
|
+
*/
|
|
828
|
+
_dragY?: MotionValue<number>;
|
|
829
|
+
}
|
|
830
|
+
interface MotionNodeDragHandlers {
|
|
831
|
+
/**
|
|
832
|
+
* Callback function that fires when dragging starts.
|
|
833
|
+
*
|
|
834
|
+
* ```jsx
|
|
835
|
+
* <motion.div
|
|
836
|
+
* drag
|
|
837
|
+
* onDragStart={
|
|
838
|
+
* (event, info) => console.log(info.point.x, info.point.y)
|
|
839
|
+
* }
|
|
840
|
+
* />
|
|
841
|
+
* ```
|
|
842
|
+
*
|
|
843
|
+
* @public
|
|
844
|
+
*/
|
|
845
|
+
onDragStart?(event: MouseEvent | TouchEvent | PointerEvent, info: PanInfo): void;
|
|
846
|
+
/**
|
|
847
|
+
* Callback function that fires when dragging ends.
|
|
848
|
+
*
|
|
849
|
+
* ```jsx
|
|
850
|
+
* <motion.div
|
|
851
|
+
* drag
|
|
852
|
+
* onDragEnd={
|
|
853
|
+
* (event, info) => console.log(info.point.x, info.point.y)
|
|
854
|
+
* }
|
|
855
|
+
* />
|
|
856
|
+
* ```
|
|
857
|
+
*
|
|
858
|
+
* @public
|
|
859
|
+
*/
|
|
860
|
+
onDragEnd?(event: MouseEvent | TouchEvent | PointerEvent, info: PanInfo): void;
|
|
861
|
+
/**
|
|
862
|
+
* Callback function that fires when the component is dragged.
|
|
863
|
+
*
|
|
864
|
+
* ```jsx
|
|
865
|
+
* <motion.div
|
|
866
|
+
* drag
|
|
867
|
+
* onDrag={
|
|
868
|
+
* (event, info) => console.log(info.point.x, info.point.y)
|
|
869
|
+
* }
|
|
870
|
+
* />
|
|
871
|
+
* ```
|
|
872
|
+
*
|
|
873
|
+
* @public
|
|
874
|
+
*/
|
|
875
|
+
onDrag?(event: MouseEvent | TouchEvent | PointerEvent, info: PanInfo): void;
|
|
876
|
+
/**
|
|
877
|
+
* Callback function that fires a drag direction is determined.
|
|
878
|
+
*
|
|
879
|
+
* ```jsx
|
|
880
|
+
* <motion.div
|
|
881
|
+
* drag
|
|
882
|
+
* dragDirectionLock
|
|
883
|
+
* onDirectionLock={axis => console.log(axis)}
|
|
884
|
+
* />
|
|
885
|
+
* ```
|
|
886
|
+
*
|
|
887
|
+
* @public
|
|
888
|
+
*/
|
|
889
|
+
onDirectionLock?(axis: "x" | "y"): void;
|
|
890
|
+
/**
|
|
891
|
+
* Callback function that fires when drag momentum/bounce transition finishes.
|
|
892
|
+
*
|
|
893
|
+
* ```jsx
|
|
894
|
+
* <motion.div
|
|
895
|
+
* drag
|
|
896
|
+
* onDragTransitionEnd={() => console.log('Drag transition complete')}
|
|
897
|
+
* />
|
|
898
|
+
* ```
|
|
899
|
+
*
|
|
900
|
+
* @public
|
|
901
|
+
*/
|
|
902
|
+
onDragTransitionEnd?(): void;
|
|
903
|
+
}
|
|
904
|
+
interface MotionNodeLayoutOptions {
|
|
905
|
+
/**
|
|
906
|
+
* If `true`, this component will automatically animate to its new position when
|
|
907
|
+
* its layout changes.
|
|
908
|
+
*
|
|
909
|
+
* ```jsx
|
|
910
|
+
* <motion.div layout />
|
|
911
|
+
* ```
|
|
912
|
+
*
|
|
913
|
+
* This will perform a layout animation using performant transforms. Part of this technique
|
|
914
|
+
* involved animating an element's scale. This can introduce visual distortions on children,
|
|
915
|
+
* `boxShadow` and `borderRadius`.
|
|
916
|
+
*
|
|
917
|
+
* To correct distortion on immediate children, add `layout` to those too.
|
|
918
|
+
*
|
|
919
|
+
* `boxShadow` and `borderRadius` will automatically be corrected if they are already being
|
|
920
|
+
* animated on this component. Otherwise, set them directly via the `initial` prop.
|
|
921
|
+
*
|
|
922
|
+
* If `layout` is set to `"position"`, the size of the component will change instantly and
|
|
923
|
+
* only its position will animate.
|
|
924
|
+
*
|
|
925
|
+
* If `layout` is set to `"size"`, the position of the component will change instantly and
|
|
926
|
+
* only its size will animate.
|
|
927
|
+
*
|
|
928
|
+
* If `layout` is set to `"preserve-aspect"`, the component will animate size & position if
|
|
929
|
+
* the aspect ratio remains the same between renders, and just position if the ratio changes.
|
|
930
|
+
*
|
|
931
|
+
* @public
|
|
932
|
+
*/
|
|
933
|
+
layout?: boolean | "position" | "size" | "preserve-aspect" | "x" | "y";
|
|
934
|
+
/**
|
|
935
|
+
* Enable shared layout transitions between different components with the same `layoutId`.
|
|
936
|
+
*
|
|
937
|
+
* When a component with a layoutId is removed from the React tree, and then
|
|
938
|
+
* added elsewhere, it will visually animate from the previous component's bounding box
|
|
939
|
+
* and its latest animated values.
|
|
940
|
+
*
|
|
941
|
+
* ```jsx
|
|
942
|
+
* {items.map(item => (
|
|
943
|
+
* <motion.li layout>
|
|
944
|
+
* {item.name}
|
|
945
|
+
* {item.isSelected && <motion.div layoutId="underline" />}
|
|
946
|
+
* </motion.li>
|
|
947
|
+
* ))}
|
|
948
|
+
* ```
|
|
949
|
+
*
|
|
950
|
+
* If the previous component remains in the tree it will crossfade with the new component.
|
|
951
|
+
*
|
|
952
|
+
* @public
|
|
953
|
+
*/
|
|
954
|
+
layoutId?: string;
|
|
955
|
+
/**
|
|
956
|
+
* A callback that will fire when a layout animation on this component starts.
|
|
957
|
+
*
|
|
958
|
+
* @public
|
|
959
|
+
*/
|
|
960
|
+
onLayoutAnimationStart?(): void;
|
|
961
|
+
/**
|
|
962
|
+
* A callback that will fire when a layout animation on this component completes.
|
|
963
|
+
*
|
|
964
|
+
* @public
|
|
965
|
+
*/
|
|
966
|
+
onLayoutAnimationComplete?(): void;
|
|
967
|
+
/**
|
|
968
|
+
* @public
|
|
969
|
+
*/
|
|
970
|
+
layoutDependency?: any;
|
|
971
|
+
/**
|
|
972
|
+
* Whether a projection node should measure its scroll when it or its descendants update their layout.
|
|
973
|
+
*
|
|
974
|
+
* @public
|
|
975
|
+
*/
|
|
976
|
+
layoutScroll?: boolean;
|
|
977
|
+
/**
|
|
978
|
+
* Whether an element should be considered a "layout root", where
|
|
979
|
+
* all children will be forced to resolve relatively to it.
|
|
980
|
+
* Currently used for `position: sticky` elements in Framer.
|
|
981
|
+
*/
|
|
982
|
+
layoutRoot?: boolean;
|
|
983
|
+
/**
|
|
984
|
+
* The anchor point for relative layout projection. This defines which
|
|
985
|
+
* point on the parent is used as the reference for the child's position.
|
|
986
|
+
*
|
|
987
|
+
* `{ x: 0, y: 0 }` (default) anchors to the top-left corner.
|
|
988
|
+
* `{ x: 0.5, y: 0.5 }` anchors to the center, useful for centered layouts
|
|
989
|
+
* (e.g., flexbox) to prevent drift during parent layout animations.
|
|
990
|
+
* `false` disables relative projection entirely.
|
|
991
|
+
*/
|
|
992
|
+
layoutAnchor?: {
|
|
993
|
+
x: number;
|
|
994
|
+
y: number;
|
|
995
|
+
} | false;
|
|
996
|
+
/**
|
|
997
|
+
* Attached to a portal root to ensure we attach the child to the document root and don't
|
|
998
|
+
* perform scale correction on it.
|
|
999
|
+
*/
|
|
1000
|
+
"data-framer-portal-id"?: string;
|
|
1001
|
+
/**
|
|
1002
|
+
* By default, shared layout elements will crossfade. By setting this
|
|
1003
|
+
* to `false`, this element will take its default opacity throughout the animation.
|
|
1004
|
+
*/
|
|
1005
|
+
layoutCrossfade?: boolean;
|
|
1006
|
+
}
|
|
1007
|
+
/**
|
|
1008
|
+
* @deprecated - Use MotionNodeDragHandlers/MotionNodeDraggableOptions
|
|
1009
|
+
*/
|
|
1010
|
+
|
|
1011
|
+
type TransformTemplate = (transform: TransformProperties, generatedTransform: string) => string;
|
|
1012
|
+
interface MotionNodeAdvancedOptions {
|
|
1013
|
+
/**
|
|
1014
|
+
* Custom data to use to resolve dynamic variants differently for each animating component.
|
|
1015
|
+
*
|
|
1016
|
+
* ```jsx
|
|
1017
|
+
* const variants = {
|
|
1018
|
+
* visible: (custom) => ({
|
|
1019
|
+
* opacity: 1,
|
|
1020
|
+
* transition: { delay: custom * 0.2 }
|
|
1021
|
+
* })
|
|
1022
|
+
* }
|
|
1023
|
+
*
|
|
1024
|
+
* <motion.div custom={0} animate="visible" variants={variants} />
|
|
1025
|
+
* <motion.div custom={1} animate="visible" variants={variants} />
|
|
1026
|
+
* <motion.div custom={2} animate="visible" variants={variants} />
|
|
1027
|
+
* ```
|
|
1028
|
+
*
|
|
1029
|
+
* @public
|
|
1030
|
+
*/
|
|
1031
|
+
custom?: any;
|
|
1032
|
+
/**
|
|
1033
|
+
* @public
|
|
1034
|
+
* Set to `false` to prevent inheriting variant changes from its parent.
|
|
1035
|
+
*/
|
|
1036
|
+
inherit?: boolean;
|
|
1037
|
+
/**
|
|
1038
|
+
* @public
|
|
1039
|
+
* Set to `false` to prevent throwing an error when a `motion` component is used within a `LazyMotion` set to strict.
|
|
1040
|
+
*/
|
|
1041
|
+
ignoreStrict?: boolean;
|
|
1042
|
+
/**
|
|
1043
|
+
* Provide a set of motion values to perform animations on.
|
|
1044
|
+
*/
|
|
1045
|
+
values?: {
|
|
1046
|
+
[key: string]: MotionValue<number> | MotionValue<string>;
|
|
1047
|
+
};
|
|
1048
|
+
/**
|
|
1049
|
+
* By default, Motion generates a `transform` property with a sensible transform order. `transformTemplate`
|
|
1050
|
+
* can be used to create a different order, or to append/preprend the automatically generated `transform` property.
|
|
1051
|
+
*
|
|
1052
|
+
* ```jsx
|
|
1053
|
+
* <motion.div
|
|
1054
|
+
* style={{ x: 0, rotate: 180 }}
|
|
1055
|
+
* transformTemplate={
|
|
1056
|
+
* ({ x, rotate }) => `rotate(${rotate}deg) translateX(${x}px)`
|
|
1057
|
+
* }
|
|
1058
|
+
* />
|
|
1059
|
+
* ```
|
|
1060
|
+
*
|
|
1061
|
+
* @param transform - The latest animated transform props.
|
|
1062
|
+
* @param generatedTransform - The transform string as automatically generated by Motion
|
|
1063
|
+
*
|
|
1064
|
+
* @public
|
|
1065
|
+
*/
|
|
1066
|
+
transformTemplate?: TransformTemplate;
|
|
1067
|
+
"data-framer-appear-id"?: string;
|
|
1068
|
+
}
|
|
1069
|
+
interface PropagateOptions {
|
|
1070
|
+
/**
|
|
1071
|
+
* If `false`, this element's tap gesture will prevent any parent
|
|
1072
|
+
* element's tap gesture handlers (`onTap`, `onTapStart`, `whileTap`)
|
|
1073
|
+
* from firing. Defaults to `true`.
|
|
1074
|
+
*/
|
|
1075
|
+
tap?: boolean;
|
|
1076
|
+
}
|
|
1077
|
+
interface MotionNodeOptions extends MotionNodeAnimationOptions, MotionNodeEventOptions, MotionNodePanHandlers, MotionNodeTapHandlers, MotionNodeHoverHandlers, MotionNodeFocusHandlers, MotionNodeViewportOptions, MotionNodeDragHandlers, MotionNodeDraggableOptions, MotionNodeLayoutOptions, MotionNodeAdvancedOptions {
|
|
1078
|
+
/**
|
|
1079
|
+
* Controls whether gesture events propagate to parent motion components.
|
|
1080
|
+
* By default all gestures propagate. Set individual gestures to `false`
|
|
1081
|
+
* to prevent parent handlers from firing.
|
|
1082
|
+
*
|
|
1083
|
+
* ```jsx
|
|
1084
|
+
* <motion.div onTap={onParentTap}>
|
|
1085
|
+
* <motion.div onTap={onChildTap} propagate={{ tap: false }} />
|
|
1086
|
+
* </motion.div>
|
|
1087
|
+
* ```
|
|
1088
|
+
*/
|
|
1089
|
+
propagate?: PropagateOptions;
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
/**
|
|
1093
|
+
* @public
|
|
1094
|
+
*/
|
|
1095
|
+
interface PresenceContextProps {
|
|
1096
|
+
id: string;
|
|
1097
|
+
isPresent: boolean;
|
|
1098
|
+
register: (id: string | number) => () => void;
|
|
1099
|
+
onExitComplete?: (id: string | number) => void;
|
|
1100
|
+
initial?: false | VariantLabels;
|
|
1101
|
+
custom?: any;
|
|
1102
|
+
}
|
|
1103
|
+
/**
|
|
1104
|
+
* @public
|
|
1105
|
+
*/
|
|
1106
|
+
type ReducedMotionConfig = "always" | "never" | "user";
|
|
1107
|
+
/**
|
|
1108
|
+
* @public
|
|
1109
|
+
*/
|
|
1110
|
+
interface MotionConfigContextProps {
|
|
1111
|
+
/**
|
|
1112
|
+
* Internal, exported only for usage in Framer
|
|
1113
|
+
*/
|
|
1114
|
+
transformPagePoint: TransformPoint;
|
|
1115
|
+
/**
|
|
1116
|
+
* Internal. Determines whether this is a static context ie the Framer canvas. If so,
|
|
1117
|
+
* it'll disable all dynamic functionality.
|
|
1118
|
+
*/
|
|
1119
|
+
isStatic: boolean;
|
|
1120
|
+
/**
|
|
1121
|
+
* Defines a new default transition for the entire tree.
|
|
1122
|
+
*
|
|
1123
|
+
* @public
|
|
1124
|
+
*/
|
|
1125
|
+
transition?: Transition;
|
|
1126
|
+
/**
|
|
1127
|
+
* If true, will respect the device prefersReducedMotion setting by switching
|
|
1128
|
+
* transform animations off.
|
|
1129
|
+
*
|
|
1130
|
+
* @public
|
|
1131
|
+
*/
|
|
1132
|
+
reducedMotion?: ReducedMotionConfig;
|
|
1133
|
+
/**
|
|
1134
|
+
* A custom `nonce` attribute used when wanting to enforce a Content Security Policy (CSP).
|
|
1135
|
+
* For more details see:
|
|
1136
|
+
* https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/style-src#unsafe_inline_styles
|
|
1137
|
+
*
|
|
1138
|
+
* @public
|
|
1139
|
+
*/
|
|
1140
|
+
nonce?: string;
|
|
1141
|
+
/**
|
|
1142
|
+
* If true, all animations will be skipped and values will be set instantly.
|
|
1143
|
+
* Useful for E2E tests and visual regression testing.
|
|
1144
|
+
*
|
|
1145
|
+
* @public
|
|
1146
|
+
*/
|
|
1147
|
+
skipAnimations?: boolean;
|
|
1148
|
+
}
|
|
1149
|
+
interface VisualState<_Instance, RenderState> {
|
|
1150
|
+
latestValues: ResolvedValues$1;
|
|
1151
|
+
renderState: RenderState;
|
|
1152
|
+
}
|
|
1153
|
+
interface VisualElementOptions<Instance, RenderState = any> {
|
|
1154
|
+
visualState: VisualState<Instance, RenderState>;
|
|
1155
|
+
parent?: any;
|
|
1156
|
+
variantParent?: any;
|
|
1157
|
+
presenceContext: PresenceContextProps | null;
|
|
1158
|
+
props: MotionNodeOptions;
|
|
1159
|
+
blockInitialAnimation?: boolean;
|
|
1160
|
+
reducedMotionConfig?: ReducedMotionConfig;
|
|
1161
|
+
/**
|
|
1162
|
+
* If true, all animations will be skipped and values will be set instantly.
|
|
1163
|
+
* Useful for E2E tests and visual regression testing.
|
|
1164
|
+
*/
|
|
1165
|
+
skipAnimations?: boolean;
|
|
1166
|
+
/**
|
|
1167
|
+
* Explicit override for SVG detection. When true, uses SVG rendering;
|
|
1168
|
+
* when false, uses HTML rendering. If undefined, auto-detects.
|
|
1169
|
+
*/
|
|
1170
|
+
isSVG?: boolean;
|
|
1171
|
+
}
|
|
1172
|
+
interface VisualElementEventCallbacks {
|
|
1173
|
+
BeforeLayoutMeasure: () => void;
|
|
1174
|
+
LayoutMeasure: (layout: Box, prevLayout?: Box) => void;
|
|
1175
|
+
LayoutUpdate: (layout: Axis, prevLayout: Axis) => void;
|
|
1176
|
+
Update: (latest: ResolvedValues$1) => void;
|
|
1177
|
+
AnimationStart: (definition: AnimationDefinition) => void;
|
|
1178
|
+
AnimationComplete: (definition: AnimationDefinition) => void;
|
|
1179
|
+
LayoutAnimationStart: () => void;
|
|
1180
|
+
LayoutAnimationComplete: () => void;
|
|
1181
|
+
SetAxisTarget: () => void;
|
|
1182
|
+
Unmount: () => void;
|
|
1183
|
+
}
|
|
1184
|
+
/**
|
|
1185
|
+
* Animation type for variant state management
|
|
1186
|
+
*/
|
|
1187
|
+
type AnimationType = "animate" | "whileHover" | "whileTap" | "whileDrag" | "whileFocus" | "whileInView" | "exit";
|
|
1188
|
+
interface SVGAttributes$1 {
|
|
1189
|
+
accentHeight?: AnyResolvedKeyframe | undefined;
|
|
1190
|
+
accumulate?: "none" | "sum" | undefined;
|
|
1191
|
+
additive?: "replace" | "sum" | undefined;
|
|
1192
|
+
alignmentBaseline?: "auto" | "baseline" | "before-edge" | "text-before-edge" | "middle" | "central" | "after-edge" | "text-after-edge" | "ideographic" | "alphabetic" | "hanging" | "mathematical" | "inherit" | undefined;
|
|
1193
|
+
allowReorder?: "no" | "yes" | undefined;
|
|
1194
|
+
alphabetic?: AnyResolvedKeyframe | undefined;
|
|
1195
|
+
amplitude?: AnyResolvedKeyframe | undefined;
|
|
1196
|
+
arabicForm?: "initial" | "medial" | "terminal" | "isolated" | undefined;
|
|
1197
|
+
ascent?: AnyResolvedKeyframe | undefined;
|
|
1198
|
+
attributeName?: string | undefined;
|
|
1199
|
+
attributeType?: string | undefined;
|
|
1200
|
+
autoReverse?: boolean | undefined;
|
|
1201
|
+
azimuth?: AnyResolvedKeyframe | undefined;
|
|
1202
|
+
baseFrequency?: AnyResolvedKeyframe | undefined;
|
|
1203
|
+
baselineShift?: AnyResolvedKeyframe | undefined;
|
|
1204
|
+
baseProfile?: AnyResolvedKeyframe | undefined;
|
|
1205
|
+
bbox?: AnyResolvedKeyframe | undefined;
|
|
1206
|
+
begin?: AnyResolvedKeyframe | undefined;
|
|
1207
|
+
bias?: AnyResolvedKeyframe | undefined;
|
|
1208
|
+
by?: AnyResolvedKeyframe | undefined;
|
|
1209
|
+
calcMode?: AnyResolvedKeyframe | undefined;
|
|
1210
|
+
capHeight?: AnyResolvedKeyframe | undefined;
|
|
1211
|
+
clip?: AnyResolvedKeyframe | undefined;
|
|
1212
|
+
clipPath?: string | undefined;
|
|
1213
|
+
clipPathUnits?: AnyResolvedKeyframe | undefined;
|
|
1214
|
+
clipRule?: AnyResolvedKeyframe | undefined;
|
|
1215
|
+
colorInterpolation?: AnyResolvedKeyframe | undefined;
|
|
1216
|
+
colorInterpolationFilters?: "auto" | "sRGB" | "linearRGB" | "inherit" | undefined;
|
|
1217
|
+
colorProfile?: AnyResolvedKeyframe | undefined;
|
|
1218
|
+
colorRendering?: AnyResolvedKeyframe | undefined;
|
|
1219
|
+
contentScriptType?: AnyResolvedKeyframe | undefined;
|
|
1220
|
+
contentStyleType?: AnyResolvedKeyframe | undefined;
|
|
1221
|
+
cursor?: AnyResolvedKeyframe | undefined;
|
|
1222
|
+
cx?: AnyResolvedKeyframe | undefined;
|
|
1223
|
+
cy?: AnyResolvedKeyframe | undefined;
|
|
1224
|
+
d?: string | undefined;
|
|
1225
|
+
decelerate?: AnyResolvedKeyframe | undefined;
|
|
1226
|
+
descent?: AnyResolvedKeyframe | undefined;
|
|
1227
|
+
diffuseConstant?: AnyResolvedKeyframe | undefined;
|
|
1228
|
+
direction?: AnyResolvedKeyframe | undefined;
|
|
1229
|
+
display?: AnyResolvedKeyframe | undefined;
|
|
1230
|
+
divisor?: AnyResolvedKeyframe | undefined;
|
|
1231
|
+
dominantBaseline?: AnyResolvedKeyframe | undefined;
|
|
1232
|
+
dur?: AnyResolvedKeyframe | undefined;
|
|
1233
|
+
dx?: AnyResolvedKeyframe | undefined;
|
|
1234
|
+
dy?: AnyResolvedKeyframe | undefined;
|
|
1235
|
+
edgeMode?: AnyResolvedKeyframe | undefined;
|
|
1236
|
+
elevation?: AnyResolvedKeyframe | undefined;
|
|
1237
|
+
enableBackground?: AnyResolvedKeyframe | undefined;
|
|
1238
|
+
end?: AnyResolvedKeyframe | undefined;
|
|
1239
|
+
exponent?: AnyResolvedKeyframe | undefined;
|
|
1240
|
+
externalResourcesRequired?: boolean | undefined;
|
|
1241
|
+
fill?: string | undefined;
|
|
1242
|
+
fillOpacity?: AnyResolvedKeyframe | undefined;
|
|
1243
|
+
fillRule?: "nonzero" | "evenodd" | "inherit" | undefined;
|
|
1244
|
+
filter?: string | undefined;
|
|
1245
|
+
filterRes?: AnyResolvedKeyframe | undefined;
|
|
1246
|
+
filterUnits?: AnyResolvedKeyframe | undefined;
|
|
1247
|
+
floodColor?: AnyResolvedKeyframe | undefined;
|
|
1248
|
+
floodOpacity?: AnyResolvedKeyframe | undefined;
|
|
1249
|
+
focusable?: boolean | "auto" | undefined;
|
|
1250
|
+
fontFamily?: string | undefined;
|
|
1251
|
+
fontSize?: AnyResolvedKeyframe | undefined;
|
|
1252
|
+
fontSizeAdjust?: AnyResolvedKeyframe | undefined;
|
|
1253
|
+
fontStretch?: AnyResolvedKeyframe | undefined;
|
|
1254
|
+
fontStyle?: AnyResolvedKeyframe | undefined;
|
|
1255
|
+
fontVariant?: AnyResolvedKeyframe | undefined;
|
|
1256
|
+
fontWeight?: AnyResolvedKeyframe | undefined;
|
|
1257
|
+
format?: AnyResolvedKeyframe | undefined;
|
|
1258
|
+
fr?: AnyResolvedKeyframe | undefined;
|
|
1259
|
+
from?: AnyResolvedKeyframe | undefined;
|
|
1260
|
+
fx?: AnyResolvedKeyframe | undefined;
|
|
1261
|
+
fy?: AnyResolvedKeyframe | undefined;
|
|
1262
|
+
g1?: AnyResolvedKeyframe | undefined;
|
|
1263
|
+
g2?: AnyResolvedKeyframe | undefined;
|
|
1264
|
+
glyphName?: AnyResolvedKeyframe | undefined;
|
|
1265
|
+
glyphOrientationHorizontal?: AnyResolvedKeyframe | undefined;
|
|
1266
|
+
glyphOrientationVertical?: AnyResolvedKeyframe | undefined;
|
|
1267
|
+
glyphRef?: AnyResolvedKeyframe | undefined;
|
|
1268
|
+
gradientTransform?: string | undefined;
|
|
1269
|
+
gradientUnits?: string | undefined;
|
|
1270
|
+
hanging?: AnyResolvedKeyframe | undefined;
|
|
1271
|
+
horizAdvX?: AnyResolvedKeyframe | undefined;
|
|
1272
|
+
horizOriginX?: AnyResolvedKeyframe | undefined;
|
|
1273
|
+
href?: string | undefined;
|
|
1274
|
+
ideographic?: AnyResolvedKeyframe | undefined;
|
|
1275
|
+
imageRendering?: AnyResolvedKeyframe | undefined;
|
|
1276
|
+
in2?: AnyResolvedKeyframe | undefined;
|
|
1277
|
+
in?: string | undefined;
|
|
1278
|
+
intercept?: AnyResolvedKeyframe | undefined;
|
|
1279
|
+
k1?: AnyResolvedKeyframe | undefined;
|
|
1280
|
+
k2?: AnyResolvedKeyframe | undefined;
|
|
1281
|
+
k3?: AnyResolvedKeyframe | undefined;
|
|
1282
|
+
k4?: AnyResolvedKeyframe | undefined;
|
|
1283
|
+
k?: AnyResolvedKeyframe | undefined;
|
|
1284
|
+
kernelMatrix?: AnyResolvedKeyframe | undefined;
|
|
1285
|
+
kernelUnitLength?: AnyResolvedKeyframe | undefined;
|
|
1286
|
+
kerning?: AnyResolvedKeyframe | undefined;
|
|
1287
|
+
keyPoints?: AnyResolvedKeyframe | undefined;
|
|
1288
|
+
keySplines?: AnyResolvedKeyframe | undefined;
|
|
1289
|
+
keyTimes?: AnyResolvedKeyframe | undefined;
|
|
1290
|
+
lengthAdjust?: AnyResolvedKeyframe | undefined;
|
|
1291
|
+
letterSpacing?: AnyResolvedKeyframe | undefined;
|
|
1292
|
+
lightingColor?: AnyResolvedKeyframe | undefined;
|
|
1293
|
+
limitingConeAngle?: AnyResolvedKeyframe | undefined;
|
|
1294
|
+
local?: AnyResolvedKeyframe | undefined;
|
|
1295
|
+
markerEnd?: string | undefined;
|
|
1296
|
+
markerHeight?: AnyResolvedKeyframe | undefined;
|
|
1297
|
+
markerMid?: string | undefined;
|
|
1298
|
+
markerStart?: string | undefined;
|
|
1299
|
+
markerUnits?: AnyResolvedKeyframe | undefined;
|
|
1300
|
+
markerWidth?: AnyResolvedKeyframe | undefined;
|
|
1301
|
+
mask?: string | undefined;
|
|
1302
|
+
maskContentUnits?: AnyResolvedKeyframe | undefined;
|
|
1303
|
+
maskUnits?: AnyResolvedKeyframe | undefined;
|
|
1304
|
+
mathematical?: AnyResolvedKeyframe | undefined;
|
|
1305
|
+
mode?: AnyResolvedKeyframe | undefined;
|
|
1306
|
+
numOctaves?: AnyResolvedKeyframe | undefined;
|
|
1307
|
+
offset?: AnyResolvedKeyframe | undefined;
|
|
1308
|
+
opacity?: AnyResolvedKeyframe | undefined;
|
|
1309
|
+
operator?: AnyResolvedKeyframe | undefined;
|
|
1310
|
+
order?: AnyResolvedKeyframe | undefined;
|
|
1311
|
+
orient?: AnyResolvedKeyframe | undefined;
|
|
1312
|
+
orientation?: AnyResolvedKeyframe | undefined;
|
|
1313
|
+
origin?: AnyResolvedKeyframe | undefined;
|
|
1314
|
+
overflow?: AnyResolvedKeyframe | undefined;
|
|
1315
|
+
overlinePosition?: AnyResolvedKeyframe | undefined;
|
|
1316
|
+
overlineThickness?: AnyResolvedKeyframe | undefined;
|
|
1317
|
+
paintOrder?: AnyResolvedKeyframe | undefined;
|
|
1318
|
+
panose1?: AnyResolvedKeyframe | undefined;
|
|
1319
|
+
path?: string | undefined;
|
|
1320
|
+
pathLength?: AnyResolvedKeyframe | undefined;
|
|
1321
|
+
patternContentUnits?: string | undefined;
|
|
1322
|
+
patternTransform?: AnyResolvedKeyframe | undefined;
|
|
1323
|
+
patternUnits?: string | undefined;
|
|
1324
|
+
pointerEvents?: AnyResolvedKeyframe | undefined;
|
|
1325
|
+
points?: string | undefined;
|
|
1326
|
+
pointsAtX?: AnyResolvedKeyframe | undefined;
|
|
1327
|
+
pointsAtY?: AnyResolvedKeyframe | undefined;
|
|
1328
|
+
pointsAtZ?: AnyResolvedKeyframe | undefined;
|
|
1329
|
+
preserveAlpha?: boolean | undefined;
|
|
1330
|
+
preserveAspectRatio?: string | undefined;
|
|
1331
|
+
primitiveUnits?: AnyResolvedKeyframe | undefined;
|
|
1332
|
+
r?: AnyResolvedKeyframe | undefined;
|
|
1333
|
+
radius?: AnyResolvedKeyframe | undefined;
|
|
1334
|
+
refX?: AnyResolvedKeyframe | undefined;
|
|
1335
|
+
refY?: AnyResolvedKeyframe | undefined;
|
|
1336
|
+
renderingIntent?: AnyResolvedKeyframe | undefined;
|
|
1337
|
+
repeatCount?: AnyResolvedKeyframe | undefined;
|
|
1338
|
+
repeatDur?: AnyResolvedKeyframe | undefined;
|
|
1339
|
+
requiredExtensions?: AnyResolvedKeyframe | undefined;
|
|
1340
|
+
requiredFeatures?: AnyResolvedKeyframe | undefined;
|
|
1341
|
+
restart?: AnyResolvedKeyframe | undefined;
|
|
1342
|
+
result?: string | undefined;
|
|
1343
|
+
rotate?: AnyResolvedKeyframe | undefined;
|
|
1344
|
+
rx?: AnyResolvedKeyframe | undefined;
|
|
1345
|
+
ry?: AnyResolvedKeyframe | undefined;
|
|
1346
|
+
scale?: AnyResolvedKeyframe | undefined;
|
|
1347
|
+
seed?: AnyResolvedKeyframe | undefined;
|
|
1348
|
+
shapeRendering?: AnyResolvedKeyframe | undefined;
|
|
1349
|
+
slope?: AnyResolvedKeyframe | undefined;
|
|
1350
|
+
spacing?: AnyResolvedKeyframe | undefined;
|
|
1351
|
+
specularConstant?: AnyResolvedKeyframe | undefined;
|
|
1352
|
+
specularExponent?: AnyResolvedKeyframe | undefined;
|
|
1353
|
+
speed?: AnyResolvedKeyframe | undefined;
|
|
1354
|
+
spreadMethod?: string | undefined;
|
|
1355
|
+
startOffset?: AnyResolvedKeyframe | undefined;
|
|
1356
|
+
stdDeviation?: AnyResolvedKeyframe | undefined;
|
|
1357
|
+
stemh?: AnyResolvedKeyframe | undefined;
|
|
1358
|
+
stemv?: AnyResolvedKeyframe | undefined;
|
|
1359
|
+
stitchTiles?: AnyResolvedKeyframe | undefined;
|
|
1360
|
+
stopColor?: string | undefined;
|
|
1361
|
+
stopOpacity?: AnyResolvedKeyframe | undefined;
|
|
1362
|
+
strikethroughPosition?: AnyResolvedKeyframe | undefined;
|
|
1363
|
+
strikethroughThickness?: AnyResolvedKeyframe | undefined;
|
|
1364
|
+
string?: AnyResolvedKeyframe | undefined;
|
|
1365
|
+
stroke?: string | undefined;
|
|
1366
|
+
strokeDasharray?: AnyResolvedKeyframe | undefined;
|
|
1367
|
+
strokeDashoffset?: AnyResolvedKeyframe | undefined;
|
|
1368
|
+
strokeLinecap?: "butt" | "round" | "square" | "inherit" | undefined;
|
|
1369
|
+
strokeLinejoin?: "miter" | "round" | "bevel" | "inherit" | undefined;
|
|
1370
|
+
strokeMiterlimit?: AnyResolvedKeyframe | undefined;
|
|
1371
|
+
strokeOpacity?: AnyResolvedKeyframe | undefined;
|
|
1372
|
+
strokeWidth?: AnyResolvedKeyframe | undefined;
|
|
1373
|
+
surfaceScale?: AnyResolvedKeyframe | undefined;
|
|
1374
|
+
systemLanguage?: AnyResolvedKeyframe | undefined;
|
|
1375
|
+
tableValues?: AnyResolvedKeyframe | undefined;
|
|
1376
|
+
targetX?: AnyResolvedKeyframe | undefined;
|
|
1377
|
+
targetY?: AnyResolvedKeyframe | undefined;
|
|
1378
|
+
textAnchor?: string | undefined;
|
|
1379
|
+
textDecoration?: AnyResolvedKeyframe | undefined;
|
|
1380
|
+
textLength?: AnyResolvedKeyframe | undefined;
|
|
1381
|
+
textRendering?: AnyResolvedKeyframe | undefined;
|
|
1382
|
+
to?: AnyResolvedKeyframe | undefined;
|
|
1383
|
+
transform?: string | undefined;
|
|
1384
|
+
u1?: AnyResolvedKeyframe | undefined;
|
|
1385
|
+
u2?: AnyResolvedKeyframe | undefined;
|
|
1386
|
+
underlinePosition?: AnyResolvedKeyframe | undefined;
|
|
1387
|
+
underlineThickness?: AnyResolvedKeyframe | undefined;
|
|
1388
|
+
unicode?: AnyResolvedKeyframe | undefined;
|
|
1389
|
+
unicodeBidi?: AnyResolvedKeyframe | undefined;
|
|
1390
|
+
unicodeRange?: AnyResolvedKeyframe | undefined;
|
|
1391
|
+
unitsPerEm?: AnyResolvedKeyframe | undefined;
|
|
1392
|
+
vAlphabetic?: AnyResolvedKeyframe | undefined;
|
|
1393
|
+
values?: string | undefined;
|
|
1394
|
+
vectorEffect?: AnyResolvedKeyframe | undefined;
|
|
1395
|
+
version?: string | undefined;
|
|
1396
|
+
vertAdvY?: AnyResolvedKeyframe | undefined;
|
|
1397
|
+
vertOriginX?: AnyResolvedKeyframe | undefined;
|
|
1398
|
+
vertOriginY?: AnyResolvedKeyframe | undefined;
|
|
1399
|
+
vHanging?: AnyResolvedKeyframe | undefined;
|
|
1400
|
+
vIdeographic?: AnyResolvedKeyframe | undefined;
|
|
1401
|
+
viewBox?: string | undefined;
|
|
1402
|
+
viewTarget?: AnyResolvedKeyframe | undefined;
|
|
1403
|
+
visibility?: AnyResolvedKeyframe | undefined;
|
|
1404
|
+
vMathematical?: AnyResolvedKeyframe | undefined;
|
|
1405
|
+
widths?: AnyResolvedKeyframe | undefined;
|
|
1406
|
+
wordSpacing?: AnyResolvedKeyframe | undefined;
|
|
1407
|
+
writingMode?: AnyResolvedKeyframe | undefined;
|
|
1408
|
+
x1?: AnyResolvedKeyframe | undefined;
|
|
1409
|
+
x2?: AnyResolvedKeyframe | undefined;
|
|
1410
|
+
x?: AnyResolvedKeyframe | undefined;
|
|
1411
|
+
xChannelSelector?: string | undefined;
|
|
1412
|
+
xHeight?: AnyResolvedKeyframe | undefined;
|
|
1413
|
+
xlinkActuate?: string | undefined;
|
|
1414
|
+
xlinkArcrole?: string | undefined;
|
|
1415
|
+
xlinkHref?: string | undefined;
|
|
1416
|
+
xlinkRole?: string | undefined;
|
|
1417
|
+
xlinkShow?: string | undefined;
|
|
1418
|
+
xlinkTitle?: string | undefined;
|
|
1419
|
+
xlinkType?: string | undefined;
|
|
1420
|
+
xmlBase?: string | undefined;
|
|
1421
|
+
xmlLang?: string | undefined;
|
|
1422
|
+
xmlns?: string | undefined;
|
|
1423
|
+
xmlnsXlink?: string | undefined;
|
|
1424
|
+
xmlSpace?: string | undefined;
|
|
1425
|
+
y1?: AnyResolvedKeyframe | undefined;
|
|
1426
|
+
y2?: AnyResolvedKeyframe | undefined;
|
|
1427
|
+
y?: AnyResolvedKeyframe | undefined;
|
|
1428
|
+
yChannelSelector?: string | undefined;
|
|
1429
|
+
z?: AnyResolvedKeyframe | undefined;
|
|
1430
|
+
zoomAndPan?: string | undefined;
|
|
1431
|
+
}
|
|
1432
|
+
interface VisualElementAnimationOptions {
|
|
1433
|
+
delay?: number;
|
|
1434
|
+
transitionOverride?: Transition;
|
|
1435
|
+
custom?: any;
|
|
1436
|
+
type?: AnimationType;
|
|
1437
|
+
}
|
|
1438
|
+
interface AnimationState$1 {
|
|
1439
|
+
animateChanges: (type?: AnimationType) => Promise<any>;
|
|
1440
|
+
setActive: (type: AnimationType, isActive: boolean, options?: VisualElementAnimationOptions) => Promise<any>;
|
|
1441
|
+
setAnimateFunction: (fn: any) => void;
|
|
1442
|
+
getState: () => {
|
|
1443
|
+
[key: string]: AnimationTypeState;
|
|
1444
|
+
};
|
|
1445
|
+
reset: () => void;
|
|
1446
|
+
}
|
|
1447
|
+
interface AnimationTypeState {
|
|
1448
|
+
isActive: boolean;
|
|
1449
|
+
protectedKeys: {
|
|
1450
|
+
[key: string]: true;
|
|
1451
|
+
};
|
|
1452
|
+
needsAnimating: {
|
|
1453
|
+
[key: string]: boolean;
|
|
1454
|
+
};
|
|
1455
|
+
prevResolvedValues: {
|
|
1456
|
+
[key: string]: any;
|
|
1457
|
+
};
|
|
1458
|
+
prevProp?: VariantLabels | TargetAndTransition;
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
/**
|
|
1462
|
+
* Set feature definitions for all VisualElements.
|
|
1463
|
+
* This should be called by the framework layer (e.g., framer-motion) during initialization.
|
|
1464
|
+
*/
|
|
1465
|
+
|
|
1466
|
+
/**
|
|
1467
|
+
* Motion style type - a subset of CSS properties that can contain motion values
|
|
1468
|
+
*/
|
|
1469
|
+
type MotionStyle$1 = {
|
|
1470
|
+
[K: string]: AnyResolvedKeyframe | MotionValue | undefined;
|
|
1471
|
+
};
|
|
1472
|
+
/**
|
|
1473
|
+
* A VisualElement is an imperative abstraction around UI elements such as
|
|
1474
|
+
* HTMLElement, SVGElement, Three.Object3D etc.
|
|
1475
|
+
*/
|
|
1476
|
+
declare abstract class VisualElement<Instance = unknown, RenderState = unknown, Options extends {} = {}> {
|
|
1477
|
+
/**
|
|
1478
|
+
* VisualElements are arranged in trees mirroring that of the React tree.
|
|
1479
|
+
* Each type of VisualElement has a unique name, to detect when we're crossing
|
|
1480
|
+
* type boundaries within that tree.
|
|
1481
|
+
*/
|
|
1482
|
+
abstract type: string;
|
|
1483
|
+
/**
|
|
1484
|
+
* An `Array.sort` compatible function that will compare two Instances and
|
|
1485
|
+
* compare their respective positions within the tree.
|
|
1486
|
+
*/
|
|
1487
|
+
abstract sortInstanceNodePosition(a: Instance, b: Instance): number;
|
|
1488
|
+
/**
|
|
1489
|
+
* Measure the viewport-relative bounding box of the Instance.
|
|
1490
|
+
*/
|
|
1491
|
+
abstract measureInstanceViewportBox(instance: Instance, props: MotionNodeOptions & Partial<MotionConfigContextProps>): Box;
|
|
1492
|
+
/**
|
|
1493
|
+
* When a value has been removed from all animation props we need to
|
|
1494
|
+
* pick a target to animate back to. For instance, for HTMLElements
|
|
1495
|
+
* we can look in the style prop.
|
|
1496
|
+
*/
|
|
1497
|
+
abstract getBaseTargetFromProps(props: MotionNodeOptions, key: string): AnyResolvedKeyframe | undefined | MotionValue;
|
|
1498
|
+
/**
|
|
1499
|
+
* When we first animate to a value we need to animate it *from* a value.
|
|
1500
|
+
* Often this have been specified via the initial prop but it might be
|
|
1501
|
+
* that the value needs to be read from the Instance.
|
|
1502
|
+
*/
|
|
1503
|
+
abstract readValueFromInstance(instance: Instance, key: string, options: Options): AnyResolvedKeyframe | null | undefined;
|
|
1504
|
+
/**
|
|
1505
|
+
* When a value has been removed from the VisualElement we use this to remove
|
|
1506
|
+
* it from the inherting class' unique render state.
|
|
1507
|
+
*/
|
|
1508
|
+
abstract removeValueFromRenderState(key: string, renderState: RenderState): void;
|
|
1509
|
+
/**
|
|
1510
|
+
* Run before a React or VisualElement render, builds the latest motion
|
|
1511
|
+
* values into an Instance-specific format. For example, HTMLVisualElement
|
|
1512
|
+
* will use this step to build `style` and `var` values.
|
|
1513
|
+
*/
|
|
1514
|
+
abstract build(renderState: RenderState, latestValues: ResolvedValues$1, props: MotionNodeOptions): void;
|
|
1515
|
+
/**
|
|
1516
|
+
* Apply the built values to the Instance. For example, HTMLElements will have
|
|
1517
|
+
* styles applied via `setProperty` and the style attribute, whereas SVGElements
|
|
1518
|
+
* will have values applied to attributes.
|
|
1519
|
+
*/
|
|
1520
|
+
abstract renderInstance(instance: Instance, renderState: RenderState, styleProp?: MotionStyle$1, projection?: any): void;
|
|
1521
|
+
/**
|
|
1522
|
+
* This method is called when a transform property is bound to a motion value.
|
|
1523
|
+
* It's currently used to measure SVG elements when a new transform property is bound.
|
|
1524
|
+
*/
|
|
1525
|
+
onBindTransform?(): void;
|
|
1526
|
+
/**
|
|
1527
|
+
* If the component child is provided as a motion value, handle subscriptions
|
|
1528
|
+
* with the renderer-specific VisualElement.
|
|
1529
|
+
*/
|
|
1530
|
+
handleChildMotionValue?(): void;
|
|
1531
|
+
/**
|
|
1532
|
+
* This method takes React props and returns found MotionValues. For example, HTML
|
|
1533
|
+
* MotionValues will be found within the style prop, whereas for Three.js within attribute arrays.
|
|
1534
|
+
*
|
|
1535
|
+
* This isn't an abstract method as it needs calling in the constructor, but it is
|
|
1536
|
+
* intended to be one.
|
|
1537
|
+
*/
|
|
1538
|
+
scrapeMotionValuesFromProps(_props: MotionNodeOptions, _prevProps: MotionNodeOptions, _visualElement: VisualElement): {
|
|
1539
|
+
[key: string]: MotionValue | AnyResolvedKeyframe;
|
|
1540
|
+
};
|
|
1541
|
+
/**
|
|
1542
|
+
* A reference to the current underlying Instance, e.g. a HTMLElement
|
|
1543
|
+
* or Three.Mesh etc.
|
|
1544
|
+
*/
|
|
1545
|
+
current: Instance | null;
|
|
1546
|
+
/**
|
|
1547
|
+
* A reference to the parent VisualElement (if exists).
|
|
1548
|
+
*/
|
|
1549
|
+
parent: VisualElement | undefined;
|
|
1550
|
+
/**
|
|
1551
|
+
* A set containing references to this VisualElement's children.
|
|
1552
|
+
*/
|
|
1553
|
+
children: Set<VisualElement<unknown, unknown, {}>>;
|
|
1554
|
+
/**
|
|
1555
|
+
* A set containing the latest children of this VisualElement. This is flushed
|
|
1556
|
+
* at the start of every commit. We use it to calculate the stagger delay
|
|
1557
|
+
* for newly-added children.
|
|
1558
|
+
*/
|
|
1559
|
+
enteringChildren?: Set<VisualElement>;
|
|
1560
|
+
/**
|
|
1561
|
+
* The depth of this VisualElement within the overall VisualElement tree.
|
|
1562
|
+
*/
|
|
1563
|
+
depth: number;
|
|
1564
|
+
/**
|
|
1565
|
+
* The current render state of this VisualElement. Defined by inherting VisualElements.
|
|
1566
|
+
*/
|
|
1567
|
+
renderState: RenderState;
|
|
1568
|
+
/**
|
|
1569
|
+
* An object containing the latest static values for each of this VisualElement's
|
|
1570
|
+
* MotionValues.
|
|
1571
|
+
*/
|
|
1572
|
+
latestValues: ResolvedValues$1;
|
|
1573
|
+
/**
|
|
1574
|
+
* Determine what role this visual element should take in the variant tree.
|
|
1575
|
+
*/
|
|
1576
|
+
isVariantNode: boolean;
|
|
1577
|
+
isControllingVariants: boolean;
|
|
1578
|
+
/**
|
|
1579
|
+
* If this component is part of the variant tree, it should track
|
|
1580
|
+
* any children that are also part of the tree. This is essentially
|
|
1581
|
+
* a shadow tree to simplify logic around how to stagger over children.
|
|
1582
|
+
*/
|
|
1583
|
+
variantChildren?: Set<VisualElement>;
|
|
1584
|
+
/**
|
|
1585
|
+
* Decides whether this VisualElement should animate in reduced motion
|
|
1586
|
+
* mode.
|
|
1587
|
+
*
|
|
1588
|
+
* TODO: This is currently set on every individual VisualElement but feels
|
|
1589
|
+
* like it could be set globally.
|
|
1590
|
+
*/
|
|
1591
|
+
shouldReduceMotion: boolean | null;
|
|
1592
|
+
/**
|
|
1593
|
+
* Decides whether animations should be skipped for this VisualElement.
|
|
1594
|
+
* Useful for E2E tests and visual regression testing.
|
|
1595
|
+
*/
|
|
1596
|
+
shouldSkipAnimations: boolean;
|
|
1597
|
+
/**
|
|
1598
|
+
* Normally, if a component is controlled by a parent's variants, it can
|
|
1599
|
+
* rely on that ancestor to trigger animations further down the tree.
|
|
1600
|
+
* However, if a component is created after its parent is mounted, the parent
|
|
1601
|
+
* won't trigger that mount animation so the child needs to.
|
|
1602
|
+
*
|
|
1603
|
+
* TODO: This might be better replaced with a method isParentMounted
|
|
1604
|
+
*/
|
|
1605
|
+
manuallyAnimateOnMount: boolean;
|
|
1606
|
+
/**
|
|
1607
|
+
* This can be set by AnimatePresence to force components that mount
|
|
1608
|
+
* at the same time as it to mount as if they have initial={false} set.
|
|
1609
|
+
*/
|
|
1610
|
+
blockInitialAnimation: boolean;
|
|
1611
|
+
/**
|
|
1612
|
+
* A reference to this VisualElement's projection node, used in layout animations.
|
|
1613
|
+
*/
|
|
1614
|
+
projection?: any;
|
|
1615
|
+
/**
|
|
1616
|
+
* A map of all motion values attached to this visual element. Motion
|
|
1617
|
+
* values are source of truth for any given animated value. A motion
|
|
1618
|
+
* value might be provided externally by the component via props.
|
|
1619
|
+
*/
|
|
1620
|
+
values: Map<string, MotionValue<any>>;
|
|
1621
|
+
/**
|
|
1622
|
+
* The AnimationState, this is hydrated by the animation Feature.
|
|
1623
|
+
*/
|
|
1624
|
+
animationState?: AnimationState$1;
|
|
1625
|
+
KeyframeResolver: typeof KeyframeResolver;
|
|
1626
|
+
/**
|
|
1627
|
+
* The options used to create this VisualElement. The Options type is defined
|
|
1628
|
+
* by the inheriting VisualElement and is passed straight through to the render functions.
|
|
1629
|
+
*/
|
|
1630
|
+
readonly options: Options;
|
|
1631
|
+
/**
|
|
1632
|
+
* A reference to the latest props provided to the VisualElement's host React component.
|
|
1633
|
+
*/
|
|
1634
|
+
props: MotionNodeOptions;
|
|
1635
|
+
prevProps?: MotionNodeOptions;
|
|
1636
|
+
presenceContext: PresenceContextProps | null;
|
|
1637
|
+
prevPresenceContext?: PresenceContextProps | null;
|
|
1638
|
+
/**
|
|
1639
|
+
* Cleanup functions for active features (hover/tap/exit etc)
|
|
1640
|
+
*/
|
|
1641
|
+
private features;
|
|
1642
|
+
/**
|
|
1643
|
+
* A map of every subscription that binds the provided or generated
|
|
1644
|
+
* motion values onChange listeners to this visual element.
|
|
1645
|
+
*/
|
|
1646
|
+
private valueSubscriptions;
|
|
1647
|
+
/**
|
|
1648
|
+
* A reference to the ReducedMotionConfig passed to the VisualElement's host React component.
|
|
1649
|
+
*/
|
|
1650
|
+
private reducedMotionConfig;
|
|
1651
|
+
/**
|
|
1652
|
+
* A reference to the skipAnimations config passed to the VisualElement's host React component.
|
|
1653
|
+
*/
|
|
1654
|
+
private skipAnimationsConfig;
|
|
1655
|
+
/**
|
|
1656
|
+
* On mount, this will be hydrated with a callback to disconnect
|
|
1657
|
+
* this visual element from its parent on unmount.
|
|
1658
|
+
*/
|
|
1659
|
+
private removeFromVariantTree;
|
|
1660
|
+
/**
|
|
1661
|
+
* A reference to the previously-provided motion values as returned
|
|
1662
|
+
* from scrapeMotionValuesFromProps. We use the keys in here to determine
|
|
1663
|
+
* if any motion values need to be removed after props are updated.
|
|
1664
|
+
*/
|
|
1665
|
+
private prevMotionValues;
|
|
1666
|
+
/**
|
|
1667
|
+
* When values are removed from all animation props we need to search
|
|
1668
|
+
* for a fallback value to animate to. These values are tracked in baseTarget.
|
|
1669
|
+
*/
|
|
1670
|
+
private baseTarget;
|
|
1671
|
+
/**
|
|
1672
|
+
* Create an object of the values we initially animated from (if initial prop present).
|
|
1673
|
+
*/
|
|
1674
|
+
private initialValues;
|
|
1675
|
+
/**
|
|
1676
|
+
* Track whether this element has been mounted before, to detect
|
|
1677
|
+
* remounts after Suspense unmount/remount cycles.
|
|
1678
|
+
*/
|
|
1679
|
+
private hasBeenMounted;
|
|
1680
|
+
/**
|
|
1681
|
+
* An object containing a SubscriptionManager for each active event.
|
|
1682
|
+
*/
|
|
1683
|
+
private events;
|
|
1684
|
+
/**
|
|
1685
|
+
* An object containing an unsubscribe function for each prop event subscription.
|
|
1686
|
+
* For example, every "Update" event can have multiple subscribers via
|
|
1687
|
+
* VisualElement.on(), but only one of those can be defined via the onUpdate prop.
|
|
1688
|
+
*/
|
|
1689
|
+
private propEventSubscriptions;
|
|
1690
|
+
constructor({
|
|
1691
|
+
parent,
|
|
1692
|
+
props,
|
|
1693
|
+
presenceContext,
|
|
1694
|
+
reducedMotionConfig,
|
|
1695
|
+
skipAnimations,
|
|
1696
|
+
blockInitialAnimation,
|
|
1697
|
+
visualState
|
|
1698
|
+
}: VisualElementOptions<Instance, RenderState>, options?: Options);
|
|
1699
|
+
mount(instance: Instance): void;
|
|
1700
|
+
unmount(): void;
|
|
1701
|
+
addChild(child: VisualElement): void;
|
|
1702
|
+
removeChild(child: VisualElement): void;
|
|
1703
|
+
private bindToMotionValue;
|
|
1704
|
+
sortNodePosition(other: VisualElement<Instance>): number;
|
|
1705
|
+
updateFeatures(): void;
|
|
1706
|
+
notifyUpdate: () => void;
|
|
1707
|
+
triggerBuild(): void;
|
|
1708
|
+
render: () => void;
|
|
1709
|
+
private renderScheduledAt;
|
|
1710
|
+
scheduleRender: () => void;
|
|
1711
|
+
/**
|
|
1712
|
+
* Measure the current viewport box with or without transforms.
|
|
1713
|
+
* Only measures axis-aligned boxes, rotate and skew must be manually
|
|
1714
|
+
* removed with a re-render to work.
|
|
1715
|
+
*/
|
|
1716
|
+
measureViewportBox(): Box;
|
|
1717
|
+
getStaticValue(key: string): AnyResolvedKeyframe;
|
|
1718
|
+
setStaticValue(key: string, value: AnyResolvedKeyframe): void;
|
|
1719
|
+
/**
|
|
1720
|
+
* Update the provided props. Ensure any newly-added motion values are
|
|
1721
|
+
* added to our map, old ones removed, and listeners updated.
|
|
1722
|
+
*/
|
|
1723
|
+
update(props: MotionNodeOptions, presenceContext: PresenceContextProps | null): void;
|
|
1724
|
+
getProps(): MotionNodeOptions;
|
|
1725
|
+
/**
|
|
1726
|
+
* Returns the variant definition with a given name.
|
|
1727
|
+
*/
|
|
1728
|
+
getVariant(name: string): Variant | undefined;
|
|
1729
|
+
/**
|
|
1730
|
+
* Returns the defined default transition on this component.
|
|
1731
|
+
*/
|
|
1732
|
+
getDefaultTransition(): Transition | undefined;
|
|
1733
|
+
getTransformPagePoint(): any;
|
|
1734
|
+
getClosestVariantNode(): VisualElement | undefined;
|
|
1735
|
+
/**
|
|
1736
|
+
* Add a child visual element to our set of children.
|
|
1737
|
+
*/
|
|
1738
|
+
addVariantChild(child: VisualElement): (() => boolean) | undefined;
|
|
1739
|
+
/**
|
|
1740
|
+
* Add a motion value and bind it to this visual element.
|
|
1741
|
+
*/
|
|
1742
|
+
addValue(key: string, value: MotionValue): void;
|
|
1743
|
+
/**
|
|
1744
|
+
* Remove a motion value and unbind any active subscriptions.
|
|
1745
|
+
*/
|
|
1746
|
+
removeValue(key: string): void;
|
|
1747
|
+
/**
|
|
1748
|
+
* Check whether we have a motion value for this key
|
|
1749
|
+
*/
|
|
1750
|
+
hasValue(key: string): boolean;
|
|
1751
|
+
/**
|
|
1752
|
+
* Get a motion value for this key. If called with a default
|
|
1753
|
+
* value, we'll create one if none exists.
|
|
1754
|
+
*/
|
|
1755
|
+
getValue(key: string): MotionValue | undefined;
|
|
1756
|
+
getValue(key: string, defaultValue: AnyResolvedKeyframe | null): MotionValue;
|
|
1757
|
+
/**
|
|
1758
|
+
* If we're trying to animate to a previously unencountered value,
|
|
1759
|
+
* we need to check for it in our state and as a last resort read it
|
|
1760
|
+
* directly from the instance (which might have performance implications).
|
|
1761
|
+
*/
|
|
1762
|
+
readValue(key: string, target?: AnyResolvedKeyframe | null): any;
|
|
1763
|
+
/**
|
|
1764
|
+
* Set the base target to later animate back to. This is currently
|
|
1765
|
+
* only hydrated on creation and when we first read a value.
|
|
1766
|
+
*/
|
|
1767
|
+
setBaseTarget(key: string, value: AnyResolvedKeyframe): void;
|
|
1768
|
+
/**
|
|
1769
|
+
* Find the base target for a value thats been removed from all animation
|
|
1770
|
+
* props.
|
|
1771
|
+
*/
|
|
1772
|
+
getBaseTarget(key: string): ResolvedValues$1[string] | undefined | null;
|
|
1773
|
+
on<EventName extends keyof VisualElementEventCallbacks>(eventName: EventName, callback: VisualElementEventCallbacks[EventName]): VoidFunction;
|
|
1774
|
+
notify<EventName extends keyof VisualElementEventCallbacks>(eventName: EventName, ...args: any): void;
|
|
1775
|
+
scheduleRenderMicrotask(): void;
|
|
1776
|
+
}
|
|
1777
|
+
|
|
1778
|
+
/**
|
|
1779
|
+
* An update function. It accepts a timestamp used to advance the animation.
|
|
1780
|
+
*/
|
|
1781
|
+
type Update$1 = (timestamp: number) => void;
|
|
1782
|
+
/**
|
|
1783
|
+
* Drivers accept a update function and call it at an interval. This interval
|
|
1784
|
+
* could be a synchronous loop, a setInterval, or tied to the device's framerate.
|
|
1785
|
+
*/
|
|
1786
|
+
interface DriverControls {
|
|
1787
|
+
start: (keepAlive?: boolean) => void;
|
|
1788
|
+
stop: () => void;
|
|
1789
|
+
now: () => number;
|
|
1790
|
+
}
|
|
1791
|
+
type Driver = (update: Update$1) => DriverControls;
|
|
1792
|
+
|
|
1793
|
+
/**
|
|
1794
|
+
* Temporary subset of VisualElement until VisualElement is
|
|
1795
|
+
* moved to motion-dom
|
|
1796
|
+
*/
|
|
1797
|
+
interface WithRender {
|
|
1798
|
+
render: () => void;
|
|
1799
|
+
readValue: (name: string, keyframe: any) => any;
|
|
1800
|
+
getValue: (name: string, defaultValue?: any) => any;
|
|
1801
|
+
current?: HTMLElement | SVGElement;
|
|
1802
|
+
measureViewportBox: () => Box;
|
|
1803
|
+
}
|
|
1804
|
+
type AnyResolvedKeyframe = string | number;
|
|
1805
|
+
interface ProgressTimeline {
|
|
1806
|
+
currentTime: null | {
|
|
1807
|
+
value: number;
|
|
1808
|
+
};
|
|
1809
|
+
cancel?: VoidFunction;
|
|
1810
|
+
}
|
|
1811
|
+
interface TimelineWithFallback {
|
|
1812
|
+
timeline?: ProgressTimeline;
|
|
1813
|
+
rangeStart?: string;
|
|
1814
|
+
rangeEnd?: string;
|
|
1815
|
+
observe: (animation: AnimationPlaybackControls) => VoidFunction;
|
|
1816
|
+
}
|
|
1817
|
+
/**
|
|
1818
|
+
* Methods to control an animation.
|
|
1819
|
+
*/
|
|
1820
|
+
interface AnimationPlaybackControls {
|
|
1821
|
+
/**
|
|
1822
|
+
* The current time of the animation, in seconds.
|
|
1823
|
+
*/
|
|
1824
|
+
time: number;
|
|
1825
|
+
/**
|
|
1826
|
+
* The playback speed of the animation.
|
|
1827
|
+
* 1 = normal speed, 2 = double speed, 0.5 = half speed.
|
|
1828
|
+
*/
|
|
1829
|
+
speed: number;
|
|
1830
|
+
/**
|
|
1831
|
+
* The start time of the animation, in milliseconds.
|
|
1832
|
+
*/
|
|
1833
|
+
startTime: number | null;
|
|
1834
|
+
/**
|
|
1835
|
+
* The state of the animation.
|
|
1836
|
+
*
|
|
1837
|
+
* This is currently for internal use only.
|
|
1838
|
+
*/
|
|
1839
|
+
state: AnimationPlayState;
|
|
1840
|
+
duration: number;
|
|
1841
|
+
/**
|
|
1842
|
+
* The duration of the animation, including any delay.
|
|
1843
|
+
*/
|
|
1844
|
+
iterationDuration: number;
|
|
1845
|
+
/**
|
|
1846
|
+
* Stops the animation at its current state, and prevents it from
|
|
1847
|
+
* resuming when the animation is played again.
|
|
1848
|
+
*/
|
|
1849
|
+
stop: () => void;
|
|
1850
|
+
/**
|
|
1851
|
+
* Plays the animation.
|
|
1852
|
+
*/
|
|
1853
|
+
play: () => void;
|
|
1854
|
+
/**
|
|
1855
|
+
* Pauses the animation.
|
|
1856
|
+
*/
|
|
1857
|
+
pause: () => void;
|
|
1858
|
+
/**
|
|
1859
|
+
* Completes the animation and applies the final state.
|
|
1860
|
+
*/
|
|
1861
|
+
complete: () => void;
|
|
1862
|
+
/**
|
|
1863
|
+
* Cancels the animation and applies the initial state.
|
|
1864
|
+
*/
|
|
1865
|
+
cancel: () => void;
|
|
1866
|
+
/**
|
|
1867
|
+
* Attaches a timeline to the animation, for instance the `ScrollTimeline`.
|
|
1868
|
+
*
|
|
1869
|
+
* This is currently for internal use only.
|
|
1870
|
+
*/
|
|
1871
|
+
attachTimeline: (timeline: TimelineWithFallback) => VoidFunction;
|
|
1872
|
+
finished: Promise<any>;
|
|
1873
|
+
}
|
|
1874
|
+
type AnimationPlaybackControlsWithThen = AnimationPlaybackControls & {
|
|
1875
|
+
then: (onResolve: VoidFunction, onReject?: VoidFunction) => Promise<void>;
|
|
1876
|
+
};
|
|
1877
|
+
interface AnimationState<V> {
|
|
1878
|
+
value: V;
|
|
1879
|
+
done: boolean;
|
|
1880
|
+
}
|
|
1881
|
+
interface KeyframeGenerator<V> {
|
|
1882
|
+
calculatedDuration: null | number;
|
|
1883
|
+
next: (t: number) => AnimationState<V>;
|
|
1884
|
+
velocity?: (t: number) => number;
|
|
1885
|
+
toString: () => string;
|
|
1886
|
+
}
|
|
1887
|
+
interface ValueAnimationOptions<V extends AnyResolvedKeyframe = number> extends ValueAnimationTransition {
|
|
1888
|
+
keyframes: V[];
|
|
1889
|
+
element?: any;
|
|
1890
|
+
name?: string;
|
|
1891
|
+
motionValue?: MotionValue<V>;
|
|
1892
|
+
from?: any;
|
|
1893
|
+
isHandoff?: boolean;
|
|
1894
|
+
allowFlatten?: boolean;
|
|
1895
|
+
finalKeyframe?: V;
|
|
1896
|
+
}
|
|
1897
|
+
type GeneratorFactoryFunction = (options: ValueAnimationOptions<any>) => KeyframeGenerator<any>;
|
|
1898
|
+
interface GeneratorFactory extends GeneratorFactoryFunction {
|
|
1899
|
+
applyToOptions?: (options: Transition) => Transition;
|
|
1900
|
+
}
|
|
1901
|
+
type AnimationGeneratorName = "decay" | "spring" | "keyframes" | "tween" | "inertia";
|
|
1902
|
+
type AnimationGeneratorType = GeneratorFactory | AnimationGeneratorName | false;
|
|
1903
|
+
interface AnimationPlaybackLifecycles<V> {
|
|
1904
|
+
onUpdate?: (latest: V) => void;
|
|
1905
|
+
onPlay?: () => void;
|
|
1906
|
+
onComplete?: () => void;
|
|
1907
|
+
onRepeat?: () => void;
|
|
1908
|
+
onStop?: () => void;
|
|
1909
|
+
}
|
|
1910
|
+
interface ValueAnimationTransition<V = any> extends ValueTransition, AnimationPlaybackLifecycles<V> {
|
|
1911
|
+
isSync?: boolean;
|
|
1912
|
+
}
|
|
1913
|
+
type RepeatType = "loop" | "reverse" | "mirror";
|
|
1914
|
+
interface AnimationPlaybackOptions {
|
|
1915
|
+
/**
|
|
1916
|
+
* The number of times to repeat the transition. Set to `Infinity` for perpetual repeating.
|
|
1917
|
+
*
|
|
1918
|
+
* Without setting `repeatType`, this will loop the animation.
|
|
1919
|
+
*
|
|
1920
|
+
* @public
|
|
1921
|
+
*/
|
|
1922
|
+
repeat?: number;
|
|
1923
|
+
/**
|
|
1924
|
+
* How to repeat the animation. This can be either:
|
|
1925
|
+
*
|
|
1926
|
+
* "loop": Repeats the animation from the start
|
|
1927
|
+
*
|
|
1928
|
+
* "reverse": Alternates between forward and backwards playback
|
|
1929
|
+
*
|
|
1930
|
+
* "mirror": Switches `from` and `to` alternately
|
|
1931
|
+
*
|
|
1932
|
+
* @public
|
|
1933
|
+
*/
|
|
1934
|
+
repeatType?: RepeatType;
|
|
1935
|
+
/**
|
|
1936
|
+
* When repeating an animation, `repeatDelay` will set the
|
|
1937
|
+
* duration of the time to wait, in seconds, between each repetition.
|
|
1938
|
+
*
|
|
1939
|
+
* @public
|
|
1940
|
+
*/
|
|
1941
|
+
repeatDelay?: number;
|
|
1942
|
+
}
|
|
1943
|
+
interface VelocityOptions {
|
|
1944
|
+
velocity?: number;
|
|
1945
|
+
/**
|
|
1946
|
+
* End animation if absolute speed (in units per second) drops below this
|
|
1947
|
+
* value and delta is smaller than `restDelta`. Set to `0.01` by default.
|
|
1948
|
+
*
|
|
1949
|
+
* @public
|
|
1950
|
+
*/
|
|
1951
|
+
restSpeed?: number;
|
|
1952
|
+
/**
|
|
1953
|
+
* End animation if distance is below this value and speed is below
|
|
1954
|
+
* `restSpeed`. When animation ends, spring gets "snapped" to. Set to
|
|
1955
|
+
* `0.01` by default.
|
|
1956
|
+
*
|
|
1957
|
+
* @public
|
|
1958
|
+
*/
|
|
1959
|
+
restDelta?: number;
|
|
1960
|
+
}
|
|
1961
|
+
interface DurationSpringOptions {
|
|
1962
|
+
/**
|
|
1963
|
+
* The total duration of the animation. Set to `0.3` by default.
|
|
1964
|
+
*
|
|
1965
|
+
* @public
|
|
1966
|
+
*/
|
|
1967
|
+
duration?: number;
|
|
1968
|
+
/**
|
|
1969
|
+
* If visualDuration is set, this will override duration.
|
|
1970
|
+
*
|
|
1971
|
+
* The visual duration is a time, set in seconds, that the animation will take to visually appear to reach its target.
|
|
1972
|
+
*
|
|
1973
|
+
* In other words, the bulk of the transition will occur before this time, and the "bouncy bit" will mostly happen after.
|
|
1974
|
+
*
|
|
1975
|
+
* This makes it easier to edit a spring, as well as visually coordinate it with other time-based animations.
|
|
1976
|
+
*
|
|
1977
|
+
* @public
|
|
1978
|
+
*/
|
|
1979
|
+
visualDuration?: number;
|
|
1980
|
+
/**
|
|
1981
|
+
* `bounce` determines the "bounciness" of a spring animation.
|
|
1982
|
+
*
|
|
1983
|
+
* `0` is no bounce, and `1` is extremely bouncy.
|
|
1984
|
+
*
|
|
1985
|
+
* If `duration` is set, this defaults to `0.25`.
|
|
1986
|
+
*
|
|
1987
|
+
* Note: `bounce` and `duration` will be overridden if `stiffness`, `damping` or `mass` are set.
|
|
1988
|
+
*
|
|
1989
|
+
* @public
|
|
1990
|
+
*/
|
|
1991
|
+
bounce?: number;
|
|
1992
|
+
}
|
|
1993
|
+
interface SpringOptions extends DurationSpringOptions, VelocityOptions {
|
|
1994
|
+
/**
|
|
1995
|
+
* Stiffness of the spring. Higher values will create more sudden movement.
|
|
1996
|
+
* Set to `100` by default.
|
|
1997
|
+
*
|
|
1998
|
+
* @default 100
|
|
1999
|
+
*
|
|
2000
|
+
* @public
|
|
2001
|
+
*/
|
|
2002
|
+
stiffness?: number;
|
|
2003
|
+
/**
|
|
2004
|
+
* Strength of opposing force. If set to 0, spring will oscillate
|
|
2005
|
+
* indefinitely. Set to `10` by default.
|
|
2006
|
+
*
|
|
2007
|
+
* @default 10
|
|
2008
|
+
*
|
|
2009
|
+
* @public
|
|
2010
|
+
*/
|
|
2011
|
+
damping?: number;
|
|
2012
|
+
/**
|
|
2013
|
+
* Mass of the moving object. Higher values will result in more lethargic
|
|
2014
|
+
* movement. Set to `1` by default.
|
|
2015
|
+
*
|
|
2016
|
+
* @default 1
|
|
2017
|
+
*
|
|
2018
|
+
* @public
|
|
2019
|
+
*/
|
|
2020
|
+
mass?: number;
|
|
2021
|
+
}
|
|
2022
|
+
/**
|
|
2023
|
+
* @deprecated Use SpringOptions instead
|
|
2024
|
+
*/
|
|
2025
|
+
|
|
2026
|
+
interface DecayOptions extends VelocityOptions {
|
|
2027
|
+
keyframes?: number[];
|
|
2028
|
+
/**
|
|
2029
|
+
* A higher power value equals a further target. Set to `0.8` by default.
|
|
2030
|
+
*
|
|
2031
|
+
* @public
|
|
2032
|
+
*/
|
|
2033
|
+
power?: number;
|
|
2034
|
+
/**
|
|
2035
|
+
* Adjusting the time constant will change the duration of the
|
|
2036
|
+
* deceleration, thereby affecting its feel. Set to `700` by default.
|
|
2037
|
+
*
|
|
2038
|
+
* @public
|
|
2039
|
+
*/
|
|
2040
|
+
timeConstant?: number;
|
|
2041
|
+
/**
|
|
2042
|
+
* A function that receives the automatically-calculated target and returns a new one. Useful for snapping the target to a grid.
|
|
2043
|
+
*
|
|
2044
|
+
* @public
|
|
2045
|
+
*/
|
|
2046
|
+
modifyTarget?: (v: number) => number;
|
|
2047
|
+
}
|
|
2048
|
+
interface InertiaOptions extends DecayOptions {
|
|
2049
|
+
/**
|
|
2050
|
+
* If `min` or `max` is set, this affects the stiffness of the bounce
|
|
2051
|
+
* spring. Higher values will create more sudden movement. Set to `500` by
|
|
2052
|
+
* default.
|
|
2053
|
+
*
|
|
2054
|
+
* @public
|
|
2055
|
+
*/
|
|
2056
|
+
bounceStiffness?: number;
|
|
2057
|
+
/**
|
|
2058
|
+
* If `min` or `max` is set, this affects the damping of the bounce spring.
|
|
2059
|
+
* If set to `0`, spring will oscillate indefinitely. Set to `10` by
|
|
2060
|
+
* default.
|
|
2061
|
+
*
|
|
2062
|
+
* @public
|
|
2063
|
+
*/
|
|
2064
|
+
bounceDamping?: number;
|
|
2065
|
+
/**
|
|
2066
|
+
* Minimum constraint. If set, the value will "bump" against this value (or immediately spring to it if the animation starts as less than this value).
|
|
2067
|
+
*
|
|
2068
|
+
* @public
|
|
2069
|
+
*/
|
|
2070
|
+
min?: number;
|
|
2071
|
+
/**
|
|
2072
|
+
* Maximum constraint. If set, the value will "bump" against this value (or immediately snap to it, if the initial animation value exceeds this value).
|
|
2073
|
+
*
|
|
2074
|
+
* @public
|
|
2075
|
+
*/
|
|
2076
|
+
max?: number;
|
|
2077
|
+
}
|
|
2078
|
+
interface AnimationOrchestrationOptions {
|
|
2079
|
+
/**
|
|
2080
|
+
* Delay the animation by this duration (in seconds). Defaults to `0`.
|
|
2081
|
+
*
|
|
2082
|
+
* @public
|
|
2083
|
+
*/
|
|
2084
|
+
delay?: number;
|
|
2085
|
+
/**
|
|
2086
|
+
* Describes the relationship between the transition and its children. Set
|
|
2087
|
+
* to `false` by default.
|
|
2088
|
+
*
|
|
2089
|
+
* @remarks
|
|
2090
|
+
* When using variants, the transition can be scheduled in relation to its
|
|
2091
|
+
* children with either `"beforeChildren"` to finish this transition before
|
|
2092
|
+
* starting children transitions, `"afterChildren"` to finish children
|
|
2093
|
+
* transitions before starting this transition.
|
|
2094
|
+
*
|
|
2095
|
+
* @public
|
|
2096
|
+
*/
|
|
2097
|
+
when?: false | "beforeChildren" | "afterChildren" | string;
|
|
2098
|
+
/**
|
|
2099
|
+
* When using variants, children animations will start after this duration
|
|
2100
|
+
* (in seconds). You can add the `transition` property to both the `motion.div` and the
|
|
2101
|
+
* `variant` directly. Adding it to the `variant` generally offers more flexibility,
|
|
2102
|
+
* as it allows you to customize the delay per visual state.
|
|
2103
|
+
*
|
|
2104
|
+
* @public
|
|
2105
|
+
*/
|
|
2106
|
+
delayChildren?: number | DynamicOption<number>;
|
|
2107
|
+
/**
|
|
2108
|
+
* When using variants, animations of child components can be staggered by this
|
|
2109
|
+
* duration (in seconds).
|
|
2110
|
+
*
|
|
2111
|
+
* For instance, if `staggerChildren` is `0.01`, the first child will be
|
|
2112
|
+
* delayed by `0` seconds, the second by `0.01`, the third by `0.02` and so
|
|
2113
|
+
* on.
|
|
2114
|
+
*
|
|
2115
|
+
* The calculated stagger delay will be added to `delayChildren`.
|
|
2116
|
+
*
|
|
2117
|
+
* @deprecated - Use `delayChildren: stagger(interval)` instead.
|
|
2118
|
+
*/
|
|
2119
|
+
staggerChildren?: number;
|
|
2120
|
+
/**
|
|
2121
|
+
* The direction in which to stagger children.
|
|
2122
|
+
*
|
|
2123
|
+
* A value of `1` staggers from the first to the last while `-1`
|
|
2124
|
+
* staggers from the last to the first.
|
|
2125
|
+
*
|
|
2126
|
+
* @deprecated - Use `delayChildren: stagger(interval, { from: "last" })` instead.
|
|
2127
|
+
*/
|
|
2128
|
+
staggerDirection?: number;
|
|
2129
|
+
}
|
|
2130
|
+
interface KeyframeOptions {
|
|
2131
|
+
/**
|
|
2132
|
+
* The total duration of the animation. Set to `0.3` by default.
|
|
2133
|
+
*
|
|
2134
|
+
* @public
|
|
2135
|
+
*/
|
|
2136
|
+
duration?: number;
|
|
2137
|
+
ease?: Easing | Easing[];
|
|
2138
|
+
times?: number[];
|
|
2139
|
+
}
|
|
2140
|
+
interface ValueTransition extends AnimationOrchestrationOptions, AnimationPlaybackOptions, Omit<SpringOptions, "keyframes">, Omit<InertiaOptions, "keyframes">, KeyframeOptions {
|
|
2141
|
+
/**
|
|
2142
|
+
* Delay the animation by this duration (in seconds). Defaults to `0`.
|
|
2143
|
+
*
|
|
2144
|
+
* @public
|
|
2145
|
+
*/
|
|
2146
|
+
delay?: number;
|
|
2147
|
+
/**
|
|
2148
|
+
* The duration of time already elapsed in the animation. Set to `0` by
|
|
2149
|
+
* default.
|
|
2150
|
+
*/
|
|
2151
|
+
elapsed?: number;
|
|
2152
|
+
driver?: Driver;
|
|
2153
|
+
/**
|
|
2154
|
+
* Type of animation to use.
|
|
2155
|
+
*
|
|
2156
|
+
* - "tween": Duration-based animation with ease curve
|
|
2157
|
+
* - "spring": Physics or duration-based spring animation
|
|
2158
|
+
* - false: Use an instant animation
|
|
2159
|
+
*/
|
|
2160
|
+
type?: AnimationGeneratorType;
|
|
2161
|
+
/**
|
|
2162
|
+
* The duration of the tween animation. Set to `0.3` by default, 0r `0.8` if animating a series of keyframes.
|
|
2163
|
+
*
|
|
2164
|
+
* @public
|
|
2165
|
+
*/
|
|
2166
|
+
duration?: number;
|
|
2167
|
+
autoplay?: boolean;
|
|
2168
|
+
startTime?: number;
|
|
2169
|
+
from?: any;
|
|
2170
|
+
/**
|
|
2171
|
+
* If true, this transition will shallow-merge with its parent transition
|
|
2172
|
+
* instead of replacing it. Inner keys win.
|
|
2173
|
+
*
|
|
2174
|
+
* @public
|
|
2175
|
+
*/
|
|
2176
|
+
inherit?: boolean;
|
|
2177
|
+
/**
|
|
2178
|
+
* If true, the animation skips straight to its final value instead of
|
|
2179
|
+
* tweening. Used by `MotionConfig`'s `skipAnimations` to opt entire
|
|
2180
|
+
* subtrees out of animation (e.g. for E2E screenshot stability).
|
|
2181
|
+
*
|
|
2182
|
+
* @public
|
|
2183
|
+
*/
|
|
2184
|
+
skipAnimations?: boolean;
|
|
2185
|
+
/**
|
|
2186
|
+
* The path the element travels between its old and new x/y positions.
|
|
2187
|
+
* Slot in a path factory (e.g. `arc()`) to swap the default
|
|
2188
|
+
* straight-line interpolation for something curved.
|
|
2189
|
+
*
|
|
2190
|
+
* Can be used in keyframe animations (`transition.path`) and layout
|
|
2191
|
+
* animations (`transition.layout.path`), including with `useAnimate`.
|
|
2192
|
+
*
|
|
2193
|
+
* @public
|
|
2194
|
+
*/
|
|
2195
|
+
path?: MotionPath;
|
|
2196
|
+
}
|
|
2197
|
+
/**
|
|
2198
|
+
* @deprecated Use KeyframeOptions instead
|
|
2199
|
+
*/
|
|
2200
|
+
|
|
2201
|
+
type SVGForcedAttrTransitions = { [K in keyof SVGForcedAttrProperties]: ValueTransition };
|
|
2202
|
+
type SVGPathTransitions = { [K in keyof SVGPathProperties]: ValueTransition };
|
|
2203
|
+
type SVGTransitions = { [K in keyof Omit<SVGAttributes$1, "from">]: ValueTransition };
|
|
2204
|
+
interface VariableTransitions {
|
|
2205
|
+
[key: `--${string}`]: ValueTransition;
|
|
2206
|
+
}
|
|
2207
|
+
type StyleTransitions = { [K in keyof CSSStyleDeclarationWithTransform]?: ValueTransition };
|
|
2208
|
+
type ValueKeyframe<T extends AnyResolvedKeyframe = AnyResolvedKeyframe> = T;
|
|
2209
|
+
type UnresolvedValueKeyframe<T extends AnyResolvedKeyframe = AnyResolvedKeyframe> = ValueKeyframe<T> | null;
|
|
2210
|
+
type ValueKeyframesDefinition = ValueKeyframe | ValueKeyframe[] | UnresolvedValueKeyframe[];
|
|
2211
|
+
type StyleKeyframesDefinition = { [K in keyof CSSStyleDeclarationWithTransform]?: ValueKeyframesDefinition };
|
|
2212
|
+
type SVGKeyframesDefinition = { [K in keyof Omit<SVGAttributes$1, "from">]?: ValueKeyframesDefinition };
|
|
2213
|
+
interface VariableKeyframesDefinition {
|
|
2214
|
+
[key: `--${string}`]: ValueKeyframesDefinition;
|
|
2215
|
+
}
|
|
2216
|
+
type SVGForcedAttrKeyframesDefinition = { [K in keyof SVGForcedAttrProperties]?: ValueKeyframesDefinition };
|
|
2217
|
+
type SVGPathKeyframesDefinition = { [K in keyof SVGPathProperties]?: ValueKeyframesDefinition };
|
|
2218
|
+
type DOMKeyframesDefinition = StyleKeyframesDefinition & SVGKeyframesDefinition & SVGPathKeyframesDefinition & SVGForcedAttrKeyframesDefinition & VariableKeyframesDefinition;
|
|
2219
|
+
interface Target extends DOMKeyframesDefinition {}
|
|
2220
|
+
type CSSPropertyKeys = { [K in keyof CSSStyleDeclaration as K extends string ? CSSStyleDeclaration[K] extends AnyResolvedKeyframe ? K : never : never]: CSSStyleDeclaration[K] };
|
|
2221
|
+
interface CSSStyleDeclarationWithTransform extends Omit<CSSPropertyKeys, "direction" | "transition" | "x" | "y" | "z"> {
|
|
2222
|
+
x: number | string;
|
|
2223
|
+
y: number | string;
|
|
2224
|
+
z: number | string;
|
|
2225
|
+
originX: number;
|
|
2226
|
+
originY: number;
|
|
2227
|
+
originZ: number;
|
|
2228
|
+
translateX: number | string;
|
|
2229
|
+
translateY: number | string;
|
|
2230
|
+
translateZ: number | string;
|
|
2231
|
+
rotateX: number | string;
|
|
2232
|
+
rotateY: number | string;
|
|
2233
|
+
rotateZ: number | string;
|
|
2234
|
+
scaleX: number;
|
|
2235
|
+
scaleY: number;
|
|
2236
|
+
scaleZ: number;
|
|
2237
|
+
skewX: number | string;
|
|
2238
|
+
skewY: number | string;
|
|
2239
|
+
transformPerspective: number;
|
|
2240
|
+
}
|
|
2241
|
+
type TransitionWithValueOverrides<V> = ValueAnimationTransition<V> & StyleTransitions & SVGPathTransitions & SVGForcedAttrTransitions & SVGTransitions & VariableTransitions & {
|
|
2242
|
+
default?: ValueTransition;
|
|
2243
|
+
layout?: ValueTransition;
|
|
2244
|
+
};
|
|
2245
|
+
type Transition<V = any> = ValueAnimationTransition<V> | TransitionWithValueOverrides<V>;
|
|
2246
|
+
interface PathState {
|
|
2247
|
+
x: number;
|
|
2248
|
+
y: number;
|
|
2249
|
+
/**
|
|
2250
|
+
* Optional rotation in degrees. If returned, the engine will apply it
|
|
2251
|
+
* to the element's `rotate` value for the duration of the animation.
|
|
2252
|
+
*/
|
|
2253
|
+
rotate?: number;
|
|
2254
|
+
}
|
|
2255
|
+
/**
|
|
2256
|
+
* Sampling function — returns position (and optionally rotation) at
|
|
2257
|
+
* progress `t` (0–1).
|
|
2258
|
+
*/
|
|
2259
|
+
interface PathInterpolator {
|
|
2260
|
+
(t: number): PathState;
|
|
2261
|
+
}
|
|
2262
|
+
/**
|
|
2263
|
+
* Returned by a path factory such as `arc()` and passed to `transition.path`.
|
|
2264
|
+
* Implements both the keyframe-animation hook (`animateVisualElement`) and
|
|
2265
|
+
* the layout-projection hook (`interpolateProjection`).
|
|
2266
|
+
*/
|
|
2267
|
+
interface MotionPath {
|
|
2268
|
+
animateVisualElement(visualElement: VisualElement, target: TargetAndTransition, transition: Transition | undefined, delay: number, animations: AnimationPlaybackControlsWithThen[]): void;
|
|
2269
|
+
interpolateProjection(delta: Delta): PathInterpolator | undefined;
|
|
2270
|
+
}
|
|
2271
|
+
type DynamicOption<T> = (i: number, total: number) => T;
|
|
2272
|
+
interface TransformProperties {
|
|
2273
|
+
x?: AnyResolvedKeyframe;
|
|
2274
|
+
y?: AnyResolvedKeyframe;
|
|
2275
|
+
z?: AnyResolvedKeyframe;
|
|
2276
|
+
translateX?: AnyResolvedKeyframe;
|
|
2277
|
+
translateY?: AnyResolvedKeyframe;
|
|
2278
|
+
translateZ?: AnyResolvedKeyframe;
|
|
2279
|
+
rotate?: AnyResolvedKeyframe;
|
|
2280
|
+
rotateX?: AnyResolvedKeyframe;
|
|
2281
|
+
rotateY?: AnyResolvedKeyframe;
|
|
2282
|
+
rotateZ?: AnyResolvedKeyframe;
|
|
2283
|
+
scale?: AnyResolvedKeyframe;
|
|
2284
|
+
scaleX?: AnyResolvedKeyframe;
|
|
2285
|
+
scaleY?: AnyResolvedKeyframe;
|
|
2286
|
+
scaleZ?: AnyResolvedKeyframe;
|
|
2287
|
+
skew?: AnyResolvedKeyframe;
|
|
2288
|
+
skewX?: AnyResolvedKeyframe;
|
|
2289
|
+
skewY?: AnyResolvedKeyframe;
|
|
2290
|
+
originX?: AnyResolvedKeyframe;
|
|
2291
|
+
originY?: AnyResolvedKeyframe;
|
|
2292
|
+
originZ?: AnyResolvedKeyframe;
|
|
2293
|
+
perspective?: AnyResolvedKeyframe;
|
|
2294
|
+
transformPerspective?: AnyResolvedKeyframe;
|
|
2295
|
+
}
|
|
2296
|
+
interface SVGForcedAttrProperties {
|
|
2297
|
+
attrX?: number;
|
|
2298
|
+
attrY?: number;
|
|
2299
|
+
attrScale?: number;
|
|
2300
|
+
}
|
|
2301
|
+
interface SVGPathProperties {
|
|
2302
|
+
pathLength?: number;
|
|
2303
|
+
pathOffset?: number;
|
|
2304
|
+
pathSpacing?: number;
|
|
2305
|
+
}
|
|
2306
|
+
|
|
2307
|
+
/**
|
|
2308
|
+
* @public
|
|
2309
|
+
*/
|
|
2310
|
+
type Subscriber<T> = (v: T) => void;
|
|
2311
|
+
/**
|
|
2312
|
+
* @public
|
|
2313
|
+
*/
|
|
2314
|
+
type PassiveEffect<T> = (v: T, safeSetter: (v: T) => void) => void;
|
|
2315
|
+
type StartAnimation = (complete: () => void) => AnimationPlaybackControlsWithThen | undefined;
|
|
2316
|
+
interface MotionValueEventCallbacks<V> {
|
|
2317
|
+
animationStart: () => void;
|
|
2318
|
+
animationComplete: () => void;
|
|
2319
|
+
animationCancel: () => void;
|
|
2320
|
+
change: (latestValue: V) => void;
|
|
2321
|
+
destroy: () => void;
|
|
2322
|
+
}
|
|
2323
|
+
interface ResolvedValues {
|
|
2324
|
+
[key: string]: AnyResolvedKeyframe;
|
|
2325
|
+
}
|
|
2326
|
+
interface Owner {
|
|
2327
|
+
current: HTMLElement | unknown;
|
|
2328
|
+
getProps: () => {
|
|
2329
|
+
onUpdate?: (latest: ResolvedValues) => void;
|
|
2330
|
+
transformTemplate?: (transform: TransformProperties, generatedTransform: string) => string;
|
|
2331
|
+
};
|
|
2332
|
+
}
|
|
2333
|
+
interface AccelerateConfig {
|
|
2334
|
+
factory: (animation: AnimationPlaybackControlsWithThen) => VoidFunction;
|
|
2335
|
+
times: number[];
|
|
2336
|
+
keyframes: any[];
|
|
2337
|
+
ease?: EasingFunction | EasingFunction[];
|
|
2338
|
+
duration: number;
|
|
2339
|
+
isTransformed?: boolean;
|
|
2340
|
+
}
|
|
2341
|
+
interface MotionValueOptions {
|
|
2342
|
+
owner?: Owner;
|
|
2343
|
+
}
|
|
2344
|
+
/**
|
|
2345
|
+
* `MotionValue` is used to track the state and velocity of motion values.
|
|
2346
|
+
*
|
|
2347
|
+
* @public
|
|
2348
|
+
*/
|
|
2349
|
+
declare class MotionValue<V = any> {
|
|
2350
|
+
/**
|
|
2351
|
+
* If a MotionValue has an owner, it was created internally within Motion
|
|
2352
|
+
* and therefore has no external listeners. It is therefore safe to animate via WAAPI.
|
|
2353
|
+
*/
|
|
2354
|
+
owner?: Owner;
|
|
2355
|
+
/**
|
|
2356
|
+
* The current state of the `MotionValue`.
|
|
2357
|
+
*/
|
|
2358
|
+
private current;
|
|
2359
|
+
/**
|
|
2360
|
+
* The previous state of the `MotionValue`.
|
|
2361
|
+
*/
|
|
2362
|
+
private prev;
|
|
2363
|
+
/**
|
|
2364
|
+
* The previous state of the `MotionValue` at the end of the previous frame.
|
|
2365
|
+
*/
|
|
2366
|
+
private prevFrameValue;
|
|
2367
|
+
/**
|
|
2368
|
+
* The last time the `MotionValue` was updated.
|
|
2369
|
+
*/
|
|
2370
|
+
updatedAt: number;
|
|
2371
|
+
/**
|
|
2372
|
+
* The time `prevFrameValue` was updated.
|
|
2373
|
+
*/
|
|
2374
|
+
prevUpdatedAt: number | undefined;
|
|
2375
|
+
private stopPassiveEffect?;
|
|
2376
|
+
/**
|
|
2377
|
+
* Whether the passive effect is active.
|
|
2378
|
+
*/
|
|
2379
|
+
isEffectActive?: boolean;
|
|
2380
|
+
/**
|
|
2381
|
+
* A reference to the currently-controlling animation.
|
|
2382
|
+
*/
|
|
2383
|
+
animation?: AnimationPlaybackControlsWithThen;
|
|
2384
|
+
/**
|
|
2385
|
+
* A list of MotionValues whose values are computed from this one.
|
|
2386
|
+
* This is a rough start to a proper signal-like dirtying system.
|
|
2387
|
+
*/
|
|
2388
|
+
private dependents;
|
|
2389
|
+
/**
|
|
2390
|
+
* Tracks whether this value should be removed
|
|
2391
|
+
*/
|
|
2392
|
+
liveStyle?: boolean;
|
|
2393
|
+
/**
|
|
2394
|
+
* Scroll timeline acceleration metadata. When set, VisualElement
|
|
2395
|
+
* can create a native WAAPI animation attached to a scroll timeline
|
|
2396
|
+
* instead of driving updates through JS.
|
|
2397
|
+
*/
|
|
2398
|
+
accelerate?: AccelerateConfig;
|
|
2399
|
+
/**
|
|
2400
|
+
* @param init - The initiating value
|
|
2401
|
+
* @param config - Optional configuration options
|
|
2402
|
+
*
|
|
2403
|
+
* - `transformer`: A function to transform incoming values with.
|
|
2404
|
+
*/
|
|
2405
|
+
constructor(init: V, options?: MotionValueOptions);
|
|
2406
|
+
setCurrent(current: V): void;
|
|
2407
|
+
setPrevFrameValue(prevFrameValue?: V | undefined): void;
|
|
2408
|
+
/**
|
|
2409
|
+
* Adds a function that will be notified when the `MotionValue` is updated.
|
|
2410
|
+
*
|
|
2411
|
+
* It returns a function that, when called, will cancel the subscription.
|
|
2412
|
+
*
|
|
2413
|
+
* When calling `onChange` inside a React component, it should be wrapped with the
|
|
2414
|
+
* `useEffect` hook. As it returns an unsubscribe function, this should be returned
|
|
2415
|
+
* from the `useEffect` function to ensure you don't add duplicate subscribers..
|
|
2416
|
+
*
|
|
2417
|
+
* ```jsx
|
|
2418
|
+
* export const MyComponent = () => {
|
|
2419
|
+
* const x = useMotionValue(0)
|
|
2420
|
+
* const y = useMotionValue(0)
|
|
2421
|
+
* const opacity = useMotionValue(1)
|
|
2422
|
+
*
|
|
2423
|
+
* useEffect(() => {
|
|
2424
|
+
* function updateOpacity() {
|
|
2425
|
+
* const maxXY = Math.max(x.get(), y.get())
|
|
2426
|
+
* const newOpacity = transform(maxXY, [0, 100], [1, 0])
|
|
2427
|
+
* opacity.set(newOpacity)
|
|
2428
|
+
* }
|
|
2429
|
+
*
|
|
2430
|
+
* const unsubscribeX = x.on("change", updateOpacity)
|
|
2431
|
+
* const unsubscribeY = y.on("change", updateOpacity)
|
|
2432
|
+
*
|
|
2433
|
+
* return () => {
|
|
2434
|
+
* unsubscribeX()
|
|
2435
|
+
* unsubscribeY()
|
|
2436
|
+
* }
|
|
2437
|
+
* }, [])
|
|
2438
|
+
*
|
|
2439
|
+
* return <motion.div style={{ x }} />
|
|
2440
|
+
* }
|
|
2441
|
+
* ```
|
|
2442
|
+
*
|
|
2443
|
+
* @param subscriber - A function that receives the latest value.
|
|
2444
|
+
* @returns A function that, when called, will cancel this subscription.
|
|
2445
|
+
*
|
|
2446
|
+
* @deprecated
|
|
2447
|
+
*/
|
|
2448
|
+
onChange(subscription: Subscriber<V>): () => void;
|
|
2449
|
+
/**
|
|
2450
|
+
* An object containing a SubscriptionManager for each active event.
|
|
2451
|
+
*/
|
|
2452
|
+
private events;
|
|
2453
|
+
on<EventName extends keyof MotionValueEventCallbacks<V>>(eventName: EventName, callback: MotionValueEventCallbacks<V>[EventName]): VoidFunction;
|
|
2454
|
+
clearListeners(): void;
|
|
2455
|
+
/**
|
|
2456
|
+
* Attaches a passive effect to the `MotionValue`.
|
|
2457
|
+
*/
|
|
2458
|
+
attach(passiveEffect: PassiveEffect<V>, stopPassiveEffect: VoidFunction): void;
|
|
2459
|
+
/**
|
|
2460
|
+
* Sets the state of the `MotionValue`.
|
|
2461
|
+
*
|
|
2462
|
+
* @remarks
|
|
2463
|
+
*
|
|
2464
|
+
* ```jsx
|
|
2465
|
+
* const x = useMotionValue(0)
|
|
2466
|
+
* x.set(10)
|
|
2467
|
+
* ```
|
|
2468
|
+
*
|
|
2469
|
+
* @param latest - Latest value to set.
|
|
2470
|
+
* @param render - Whether to notify render subscribers. Defaults to `true`
|
|
2471
|
+
*
|
|
2472
|
+
* @public
|
|
2473
|
+
*/
|
|
2474
|
+
set(v: V): void;
|
|
2475
|
+
setWithVelocity(prev: V, current: V, delta: number): void;
|
|
2476
|
+
/**
|
|
2477
|
+
* Set the state of the `MotionValue`, stopping any active animations,
|
|
2478
|
+
* effects, and resets velocity to `0`.
|
|
2479
|
+
*/
|
|
2480
|
+
jump(v: V, endAnimation?: boolean): void;
|
|
2481
|
+
dirty(): void;
|
|
2482
|
+
addDependent(dependent: MotionValue): void;
|
|
2483
|
+
removeDependent(dependent: MotionValue): void;
|
|
2484
|
+
updateAndNotify: (v: V) => void;
|
|
2485
|
+
/**
|
|
2486
|
+
* Returns the latest state of `MotionValue`
|
|
2487
|
+
*
|
|
2488
|
+
* @returns - The latest state of `MotionValue`
|
|
2489
|
+
*
|
|
2490
|
+
* @public
|
|
2491
|
+
*/
|
|
2492
|
+
get(): NonNullable<V>;
|
|
2493
|
+
/**
|
|
2494
|
+
* @public
|
|
2495
|
+
*/
|
|
2496
|
+
getPrevious(): V | undefined;
|
|
2497
|
+
/**
|
|
2498
|
+
* Returns the latest velocity of `MotionValue`
|
|
2499
|
+
*
|
|
2500
|
+
* @returns - The latest velocity of `MotionValue`. Returns `0` if the state is non-numerical.
|
|
2501
|
+
*
|
|
2502
|
+
* @public
|
|
2503
|
+
*/
|
|
2504
|
+
getVelocity(): number;
|
|
2505
|
+
hasAnimated: boolean;
|
|
2506
|
+
/**
|
|
2507
|
+
* Registers a new animation to control this `MotionValue`. Only one
|
|
2508
|
+
* animation can drive a `MotionValue` at one time.
|
|
2509
|
+
*
|
|
2510
|
+
* ```jsx
|
|
2511
|
+
* value.start()
|
|
2512
|
+
* ```
|
|
2513
|
+
*
|
|
2514
|
+
* @param animation - A function that starts the provided animation
|
|
2515
|
+
*/
|
|
2516
|
+
start(startAnimation: StartAnimation): Promise<void>;
|
|
2517
|
+
/**
|
|
2518
|
+
* Stop the currently active animation.
|
|
2519
|
+
*
|
|
2520
|
+
* @public
|
|
2521
|
+
*/
|
|
2522
|
+
stop(): void;
|
|
2523
|
+
/**
|
|
2524
|
+
* Returns `true` if this value is currently animating.
|
|
2525
|
+
*
|
|
2526
|
+
* @public
|
|
2527
|
+
*/
|
|
2528
|
+
isAnimating(): boolean;
|
|
2529
|
+
private clearAnimation;
|
|
2530
|
+
/**
|
|
2531
|
+
* Destroy and clean up subscribers to this `MotionValue`.
|
|
2532
|
+
*
|
|
2533
|
+
* The `MotionValue` hooks like `useMotionValue` and `useTransform` automatically
|
|
2534
|
+
* handle the lifecycle of the returned `MotionValue`, so this method is only necessary if you've manually
|
|
2535
|
+
* created a `MotionValue` via the `motionValue` function.
|
|
2536
|
+
*
|
|
2537
|
+
* @public
|
|
2538
|
+
*/
|
|
2539
|
+
destroy(): void;
|
|
2540
|
+
}
|
|
2541
|
+
type UnresolvedKeyframes<T extends AnyResolvedKeyframe> = Array<T | null>;
|
|
2542
|
+
type ResolvedKeyframes<T extends AnyResolvedKeyframe> = Array<T>;
|
|
2543
|
+
type OnKeyframesResolved<T extends AnyResolvedKeyframe> = (resolvedKeyframes: ResolvedKeyframes<T>, finalKeyframe: T, forced: boolean) => void;
|
|
2544
|
+
declare class KeyframeResolver<T extends AnyResolvedKeyframe = any> {
|
|
2545
|
+
name?: string;
|
|
2546
|
+
element?: WithRender;
|
|
2547
|
+
finalKeyframe?: T;
|
|
2548
|
+
suspendedScrollY?: number;
|
|
2549
|
+
protected unresolvedKeyframes: UnresolvedKeyframes<AnyResolvedKeyframe>;
|
|
2550
|
+
private motionValue?;
|
|
2551
|
+
private onComplete;
|
|
2552
|
+
state: "pending" | "scheduled" | "complete";
|
|
2553
|
+
/**
|
|
2554
|
+
* Track whether this resolver is async. If it is, it'll be added to the
|
|
2555
|
+
* resolver queue and flushed in the next frame. Resolvers that aren't going
|
|
2556
|
+
* to trigger read/write thrashing don't need to be async.
|
|
2557
|
+
*/
|
|
2558
|
+
private isAsync;
|
|
2559
|
+
/**
|
|
2560
|
+
* Track whether this resolver needs to perform a measurement
|
|
2561
|
+
* to resolve its keyframes.
|
|
2562
|
+
*/
|
|
2563
|
+
needsMeasurement: boolean;
|
|
2564
|
+
constructor(unresolvedKeyframes: UnresolvedKeyframes<AnyResolvedKeyframe>, onComplete: OnKeyframesResolved<T>, name?: string, motionValue?: MotionValue<T>, element?: WithRender, isAsync?: boolean);
|
|
2565
|
+
scheduleResolve(): void;
|
|
2566
|
+
readKeyframes(): void;
|
|
2567
|
+
setFinalKeyframe(): void;
|
|
2568
|
+
measureInitialState(): void;
|
|
2569
|
+
renderEndStyles(): void;
|
|
2570
|
+
measureEndState(): void;
|
|
2571
|
+
complete(isForcedComplete?: boolean): void;
|
|
2572
|
+
cancel(): void;
|
|
2573
|
+
resume(): void;
|
|
2574
|
+
}
|
|
2575
|
+
declare const optimizedAppearDataAttribute: "data-framer-appear-id";
|
|
2576
|
+
type Process = (data: FrameData) => void;
|
|
2577
|
+
type Schedule = (process: Process, keepAlive?: boolean, immediate?: boolean) => Process;
|
|
2578
|
+
type StepId = "setup" | "read" | "resolveKeyframes" | "preUpdate" | "update" | "preRender" | "render" | "postRender";
|
|
2579
|
+
type Batcher = { [key in StepId]: Schedule };
|
|
2580
|
+
interface FrameData {
|
|
2581
|
+
delta: number;
|
|
2582
|
+
timestamp: number;
|
|
2583
|
+
isProcessing: boolean;
|
|
2584
|
+
}
|
|
2585
|
+
|
|
2586
|
+
/**
|
|
2587
|
+
* Expose only the needed part of the VisualElement interface to
|
|
2588
|
+
* ensure React types don't end up in the generic DOM bundle.
|
|
2589
|
+
*/
|
|
2590
|
+
interface WithAppearProps {
|
|
2591
|
+
props: {
|
|
2592
|
+
[optimizedAppearDataAttribute]?: string;
|
|
2593
|
+
values?: {
|
|
2594
|
+
[key: string]: MotionValue<number> | MotionValue<string>;
|
|
2595
|
+
};
|
|
2596
|
+
};
|
|
2597
|
+
}
|
|
2598
|
+
type HandoffFunction = (storeId: string, valueName: string, frame: Batcher) => number | null;
|
|
2599
|
+
/**
|
|
2600
|
+
* The window global object acts as a bridge between our inline script
|
|
2601
|
+
* triggering the optimized appear animations, and Motion.
|
|
2602
|
+
*/
|
|
2603
|
+
declare global {
|
|
2604
|
+
interface Window {
|
|
2605
|
+
MotionHandoffAnimation?: HandoffFunction;
|
|
2606
|
+
MotionHandoffMarkAsComplete?: (elementId: string) => void;
|
|
2607
|
+
MotionHandoffIsComplete?: (elementId: string) => boolean;
|
|
2608
|
+
MotionHasOptimisedAnimation?: (elementId?: string, valueName?: string) => boolean;
|
|
2609
|
+
MotionCancelOptimisedAnimation?: (elementId?: string, valueName?: string, frame?: Batcher, canResume?: boolean) => void;
|
|
2610
|
+
MotionCheckAppearSync?: (visualElement: WithAppearProps, valueName: string, value: MotionValue) => VoidFunction | void;
|
|
2611
|
+
MotionIsMounted?: boolean;
|
|
2612
|
+
}
|
|
2613
|
+
}
|
|
2614
|
+
declare global {
|
|
2615
|
+
interface Window {
|
|
2616
|
+
ScrollTimeline: ScrollTimeline;
|
|
2617
|
+
ViewTimeline: ViewTimeline;
|
|
2618
|
+
}
|
|
2619
|
+
}
|
|
2620
|
+
declare class ScrollTimeline implements ProgressTimeline {
|
|
2621
|
+
constructor(options: ScrollOptions);
|
|
2622
|
+
currentTime: null | {
|
|
2623
|
+
value: number;
|
|
2624
|
+
};
|
|
2625
|
+
cancel?: VoidFunction;
|
|
2626
|
+
}
|
|
2627
|
+
declare class ViewTimeline implements ProgressTimeline {
|
|
2628
|
+
constructor(options: {
|
|
2629
|
+
subject: Element;
|
|
2630
|
+
axis?: string;
|
|
2631
|
+
});
|
|
2632
|
+
currentTime: null | {
|
|
2633
|
+
value: number;
|
|
2634
|
+
};
|
|
2635
|
+
cancel?: VoidFunction;
|
|
2636
|
+
}
|
|
2637
|
+
//#endregion
|
|
2638
|
+
//#region ../node_modules/.pnpm/framer-motion@12.40.0_@emotion+is-prop-valid@1.4.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/framer-motion/dist/index.d.ts
|
|
2639
|
+
type MotionValueString = MotionValue<string>;
|
|
2640
|
+
type MotionValueNumber = MotionValue<number>;
|
|
2641
|
+
type MotionValueAny = MotionValue<any>;
|
|
2642
|
+
type AnyMotionValue = MotionValueNumber | MotionValueString | MotionValueAny;
|
|
2643
|
+
type MotionValueHelper<T> = T | AnyMotionValue;
|
|
2644
|
+
type MakeMotionHelper<T> = { [K in keyof T]: MotionValueHelper<T[K]> };
|
|
2645
|
+
type MakeCustomValueTypeHelper<T> = MakeMotionHelper<T>;
|
|
2646
|
+
type MakeMotion<T> = MakeCustomValueTypeHelper<T>;
|
|
2647
|
+
type MotionCSS = MakeMotion<Omit<CSSProperties, "rotate" | "scale" | "perspective" | "x" | "y" | "z">>;
|
|
2648
|
+
/**
|
|
2649
|
+
* @public
|
|
2650
|
+
*/
|
|
2651
|
+
type MotionTransform = MakeMotion<TransformProperties>;
|
|
2652
|
+
type MotionSVGProps = MakeMotion<SVGPathProperties>;
|
|
2653
|
+
/**
|
|
2654
|
+
* @public
|
|
2655
|
+
*/
|
|
2656
|
+
interface MotionStyle extends MotionCSS, MotionTransform, MotionSVGProps {}
|
|
2657
|
+
/**
|
|
2658
|
+
* Props for `motion` components.
|
|
2659
|
+
*
|
|
2660
|
+
* @public
|
|
2661
|
+
*/
|
|
2662
|
+
interface MotionProps extends MotionNodeOptions {
|
|
2663
|
+
/**
|
|
2664
|
+
*
|
|
2665
|
+
* The React DOM `style` prop, enhanced with support for `MotionValue`s and separate `transform` values.
|
|
2666
|
+
*
|
|
2667
|
+
* ```jsx
|
|
2668
|
+
* export const MyComponent = () => {
|
|
2669
|
+
* const x = useMotionValue(0)
|
|
2670
|
+
*
|
|
2671
|
+
* return <motion.div style={{ x, opacity: 1, scale: 0.5 }} />
|
|
2672
|
+
* }
|
|
2673
|
+
* ```
|
|
2674
|
+
*/
|
|
2675
|
+
style?: MotionStyle;
|
|
2676
|
+
children?: React.ReactNode | MotionValueNumber | MotionValueString;
|
|
2677
|
+
}
|
|
2678
|
+
interface HTMLElements {
|
|
2679
|
+
a: HTMLAnchorElement;
|
|
2680
|
+
abbr: HTMLElement;
|
|
2681
|
+
address: HTMLElement;
|
|
2682
|
+
area: HTMLAreaElement;
|
|
2683
|
+
article: HTMLElement;
|
|
2684
|
+
aside: HTMLElement;
|
|
2685
|
+
audio: HTMLAudioElement;
|
|
2686
|
+
b: HTMLElement;
|
|
2687
|
+
base: HTMLBaseElement;
|
|
2688
|
+
bdi: HTMLElement;
|
|
2689
|
+
bdo: HTMLElement;
|
|
2690
|
+
big: HTMLElement;
|
|
2691
|
+
blockquote: HTMLQuoteElement;
|
|
2692
|
+
body: HTMLBodyElement;
|
|
2693
|
+
br: HTMLBRElement;
|
|
2694
|
+
button: HTMLButtonElement;
|
|
2695
|
+
canvas: HTMLCanvasElement;
|
|
2696
|
+
caption: HTMLElement;
|
|
2697
|
+
center: HTMLElement;
|
|
2698
|
+
cite: HTMLElement;
|
|
2699
|
+
code: HTMLElement;
|
|
2700
|
+
col: HTMLTableColElement;
|
|
2701
|
+
colgroup: HTMLTableColElement;
|
|
2702
|
+
data: HTMLDataElement;
|
|
2703
|
+
datalist: HTMLDataListElement;
|
|
2704
|
+
dd: HTMLElement;
|
|
2705
|
+
del: HTMLModElement;
|
|
2706
|
+
details: HTMLDetailsElement;
|
|
2707
|
+
dfn: HTMLElement;
|
|
2708
|
+
dialog: HTMLDialogElement;
|
|
2709
|
+
div: HTMLDivElement;
|
|
2710
|
+
dl: HTMLDListElement;
|
|
2711
|
+
dt: HTMLElement;
|
|
2712
|
+
em: HTMLElement;
|
|
2713
|
+
embed: HTMLEmbedElement;
|
|
2714
|
+
fieldset: HTMLFieldSetElement;
|
|
2715
|
+
figcaption: HTMLElement;
|
|
2716
|
+
figure: HTMLElement;
|
|
2717
|
+
footer: HTMLElement;
|
|
2718
|
+
form: HTMLFormElement;
|
|
2719
|
+
h1: HTMLHeadingElement;
|
|
2720
|
+
h2: HTMLHeadingElement;
|
|
2721
|
+
h3: HTMLHeadingElement;
|
|
2722
|
+
h4: HTMLHeadingElement;
|
|
2723
|
+
h5: HTMLHeadingElement;
|
|
2724
|
+
h6: HTMLHeadingElement;
|
|
2725
|
+
head: HTMLHeadElement;
|
|
2726
|
+
header: HTMLElement;
|
|
2727
|
+
hgroup: HTMLElement;
|
|
2728
|
+
hr: HTMLHRElement;
|
|
2729
|
+
html: HTMLHtmlElement;
|
|
2730
|
+
i: HTMLElement;
|
|
2731
|
+
iframe: HTMLIFrameElement;
|
|
2732
|
+
img: HTMLImageElement;
|
|
2733
|
+
input: HTMLInputElement;
|
|
2734
|
+
ins: HTMLModElement;
|
|
2735
|
+
kbd: HTMLElement;
|
|
2736
|
+
keygen: HTMLElement;
|
|
2737
|
+
label: HTMLLabelElement;
|
|
2738
|
+
legend: HTMLLegendElement;
|
|
2739
|
+
li: HTMLLIElement;
|
|
2740
|
+
link: HTMLLinkElement;
|
|
2741
|
+
main: HTMLElement;
|
|
2742
|
+
map: HTMLMapElement;
|
|
2743
|
+
mark: HTMLElement;
|
|
2744
|
+
menu: HTMLElement;
|
|
2745
|
+
menuitem: HTMLElement;
|
|
2746
|
+
meta: HTMLMetaElement;
|
|
2747
|
+
meter: HTMLMeterElement;
|
|
2748
|
+
nav: HTMLElement;
|
|
2749
|
+
noindex: HTMLElement;
|
|
2750
|
+
noscript: HTMLElement;
|
|
2751
|
+
object: HTMLObjectElement;
|
|
2752
|
+
ol: HTMLOListElement;
|
|
2753
|
+
optgroup: HTMLOptGroupElement;
|
|
2754
|
+
option: HTMLOptionElement;
|
|
2755
|
+
output: HTMLOutputElement;
|
|
2756
|
+
p: HTMLParagraphElement;
|
|
2757
|
+
param: HTMLParamElement;
|
|
2758
|
+
picture: HTMLElement;
|
|
2759
|
+
pre: HTMLPreElement;
|
|
2760
|
+
progress: HTMLProgressElement;
|
|
2761
|
+
q: HTMLQuoteElement;
|
|
2762
|
+
rp: HTMLElement;
|
|
2763
|
+
rt: HTMLElement;
|
|
2764
|
+
ruby: HTMLElement;
|
|
2765
|
+
s: HTMLElement;
|
|
2766
|
+
samp: HTMLElement;
|
|
2767
|
+
search: HTMLElement;
|
|
2768
|
+
slot: HTMLSlotElement;
|
|
2769
|
+
script: HTMLScriptElement;
|
|
2770
|
+
section: HTMLElement;
|
|
2771
|
+
select: HTMLSelectElement;
|
|
2772
|
+
small: HTMLElement;
|
|
2773
|
+
source: HTMLSourceElement;
|
|
2774
|
+
span: HTMLSpanElement;
|
|
2775
|
+
strong: HTMLElement;
|
|
2776
|
+
style: HTMLStyleElement;
|
|
2777
|
+
sub: HTMLElement;
|
|
2778
|
+
summary: HTMLElement;
|
|
2779
|
+
sup: HTMLElement;
|
|
2780
|
+
table: HTMLTableElement;
|
|
2781
|
+
template: HTMLTemplateElement;
|
|
2782
|
+
tbody: HTMLTableSectionElement;
|
|
2783
|
+
td: HTMLTableDataCellElement;
|
|
2784
|
+
textarea: HTMLTextAreaElement;
|
|
2785
|
+
tfoot: HTMLTableSectionElement;
|
|
2786
|
+
th: HTMLTableHeaderCellElement;
|
|
2787
|
+
thead: HTMLTableSectionElement;
|
|
2788
|
+
time: HTMLTimeElement;
|
|
2789
|
+
title: HTMLTitleElement;
|
|
2790
|
+
tr: HTMLTableRowElement;
|
|
2791
|
+
track: HTMLTrackElement;
|
|
2792
|
+
u: HTMLElement;
|
|
2793
|
+
ul: HTMLUListElement;
|
|
2794
|
+
var: HTMLElement;
|
|
2795
|
+
video: HTMLVideoElement;
|
|
2796
|
+
wbr: HTMLElement;
|
|
2797
|
+
webview: HTMLWebViewElement;
|
|
2798
|
+
}
|
|
2799
|
+
|
|
2800
|
+
/**
|
|
2801
|
+
* @public
|
|
2802
|
+
*/
|
|
2803
|
+
|
|
2804
|
+
type AttributesWithoutMotionProps<Attributes> = { [K in Exclude<keyof Attributes, keyof MotionProps>]?: Attributes[K] };
|
|
2805
|
+
/**
|
|
2806
|
+
* @public
|
|
2807
|
+
*/
|
|
2808
|
+
type HTMLMotionProps<Tag extends keyof HTMLElements> = AttributesWithoutMotionProps<JSX.IntrinsicElements[Tag]> & MotionProps;
|
|
2809
|
+
/**
|
|
2810
|
+
* Motion-optimised versions of React's HTML components.
|
|
2811
|
+
*
|
|
2812
|
+
* @public
|
|
2813
|
+
*/
|
|
2814
|
+
//#endregion
|
|
2815
|
+
//#region ../node_modules/.pnpm/@0xsequence+design-system@3.2.0_@types+react-dom@19.2.3_@types+react@19.2.7__@types+rea_e8a70ec65c6cffc31b8056c1e4b9de13/node_modules/@0xsequence/design-system/dist/index.d.ts
|
|
8
2816
|
declare const iconVariants: (props?: ({
|
|
9
2817
|
size?: "default" | "xxs" | "xs" | "sm" | "md" | "lg" | "xl" | null | undefined;
|
|
10
2818
|
} & ClassProp) | undefined) => string;
|