motion-dom 12.23.23 → 12.23.28

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/dist/index.d.ts DELETED
@@ -1,3158 +0,0 @@
1
- import { Box, Easing, EasingFunction, BezierDefinition, Point, BoundingBox, Axis } from 'motion-utils';
2
-
3
- interface SVGAttributes {
4
- accentHeight?: AnyResolvedKeyframe | undefined;
5
- accumulate?: "none" | "sum" | undefined;
6
- additive?: "replace" | "sum" | undefined;
7
- alignmentBaseline?: "auto" | "baseline" | "before-edge" | "text-before-edge" | "middle" | "central" | "after-edge" | "text-after-edge" | "ideographic" | "alphabetic" | "hanging" | "mathematical" | "inherit" | undefined;
8
- allowReorder?: "no" | "yes" | undefined;
9
- alphabetic?: AnyResolvedKeyframe | undefined;
10
- amplitude?: AnyResolvedKeyframe | undefined;
11
- arabicForm?: "initial" | "medial" | "terminal" | "isolated" | undefined;
12
- ascent?: AnyResolvedKeyframe | undefined;
13
- attributeName?: string | undefined;
14
- attributeType?: string | undefined;
15
- autoReverse?: boolean | undefined;
16
- azimuth?: AnyResolvedKeyframe | undefined;
17
- baseFrequency?: AnyResolvedKeyframe | undefined;
18
- baselineShift?: AnyResolvedKeyframe | undefined;
19
- baseProfile?: AnyResolvedKeyframe | undefined;
20
- bbox?: AnyResolvedKeyframe | undefined;
21
- begin?: AnyResolvedKeyframe | undefined;
22
- bias?: AnyResolvedKeyframe | undefined;
23
- by?: AnyResolvedKeyframe | undefined;
24
- calcMode?: AnyResolvedKeyframe | undefined;
25
- capHeight?: AnyResolvedKeyframe | undefined;
26
- clip?: AnyResolvedKeyframe | undefined;
27
- clipPath?: string | undefined;
28
- clipPathUnits?: AnyResolvedKeyframe | undefined;
29
- clipRule?: AnyResolvedKeyframe | undefined;
30
- colorInterpolation?: AnyResolvedKeyframe | undefined;
31
- colorInterpolationFilters?: "auto" | "sRGB" | "linearRGB" | "inherit" | undefined;
32
- colorProfile?: AnyResolvedKeyframe | undefined;
33
- colorRendering?: AnyResolvedKeyframe | undefined;
34
- contentScriptType?: AnyResolvedKeyframe | undefined;
35
- contentStyleType?: AnyResolvedKeyframe | undefined;
36
- cursor?: AnyResolvedKeyframe | undefined;
37
- cx?: AnyResolvedKeyframe | undefined;
38
- cy?: AnyResolvedKeyframe | undefined;
39
- d?: string | undefined;
40
- decelerate?: AnyResolvedKeyframe | undefined;
41
- descent?: AnyResolvedKeyframe | undefined;
42
- diffuseConstant?: AnyResolvedKeyframe | undefined;
43
- direction?: AnyResolvedKeyframe | undefined;
44
- display?: AnyResolvedKeyframe | undefined;
45
- divisor?: AnyResolvedKeyframe | undefined;
46
- dominantBaseline?: AnyResolvedKeyframe | undefined;
47
- dur?: AnyResolvedKeyframe | undefined;
48
- dx?: AnyResolvedKeyframe | undefined;
49
- dy?: AnyResolvedKeyframe | undefined;
50
- edgeMode?: AnyResolvedKeyframe | undefined;
51
- elevation?: AnyResolvedKeyframe | undefined;
52
- enableBackground?: AnyResolvedKeyframe | undefined;
53
- end?: AnyResolvedKeyframe | undefined;
54
- exponent?: AnyResolvedKeyframe | undefined;
55
- externalResourcesRequired?: boolean | undefined;
56
- fill?: string | undefined;
57
- fillOpacity?: AnyResolvedKeyframe | undefined;
58
- fillRule?: "nonzero" | "evenodd" | "inherit" | undefined;
59
- filter?: string | undefined;
60
- filterRes?: AnyResolvedKeyframe | undefined;
61
- filterUnits?: AnyResolvedKeyframe | undefined;
62
- floodColor?: AnyResolvedKeyframe | undefined;
63
- floodOpacity?: AnyResolvedKeyframe | undefined;
64
- focusable?: boolean | "auto" | undefined;
65
- fontFamily?: string | undefined;
66
- fontSize?: AnyResolvedKeyframe | undefined;
67
- fontSizeAdjust?: AnyResolvedKeyframe | undefined;
68
- fontStretch?: AnyResolvedKeyframe | undefined;
69
- fontStyle?: AnyResolvedKeyframe | undefined;
70
- fontVariant?: AnyResolvedKeyframe | undefined;
71
- fontWeight?: AnyResolvedKeyframe | undefined;
72
- format?: AnyResolvedKeyframe | undefined;
73
- fr?: AnyResolvedKeyframe | undefined;
74
- from?: AnyResolvedKeyframe | undefined;
75
- fx?: AnyResolvedKeyframe | undefined;
76
- fy?: AnyResolvedKeyframe | undefined;
77
- g1?: AnyResolvedKeyframe | undefined;
78
- g2?: AnyResolvedKeyframe | undefined;
79
- glyphName?: AnyResolvedKeyframe | undefined;
80
- glyphOrientationHorizontal?: AnyResolvedKeyframe | undefined;
81
- glyphOrientationVertical?: AnyResolvedKeyframe | undefined;
82
- glyphRef?: AnyResolvedKeyframe | undefined;
83
- gradientTransform?: string | undefined;
84
- gradientUnits?: string | undefined;
85
- hanging?: AnyResolvedKeyframe | undefined;
86
- horizAdvX?: AnyResolvedKeyframe | undefined;
87
- horizOriginX?: AnyResolvedKeyframe | undefined;
88
- href?: string | undefined;
89
- ideographic?: AnyResolvedKeyframe | undefined;
90
- imageRendering?: AnyResolvedKeyframe | undefined;
91
- in2?: AnyResolvedKeyframe | undefined;
92
- in?: string | undefined;
93
- intercept?: AnyResolvedKeyframe | undefined;
94
- k1?: AnyResolvedKeyframe | undefined;
95
- k2?: AnyResolvedKeyframe | undefined;
96
- k3?: AnyResolvedKeyframe | undefined;
97
- k4?: AnyResolvedKeyframe | undefined;
98
- k?: AnyResolvedKeyframe | undefined;
99
- kernelMatrix?: AnyResolvedKeyframe | undefined;
100
- kernelUnitLength?: AnyResolvedKeyframe | undefined;
101
- kerning?: AnyResolvedKeyframe | undefined;
102
- keyPoints?: AnyResolvedKeyframe | undefined;
103
- keySplines?: AnyResolvedKeyframe | undefined;
104
- keyTimes?: AnyResolvedKeyframe | undefined;
105
- lengthAdjust?: AnyResolvedKeyframe | undefined;
106
- letterSpacing?: AnyResolvedKeyframe | undefined;
107
- lightingColor?: AnyResolvedKeyframe | undefined;
108
- limitingConeAngle?: AnyResolvedKeyframe | undefined;
109
- local?: AnyResolvedKeyframe | undefined;
110
- markerEnd?: string | undefined;
111
- markerHeight?: AnyResolvedKeyframe | undefined;
112
- markerMid?: string | undefined;
113
- markerStart?: string | undefined;
114
- markerUnits?: AnyResolvedKeyframe | undefined;
115
- markerWidth?: AnyResolvedKeyframe | undefined;
116
- mask?: string | undefined;
117
- maskContentUnits?: AnyResolvedKeyframe | undefined;
118
- maskUnits?: AnyResolvedKeyframe | undefined;
119
- mathematical?: AnyResolvedKeyframe | undefined;
120
- mode?: AnyResolvedKeyframe | undefined;
121
- numOctaves?: AnyResolvedKeyframe | undefined;
122
- offset?: AnyResolvedKeyframe | undefined;
123
- opacity?: AnyResolvedKeyframe | undefined;
124
- operator?: AnyResolvedKeyframe | undefined;
125
- order?: AnyResolvedKeyframe | undefined;
126
- orient?: AnyResolvedKeyframe | undefined;
127
- orientation?: AnyResolvedKeyframe | undefined;
128
- origin?: AnyResolvedKeyframe | undefined;
129
- overflow?: AnyResolvedKeyframe | undefined;
130
- overlinePosition?: AnyResolvedKeyframe | undefined;
131
- overlineThickness?: AnyResolvedKeyframe | undefined;
132
- paintOrder?: AnyResolvedKeyframe | undefined;
133
- panose1?: AnyResolvedKeyframe | undefined;
134
- path?: string | undefined;
135
- pathLength?: AnyResolvedKeyframe | undefined;
136
- patternContentUnits?: string | undefined;
137
- patternTransform?: AnyResolvedKeyframe | undefined;
138
- patternUnits?: string | undefined;
139
- pointerEvents?: AnyResolvedKeyframe | undefined;
140
- points?: string | undefined;
141
- pointsAtX?: AnyResolvedKeyframe | undefined;
142
- pointsAtY?: AnyResolvedKeyframe | undefined;
143
- pointsAtZ?: AnyResolvedKeyframe | undefined;
144
- preserveAlpha?: boolean | undefined;
145
- preserveAspectRatio?: string | undefined;
146
- primitiveUnits?: AnyResolvedKeyframe | undefined;
147
- r?: AnyResolvedKeyframe | undefined;
148
- radius?: AnyResolvedKeyframe | undefined;
149
- refX?: AnyResolvedKeyframe | undefined;
150
- refY?: AnyResolvedKeyframe | undefined;
151
- renderingIntent?: AnyResolvedKeyframe | undefined;
152
- repeatCount?: AnyResolvedKeyframe | undefined;
153
- repeatDur?: AnyResolvedKeyframe | undefined;
154
- requiredExtensions?: AnyResolvedKeyframe | undefined;
155
- requiredFeatures?: AnyResolvedKeyframe | undefined;
156
- restart?: AnyResolvedKeyframe | undefined;
157
- result?: string | undefined;
158
- rotate?: AnyResolvedKeyframe | undefined;
159
- rx?: AnyResolvedKeyframe | undefined;
160
- ry?: AnyResolvedKeyframe | undefined;
161
- scale?: AnyResolvedKeyframe | undefined;
162
- seed?: AnyResolvedKeyframe | undefined;
163
- shapeRendering?: AnyResolvedKeyframe | undefined;
164
- slope?: AnyResolvedKeyframe | undefined;
165
- spacing?: AnyResolvedKeyframe | undefined;
166
- specularConstant?: AnyResolvedKeyframe | undefined;
167
- specularExponent?: AnyResolvedKeyframe | undefined;
168
- speed?: AnyResolvedKeyframe | undefined;
169
- spreadMethod?: string | undefined;
170
- startOffset?: AnyResolvedKeyframe | undefined;
171
- stdDeviation?: AnyResolvedKeyframe | undefined;
172
- stemh?: AnyResolvedKeyframe | undefined;
173
- stemv?: AnyResolvedKeyframe | undefined;
174
- stitchTiles?: AnyResolvedKeyframe | undefined;
175
- stopColor?: string | undefined;
176
- stopOpacity?: AnyResolvedKeyframe | undefined;
177
- strikethroughPosition?: AnyResolvedKeyframe | undefined;
178
- strikethroughThickness?: AnyResolvedKeyframe | undefined;
179
- string?: AnyResolvedKeyframe | undefined;
180
- stroke?: string | undefined;
181
- strokeDasharray?: AnyResolvedKeyframe | undefined;
182
- strokeDashoffset?: AnyResolvedKeyframe | undefined;
183
- strokeLinecap?: "butt" | "round" | "square" | "inherit" | undefined;
184
- strokeLinejoin?: "miter" | "round" | "bevel" | "inherit" | undefined;
185
- strokeMiterlimit?: AnyResolvedKeyframe | undefined;
186
- strokeOpacity?: AnyResolvedKeyframe | undefined;
187
- strokeWidth?: AnyResolvedKeyframe | undefined;
188
- surfaceScale?: AnyResolvedKeyframe | undefined;
189
- systemLanguage?: AnyResolvedKeyframe | undefined;
190
- tableValues?: AnyResolvedKeyframe | undefined;
191
- targetX?: AnyResolvedKeyframe | undefined;
192
- targetY?: AnyResolvedKeyframe | undefined;
193
- textAnchor?: string | undefined;
194
- textDecoration?: AnyResolvedKeyframe | undefined;
195
- textLength?: AnyResolvedKeyframe | undefined;
196
- textRendering?: AnyResolvedKeyframe | undefined;
197
- to?: AnyResolvedKeyframe | undefined;
198
- transform?: string | undefined;
199
- u1?: AnyResolvedKeyframe | undefined;
200
- u2?: AnyResolvedKeyframe | undefined;
201
- underlinePosition?: AnyResolvedKeyframe | undefined;
202
- underlineThickness?: AnyResolvedKeyframe | undefined;
203
- unicode?: AnyResolvedKeyframe | undefined;
204
- unicodeBidi?: AnyResolvedKeyframe | undefined;
205
- unicodeRange?: AnyResolvedKeyframe | undefined;
206
- unitsPerEm?: AnyResolvedKeyframe | undefined;
207
- vAlphabetic?: AnyResolvedKeyframe | undefined;
208
- values?: string | undefined;
209
- vectorEffect?: AnyResolvedKeyframe | undefined;
210
- version?: string | undefined;
211
- vertAdvY?: AnyResolvedKeyframe | undefined;
212
- vertOriginX?: AnyResolvedKeyframe | undefined;
213
- vertOriginY?: AnyResolvedKeyframe | undefined;
214
- vHanging?: AnyResolvedKeyframe | undefined;
215
- vIdeographic?: AnyResolvedKeyframe | undefined;
216
- viewBox?: string | undefined;
217
- viewTarget?: AnyResolvedKeyframe | undefined;
218
- visibility?: AnyResolvedKeyframe | undefined;
219
- vMathematical?: AnyResolvedKeyframe | undefined;
220
- widths?: AnyResolvedKeyframe | undefined;
221
- wordSpacing?: AnyResolvedKeyframe | undefined;
222
- writingMode?: AnyResolvedKeyframe | undefined;
223
- x1?: AnyResolvedKeyframe | undefined;
224
- x2?: AnyResolvedKeyframe | undefined;
225
- x?: AnyResolvedKeyframe | undefined;
226
- xChannelSelector?: string | undefined;
227
- xHeight?: AnyResolvedKeyframe | undefined;
228
- xlinkActuate?: string | undefined;
229
- xlinkArcrole?: string | undefined;
230
- xlinkHref?: string | undefined;
231
- xlinkRole?: string | undefined;
232
- xlinkShow?: string | undefined;
233
- xlinkTitle?: string | undefined;
234
- xlinkType?: string | undefined;
235
- xmlBase?: string | undefined;
236
- xmlLang?: string | undefined;
237
- xmlns?: string | undefined;
238
- xmlnsXlink?: string | undefined;
239
- xmlSpace?: string | undefined;
240
- y1?: AnyResolvedKeyframe | undefined;
241
- y2?: AnyResolvedKeyframe | undefined;
242
- y?: AnyResolvedKeyframe | undefined;
243
- yChannelSelector?: string | undefined;
244
- z?: AnyResolvedKeyframe | undefined;
245
- zoomAndPan?: string | undefined;
246
- }
247
-
248
- /**
249
- * An update function. It accepts a timestamp used to advance the animation.
250
- */
251
- type Update$1 = (timestamp: number) => void;
252
- /**
253
- * Drivers accept a update function and call it at an interval. This interval
254
- * could be a synchronous loop, a setInterval, or tied to the device's framerate.
255
- */
256
- interface DriverControls {
257
- start: (keepAlive?: boolean) => void;
258
- stop: () => void;
259
- now: () => number;
260
- }
261
- type Driver = (update: Update$1) => DriverControls;
262
-
263
- /**
264
- * Temporary subset of VisualElement until VisualElement is
265
- * moved to motion-dom
266
- */
267
- interface WithRender {
268
- render: () => void;
269
- readValue: (name: string, keyframe: any) => any;
270
- getValue: (name: string, defaultValue?: any) => any;
271
- current?: HTMLElement | SVGElement;
272
- measureViewportBox: () => Box;
273
- }
274
-
275
- type AnyResolvedKeyframe = string | number;
276
- interface ProgressTimeline {
277
- currentTime: null | {
278
- value: number;
279
- };
280
- cancel?: VoidFunction;
281
- }
282
- interface ValueAnimationOptionsWithRenderContext<V extends AnyResolvedKeyframe = number> extends ValueAnimationOptions<V> {
283
- KeyframeResolver?: typeof KeyframeResolver;
284
- motionValue?: MotionValue<V>;
285
- element?: WithRender;
286
- }
287
- interface TimelineWithFallback {
288
- timeline?: ProgressTimeline;
289
- observe: (animation: AnimationPlaybackControls) => VoidFunction;
290
- }
291
- /**
292
- * Methods to control an animation.
293
- */
294
- interface AnimationPlaybackControls {
295
- /**
296
- * The current time of the animation, in seconds.
297
- */
298
- time: number;
299
- /**
300
- * The playback speed of the animation.
301
- * 1 = normal speed, 2 = double speed, 0.5 = half speed.
302
- */
303
- speed: number;
304
- /**
305
- * The start time of the animation, in milliseconds.
306
- */
307
- startTime: number | null;
308
- /**
309
- * The state of the animation.
310
- *
311
- * This is currently for internal use only.
312
- */
313
- state: AnimationPlayState;
314
- duration: number;
315
- /**
316
- * The duration of the animation, including any delay.
317
- */
318
- iterationDuration: number;
319
- /**
320
- * Stops the animation at its current state, and prevents it from
321
- * resuming when the animation is played again.
322
- */
323
- stop: () => void;
324
- /**
325
- * Plays the animation.
326
- */
327
- play: () => void;
328
- /**
329
- * Pauses the animation.
330
- */
331
- pause: () => void;
332
- /**
333
- * Completes the animation and applies the final state.
334
- */
335
- complete: () => void;
336
- /**
337
- * Cancels the animation and applies the initial state.
338
- */
339
- cancel: () => void;
340
- /**
341
- * Attaches a timeline to the animation, for instance the `ScrollTimeline`.
342
- *
343
- * This is currently for internal use only.
344
- */
345
- attachTimeline: (timeline: TimelineWithFallback) => VoidFunction;
346
- finished: Promise<any>;
347
- }
348
- type AnimationPlaybackControlsWithThen = AnimationPlaybackControls & {
349
- then: (onResolve: VoidFunction, onReject?: VoidFunction) => Promise<void>;
350
- };
351
- interface AnimationState<V> {
352
- value: V;
353
- done: boolean;
354
- }
355
- interface KeyframeGenerator<V> {
356
- calculatedDuration: null | number;
357
- next: (t: number) => AnimationState<V>;
358
- toString: () => string;
359
- }
360
- interface DOMValueAnimationOptions<V extends AnyResolvedKeyframe = number> extends ValueAnimationTransition<V> {
361
- element: HTMLElement | SVGElement;
362
- keyframes: ValueKeyframesDefinition;
363
- name: string;
364
- pseudoElement?: string;
365
- allowFlatten?: boolean;
366
- }
367
- interface ValueAnimationOptions<V extends AnyResolvedKeyframe = number> extends ValueAnimationTransition {
368
- keyframes: V[];
369
- element?: any;
370
- name?: string;
371
- motionValue?: MotionValue<V>;
372
- from?: any;
373
- isHandoff?: boolean;
374
- allowFlatten?: boolean;
375
- finalKeyframe?: V;
376
- }
377
- type GeneratorFactoryFunction = (options: ValueAnimationOptions<any>) => KeyframeGenerator<any>;
378
- interface GeneratorFactory extends GeneratorFactoryFunction {
379
- applyToOptions?: (options: Transition) => Transition;
380
- }
381
- type AnimationGeneratorName = "decay" | "spring" | "keyframes" | "tween" | "inertia";
382
- type AnimationGeneratorType = GeneratorFactory | AnimationGeneratorName | false;
383
- interface AnimationPlaybackLifecycles<V> {
384
- onUpdate?: (latest: V) => void;
385
- onPlay?: () => void;
386
- onComplete?: () => void;
387
- onRepeat?: () => void;
388
- onStop?: () => void;
389
- }
390
- interface ValueAnimationTransition<V = any> extends ValueTransition, AnimationPlaybackLifecycles<V> {
391
- isSync?: boolean;
392
- }
393
- type RepeatType = "loop" | "reverse" | "mirror";
394
- interface AnimationPlaybackOptions {
395
- /**
396
- * The number of times to repeat the transition. Set to `Infinity` for perpetual repeating.
397
- *
398
- * Without setting `repeatType`, this will loop the animation.
399
- *
400
- * @public
401
- */
402
- repeat?: number;
403
- /**
404
- * How to repeat the animation. This can be either:
405
- *
406
- * "loop": Repeats the animation from the start
407
- *
408
- * "reverse": Alternates between forward and backwards playback
409
- *
410
- * "mirror": Switches `from` and `to` alternately
411
- *
412
- * @public
413
- */
414
- repeatType?: RepeatType;
415
- /**
416
- * When repeating an animation, `repeatDelay` will set the
417
- * duration of the time to wait, in seconds, between each repetition.
418
- *
419
- * @public
420
- */
421
- repeatDelay?: number;
422
- }
423
- interface VelocityOptions {
424
- velocity?: number;
425
- /**
426
- * End animation if absolute speed (in units per second) drops below this
427
- * value and delta is smaller than `restDelta`. Set to `0.01` by default.
428
- *
429
- * @public
430
- */
431
- restSpeed?: number;
432
- /**
433
- * End animation if distance is below this value and speed is below
434
- * `restSpeed`. When animation ends, spring gets "snapped" to. Set to
435
- * `0.01` by default.
436
- *
437
- * @public
438
- */
439
- restDelta?: number;
440
- }
441
- interface DurationSpringOptions {
442
- /**
443
- * The total duration of the animation. Set to `0.3` by default.
444
- *
445
- * @public
446
- */
447
- duration?: number;
448
- /**
449
- * If visualDuration is set, this will override duration.
450
- *
451
- * The visual duration is a time, set in seconds, that the animation will take to visually appear to reach its target.
452
- *
453
- * In other words, the bulk of the transition will occur before this time, and the "bouncy bit" will mostly happen after.
454
- *
455
- * This makes it easier to edit a spring, as well as visually coordinate it with other time-based animations.
456
- *
457
- * @public
458
- */
459
- visualDuration?: number;
460
- /**
461
- * `bounce` determines the "bounciness" of a spring animation.
462
- *
463
- * `0` is no bounce, and `1` is extremely bouncy.
464
- *
465
- * If `duration` is set, this defaults to `0.25`.
466
- *
467
- * Note: `bounce` and `duration` will be overridden if `stiffness`, `damping` or `mass` are set.
468
- *
469
- * @public
470
- */
471
- bounce?: number;
472
- }
473
- interface SpringOptions extends DurationSpringOptions, VelocityOptions {
474
- /**
475
- * Stiffness of the spring. Higher values will create more sudden movement.
476
- * Set to `100` by default.
477
- *
478
- * @public
479
- */
480
- stiffness?: number;
481
- /**
482
- * Strength of opposing force. If set to 0, spring will oscillate
483
- * indefinitely. Set to `10` by default.
484
- *
485
- * @public
486
- */
487
- damping?: number;
488
- /**
489
- * Mass of the moving object. Higher values will result in more lethargic
490
- * movement. Set to `1` by default.
491
- *
492
- * @public
493
- */
494
- mass?: number;
495
- }
496
- /**
497
- * @deprecated Use SpringOptions instead
498
- */
499
- interface Spring extends SpringOptions {
500
- }
501
- interface DecayOptions extends VelocityOptions {
502
- keyframes?: number[];
503
- /**
504
- * A higher power value equals a further target. Set to `0.8` by default.
505
- *
506
- * @public
507
- */
508
- power?: number;
509
- /**
510
- * Adjusting the time constant will change the duration of the
511
- * deceleration, thereby affecting its feel. Set to `700` by default.
512
- *
513
- * @public
514
- */
515
- timeConstant?: number;
516
- /**
517
- * A function that receives the automatically-calculated target and returns a new one. Useful for snapping the target to a grid.
518
- *
519
- * @public
520
- */
521
- modifyTarget?: (v: number) => number;
522
- }
523
- interface InertiaOptions extends DecayOptions {
524
- /**
525
- * If `min` or `max` is set, this affects the stiffness of the bounce
526
- * spring. Higher values will create more sudden movement. Set to `500` by
527
- * default.
528
- *
529
- * @public
530
- */
531
- bounceStiffness?: number;
532
- /**
533
- * If `min` or `max` is set, this affects the damping of the bounce spring.
534
- * If set to `0`, spring will oscillate indefinitely. Set to `10` by
535
- * default.
536
- *
537
- * @public
538
- */
539
- bounceDamping?: number;
540
- /**
541
- * 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).
542
- *
543
- * @public
544
- */
545
- min?: number;
546
- /**
547
- * Maximum constraint. If set, the value will "bump" against this value (or immediately snap to it, if the initial animation value exceeds this value).
548
- *
549
- * @public
550
- */
551
- max?: number;
552
- }
553
- interface AnimationOrchestrationOptions {
554
- /**
555
- * Delay the animation by this duration (in seconds). Defaults to `0`.
556
- *
557
- * @public
558
- */
559
- delay?: number;
560
- /**
561
- * Describes the relationship between the transition and its children. Set
562
- * to `false` by default.
563
- *
564
- * @remarks
565
- * When using variants, the transition can be scheduled in relation to its
566
- * children with either `"beforeChildren"` to finish this transition before
567
- * starting children transitions, `"afterChildren"` to finish children
568
- * transitions before starting this transition.
569
- *
570
- * @public
571
- */
572
- when?: false | "beforeChildren" | "afterChildren" | string;
573
- /**
574
- * When using variants, children animations will start after this duration
575
- * (in seconds). You can add the `transition` property to both the `motion.div` and the
576
- * `variant` directly. Adding it to the `variant` generally offers more flexibility,
577
- * as it allows you to customize the delay per visual state.
578
- *
579
- * @public
580
- */
581
- delayChildren?: number | DynamicOption<number>;
582
- /**
583
- * When using variants, animations of child components can be staggered by this
584
- * duration (in seconds).
585
- *
586
- * For instance, if `staggerChildren` is `0.01`, the first child will be
587
- * delayed by `0` seconds, the second by `0.01`, the third by `0.02` and so
588
- * on.
589
- *
590
- * The calculated stagger delay will be added to `delayChildren`.
591
- *
592
- * @deprecated - Use `delayChildren: stagger(interval)` instead.
593
- */
594
- staggerChildren?: number;
595
- /**
596
- * The direction in which to stagger children.
597
- *
598
- * A value of `1` staggers from the first to the last while `-1`
599
- * staggers from the last to the first.
600
- *
601
- * @deprecated - Use `delayChildren: stagger(interval, { from: "last" })` instead.
602
- */
603
- staggerDirection?: number;
604
- }
605
- interface KeyframeOptions {
606
- /**
607
- * The total duration of the animation. Set to `0.3` by default.
608
- *
609
- * @public
610
- */
611
- duration?: number;
612
- ease?: Easing | Easing[];
613
- times?: number[];
614
- }
615
- interface ValueTransition extends AnimationOrchestrationOptions, AnimationPlaybackOptions, Omit<SpringOptions, "keyframes">, Omit<InertiaOptions, "keyframes">, KeyframeOptions {
616
- /**
617
- * Delay the animation by this duration (in seconds). Defaults to `0`.
618
- *
619
- * @public
620
- */
621
- delay?: number;
622
- /**
623
- * The duration of time already elapsed in the animation. Set to `0` by
624
- * default.
625
- */
626
- elapsed?: number;
627
- driver?: Driver;
628
- /**
629
- * Type of animation to use.
630
- *
631
- * - "tween": Duration-based animation with ease curve
632
- * - "spring": Physics or duration-based spring animation
633
- * - false: Use an instant animation
634
- */
635
- type?: AnimationGeneratorType;
636
- /**
637
- * The duration of the tween animation. Set to `0.3` by default, 0r `0.8` if animating a series of keyframes.
638
- *
639
- * @public
640
- */
641
- duration?: number;
642
- autoplay?: boolean;
643
- startTime?: number;
644
- from?: any;
645
- }
646
- /**
647
- * @deprecated Use KeyframeOptions instead
648
- */
649
- interface Tween extends KeyframeOptions {
650
- }
651
- type SVGForcedAttrTransitions = {
652
- [K in keyof SVGForcedAttrProperties]: ValueTransition;
653
- };
654
- type SVGPathTransitions = {
655
- [K in keyof SVGPathProperties]: ValueTransition;
656
- };
657
- type SVGTransitions = {
658
- [K in keyof Omit<SVGAttributes, "from">]: ValueTransition;
659
- };
660
- interface VariableTransitions {
661
- [key: `--${string}`]: ValueTransition;
662
- }
663
- type StyleTransitions = {
664
- [K in keyof CSSStyleDeclarationWithTransform]?: ValueTransition;
665
- };
666
- type ValueKeyframe<T extends AnyResolvedKeyframe = AnyResolvedKeyframe> = T;
667
- type UnresolvedValueKeyframe<T extends AnyResolvedKeyframe = AnyResolvedKeyframe> = ValueKeyframe<T> | null;
668
- type ResolvedValueKeyframe = ValueKeyframe | ValueKeyframe[];
669
- type ValueKeyframesDefinition = ValueKeyframe | ValueKeyframe[] | UnresolvedValueKeyframe[];
670
- type StyleKeyframesDefinition = {
671
- [K in keyof CSSStyleDeclarationWithTransform]?: ValueKeyframesDefinition;
672
- };
673
- type SVGKeyframesDefinition = {
674
- [K in keyof Omit<SVGAttributes, "from">]?: ValueKeyframesDefinition;
675
- };
676
- interface VariableKeyframesDefinition {
677
- [key: `--${string}`]: ValueKeyframesDefinition;
678
- }
679
- type SVGForcedAttrKeyframesDefinition = {
680
- [K in keyof SVGForcedAttrProperties]?: ValueKeyframesDefinition;
681
- };
682
- type SVGPathKeyframesDefinition = {
683
- [K in keyof SVGPathProperties]?: ValueKeyframesDefinition;
684
- };
685
- type DOMKeyframesDefinition = StyleKeyframesDefinition & SVGKeyframesDefinition & SVGPathKeyframesDefinition & SVGForcedAttrKeyframesDefinition & VariableKeyframesDefinition;
686
- interface Target extends DOMKeyframesDefinition {
687
- }
688
- type CSSPropertyKeys = {
689
- [K in keyof CSSStyleDeclaration as K extends string ? CSSStyleDeclaration[K] extends AnyResolvedKeyframe ? K : never : never]: CSSStyleDeclaration[K];
690
- };
691
- interface CSSStyleDeclarationWithTransform extends Omit<CSSPropertyKeys, "direction" | "transition" | "x" | "y" | "z"> {
692
- x: number | string;
693
- y: number | string;
694
- z: number | string;
695
- originX: number;
696
- originY: number;
697
- originZ: number;
698
- translateX: number | string;
699
- translateY: number | string;
700
- translateZ: number | string;
701
- rotateX: number | string;
702
- rotateY: number | string;
703
- rotateZ: number | string;
704
- scaleX: number;
705
- scaleY: number;
706
- scaleZ: number;
707
- skewX: number | string;
708
- skewY: number | string;
709
- transformPerspective: number;
710
- }
711
- type TransitionWithValueOverrides<V> = ValueAnimationTransition<V> & StyleTransitions & SVGPathTransitions & SVGForcedAttrTransitions & SVGTransitions & VariableTransitions & {
712
- default?: ValueTransition;
713
- layout?: ValueTransition;
714
- };
715
- type Transition<V = any> = ValueAnimationTransition<V> | TransitionWithValueOverrides<V>;
716
- type DynamicOption<T> = (i: number, total: number) => T;
717
- type ValueAnimationWithDynamicDelay = Omit<ValueAnimationTransition<any>, "delay"> & {
718
- delay?: number | DynamicOption<number>;
719
- };
720
- type AnimationOptions = ValueAnimationWithDynamicDelay | (ValueAnimationWithDynamicDelay & StyleTransitions & SVGPathTransitions & SVGForcedAttrTransitions & SVGTransitions & VariableTransitions & {
721
- default?: ValueTransition;
722
- layout?: ValueTransition;
723
- });
724
- interface TransformProperties {
725
- x?: AnyResolvedKeyframe;
726
- y?: AnyResolvedKeyframe;
727
- z?: AnyResolvedKeyframe;
728
- translateX?: AnyResolvedKeyframe;
729
- translateY?: AnyResolvedKeyframe;
730
- translateZ?: AnyResolvedKeyframe;
731
- rotate?: AnyResolvedKeyframe;
732
- rotateX?: AnyResolvedKeyframe;
733
- rotateY?: AnyResolvedKeyframe;
734
- rotateZ?: AnyResolvedKeyframe;
735
- scale?: AnyResolvedKeyframe;
736
- scaleX?: AnyResolvedKeyframe;
737
- scaleY?: AnyResolvedKeyframe;
738
- scaleZ?: AnyResolvedKeyframe;
739
- skew?: AnyResolvedKeyframe;
740
- skewX?: AnyResolvedKeyframe;
741
- skewY?: AnyResolvedKeyframe;
742
- originX?: AnyResolvedKeyframe;
743
- originY?: AnyResolvedKeyframe;
744
- originZ?: AnyResolvedKeyframe;
745
- perspective?: AnyResolvedKeyframe;
746
- transformPerspective?: AnyResolvedKeyframe;
747
- }
748
- interface SVGForcedAttrProperties {
749
- attrX?: number;
750
- attrY?: number;
751
- attrScale?: number;
752
- }
753
- interface SVGPathProperties {
754
- pathLength?: number;
755
- pathOffset?: number;
756
- pathSpacing?: number;
757
- }
758
-
759
- /**
760
- * @public
761
- */
762
- type Subscriber<T> = (v: T) => void;
763
- /**
764
- * @public
765
- */
766
- type PassiveEffect<T> = (v: T, safeSetter: (v: T) => void) => void;
767
- type StartAnimation = (complete: () => void) => AnimationPlaybackControlsWithThen | undefined;
768
- interface MotionValueEventCallbacks<V> {
769
- animationStart: () => void;
770
- animationComplete: () => void;
771
- animationCancel: () => void;
772
- change: (latestValue: V) => void;
773
- destroy: () => void;
774
- }
775
- interface ResolvedValues$1 {
776
- [key: string]: AnyResolvedKeyframe;
777
- }
778
- interface Owner {
779
- current: HTMLElement | unknown;
780
- getProps: () => {
781
- onUpdate?: (latest: ResolvedValues$1) => void;
782
- transformTemplate?: (transform: TransformProperties, generatedTransform: string) => string;
783
- };
784
- }
785
- interface MotionValueOptions {
786
- owner?: Owner;
787
- }
788
- declare const collectMotionValues: {
789
- current: MotionValue[] | undefined;
790
- };
791
- /**
792
- * `MotionValue` is used to track the state and velocity of motion values.
793
- *
794
- * @public
795
- */
796
- declare class MotionValue<V = any> {
797
- /**
798
- * If a MotionValue has an owner, it was created internally within Motion
799
- * and therefore has no external listeners. It is therefore safe to animate via WAAPI.
800
- */
801
- owner?: Owner;
802
- /**
803
- * The current state of the `MotionValue`.
804
- */
805
- private current;
806
- /**
807
- * The previous state of the `MotionValue`.
808
- */
809
- private prev;
810
- /**
811
- * The previous state of the `MotionValue` at the end of the previous frame.
812
- */
813
- private prevFrameValue;
814
- /**
815
- * The last time the `MotionValue` was updated.
816
- */
817
- updatedAt: number;
818
- /**
819
- * The time `prevFrameValue` was updated.
820
- */
821
- prevUpdatedAt: number | undefined;
822
- private stopPassiveEffect?;
823
- /**
824
- * Whether the passive effect is active.
825
- */
826
- isEffectActive?: boolean;
827
- /**
828
- * A reference to the currently-controlling animation.
829
- */
830
- animation?: AnimationPlaybackControlsWithThen;
831
- /**
832
- * A list of MotionValues whose values are computed from this one.
833
- * This is a rough start to a proper signal-like dirtying system.
834
- */
835
- private dependents;
836
- /**
837
- * Tracks whether this value should be removed
838
- */
839
- liveStyle?: boolean;
840
- /**
841
- * @param init - The initiating value
842
- * @param config - Optional configuration options
843
- *
844
- * - `transformer`: A function to transform incoming values with.
845
- */
846
- constructor(init: V, options?: MotionValueOptions);
847
- setCurrent(current: V): void;
848
- setPrevFrameValue(prevFrameValue?: V | undefined): void;
849
- /**
850
- * Adds a function that will be notified when the `MotionValue` is updated.
851
- *
852
- * It returns a function that, when called, will cancel the subscription.
853
- *
854
- * When calling `onChange` inside a React component, it should be wrapped with the
855
- * `useEffect` hook. As it returns an unsubscribe function, this should be returned
856
- * from the `useEffect` function to ensure you don't add duplicate subscribers..
857
- *
858
- * ```jsx
859
- * export const MyComponent = () => {
860
- * const x = useMotionValue(0)
861
- * const y = useMotionValue(0)
862
- * const opacity = useMotionValue(1)
863
- *
864
- * useEffect(() => {
865
- * function updateOpacity() {
866
- * const maxXY = Math.max(x.get(), y.get())
867
- * const newOpacity = transform(maxXY, [0, 100], [1, 0])
868
- * opacity.set(newOpacity)
869
- * }
870
- *
871
- * const unsubscribeX = x.on("change", updateOpacity)
872
- * const unsubscribeY = y.on("change", updateOpacity)
873
- *
874
- * return () => {
875
- * unsubscribeX()
876
- * unsubscribeY()
877
- * }
878
- * }, [])
879
- *
880
- * return <motion.div style={{ x }} />
881
- * }
882
- * ```
883
- *
884
- * @param subscriber - A function that receives the latest value.
885
- * @returns A function that, when called, will cancel this subscription.
886
- *
887
- * @deprecated
888
- */
889
- onChange(subscription: Subscriber<V>): () => void;
890
- /**
891
- * An object containing a SubscriptionManager for each active event.
892
- */
893
- private events;
894
- on<EventName extends keyof MotionValueEventCallbacks<V>>(eventName: EventName, callback: MotionValueEventCallbacks<V>[EventName]): VoidFunction;
895
- clearListeners(): void;
896
- /**
897
- * Attaches a passive effect to the `MotionValue`.
898
- */
899
- attach(passiveEffect: PassiveEffect<V>, stopPassiveEffect: VoidFunction): void;
900
- /**
901
- * Sets the state of the `MotionValue`.
902
- *
903
- * @remarks
904
- *
905
- * ```jsx
906
- * const x = useMotionValue(0)
907
- * x.set(10)
908
- * ```
909
- *
910
- * @param latest - Latest value to set.
911
- * @param render - Whether to notify render subscribers. Defaults to `true`
912
- *
913
- * @public
914
- */
915
- set(v: V): void;
916
- setWithVelocity(prev: V, current: V, delta: number): void;
917
- /**
918
- * Set the state of the `MotionValue`, stopping any active animations,
919
- * effects, and resets velocity to `0`.
920
- */
921
- jump(v: V, endAnimation?: boolean): void;
922
- dirty(): void;
923
- addDependent(dependent: MotionValue): void;
924
- removeDependent(dependent: MotionValue): void;
925
- updateAndNotify: (v: V) => void;
926
- /**
927
- * Returns the latest state of `MotionValue`
928
- *
929
- * @returns - The latest state of `MotionValue`
930
- *
931
- * @public
932
- */
933
- get(): NonNullable<V>;
934
- /**
935
- * @public
936
- */
937
- getPrevious(): V | undefined;
938
- /**
939
- * Returns the latest velocity of `MotionValue`
940
- *
941
- * @returns - The latest velocity of `MotionValue`. Returns `0` if the state is non-numerical.
942
- *
943
- * @public
944
- */
945
- getVelocity(): number;
946
- hasAnimated: boolean;
947
- /**
948
- * Registers a new animation to control this `MotionValue`. Only one
949
- * animation can drive a `MotionValue` at one time.
950
- *
951
- * ```jsx
952
- * value.start()
953
- * ```
954
- *
955
- * @param animation - A function that starts the provided animation
956
- */
957
- start(startAnimation: StartAnimation): Promise<void>;
958
- /**
959
- * Stop the currently active animation.
960
- *
961
- * @public
962
- */
963
- stop(): void;
964
- /**
965
- * Returns `true` if this value is currently animating.
966
- *
967
- * @public
968
- */
969
- isAnimating(): boolean;
970
- private clearAnimation;
971
- /**
972
- * Destroy and clean up subscribers to this `MotionValue`.
973
- *
974
- * The `MotionValue` hooks like `useMotionValue` and `useTransform` automatically
975
- * handle the lifecycle of the returned `MotionValue`, so this method is only necessary if you've manually
976
- * created a `MotionValue` via the `motionValue` function.
977
- *
978
- * @public
979
- */
980
- destroy(): void;
981
- }
982
- declare function motionValue<V>(init: V, options?: MotionValueOptions): MotionValue<V>;
983
-
984
- type UnresolvedKeyframes<T extends AnyResolvedKeyframe> = Array<T | null>;
985
- type ResolvedKeyframes<T extends AnyResolvedKeyframe> = Array<T>;
986
- declare function flushKeyframeResolvers(): void;
987
- type OnKeyframesResolved<T extends AnyResolvedKeyframe> = (resolvedKeyframes: ResolvedKeyframes<T>, finalKeyframe: T, forced: boolean) => void;
988
- declare class KeyframeResolver<T extends AnyResolvedKeyframe = any> {
989
- name?: string;
990
- element?: WithRender;
991
- finalKeyframe?: T;
992
- suspendedScrollY?: number;
993
- protected unresolvedKeyframes: UnresolvedKeyframes<AnyResolvedKeyframe>;
994
- private motionValue?;
995
- private onComplete;
996
- state: "pending" | "scheduled" | "complete";
997
- /**
998
- * Track whether this resolver is async. If it is, it'll be added to the
999
- * resolver queue and flushed in the next frame. Resolvers that aren't going
1000
- * to trigger read/write thrashing don't need to be async.
1001
- */
1002
- private isAsync;
1003
- /**
1004
- * Track whether this resolver needs to perform a measurement
1005
- * to resolve its keyframes.
1006
- */
1007
- needsMeasurement: boolean;
1008
- constructor(unresolvedKeyframes: UnresolvedKeyframes<AnyResolvedKeyframe>, onComplete: OnKeyframesResolved<T>, name?: string, motionValue?: MotionValue<T>, element?: WithRender, isAsync?: boolean);
1009
- scheduleResolve(): void;
1010
- readKeyframes(): void;
1011
- setFinalKeyframe(): void;
1012
- measureInitialState(): void;
1013
- renderEndStyles(): void;
1014
- measureEndState(): void;
1015
- complete(isForcedComplete?: boolean): void;
1016
- cancel(): void;
1017
- resume(): void;
1018
- }
1019
-
1020
- declare class WithPromise {
1021
- protected _finished: Promise<void>;
1022
- resolve: VoidFunction;
1023
- constructor();
1024
- get finished(): Promise<void>;
1025
- protected updateFinished(): void;
1026
- protected notifyFinished(): void;
1027
- /**
1028
- * Allows the animation to be awaited.
1029
- *
1030
- * @deprecated Use `finished` instead.
1031
- */
1032
- then(onResolve: VoidFunction, onReject?: VoidFunction): Promise<void>;
1033
- }
1034
-
1035
- type OptionsWithoutKeyframes<T extends AnyResolvedKeyframe> = Omit<ValueAnimationOptions<T>, "keyframes">;
1036
- declare class AsyncMotionValueAnimation<T extends AnyResolvedKeyframe> extends WithPromise implements AnimationPlaybackControls {
1037
- private createdAt;
1038
- private resolvedAt;
1039
- private _animation;
1040
- private pendingTimeline;
1041
- private keyframeResolver;
1042
- private stopTimeline;
1043
- constructor({ autoplay, delay, type, repeat, repeatDelay, repeatType, keyframes, name, motionValue, element, ...options }: ValueAnimationOptions<T>);
1044
- onKeyframesResolved(keyframes: ResolvedKeyframes<T>, finalKeyframe: T, options: OptionsWithoutKeyframes<T>, sync: boolean): void;
1045
- get finished(): Promise<any>;
1046
- then(onResolve: VoidFunction, _onReject?: VoidFunction): Promise<void>;
1047
- get animation(): AnimationPlaybackControls;
1048
- get duration(): number;
1049
- get iterationDuration(): number;
1050
- get time(): number;
1051
- set time(newTime: number);
1052
- get speed(): number;
1053
- get state(): AnimationPlayState;
1054
- set speed(newSpeed: number);
1055
- get startTime(): number | null;
1056
- attachTimeline(timeline: TimelineWithFallback): () => void;
1057
- play(): void;
1058
- pause(): void;
1059
- complete(): void;
1060
- cancel(): void;
1061
- /**
1062
- * Bound to support return animation.stop pattern
1063
- */
1064
- stop: () => void;
1065
- }
1066
-
1067
- type AcceptedAnimations = AnimationPlaybackControls;
1068
- type GroupedAnimations = AcceptedAnimations[];
1069
- declare class GroupAnimation implements AnimationPlaybackControls {
1070
- animations: GroupedAnimations;
1071
- constructor(animations: Array<AcceptedAnimations | undefined>);
1072
- get finished(): Promise<any[]>;
1073
- /**
1074
- * TODO: Filter out cancelled or stopped animations before returning
1075
- */
1076
- private getAll;
1077
- private setAll;
1078
- attachTimeline(timeline: TimelineWithFallback): () => void;
1079
- get time(): number;
1080
- set time(time: number);
1081
- get speed(): number;
1082
- set speed(speed: number);
1083
- get state(): any;
1084
- get startTime(): any;
1085
- get duration(): number;
1086
- get iterationDuration(): number;
1087
- private runAll;
1088
- play(): void;
1089
- pause(): void;
1090
- stop: () => void;
1091
- cancel(): void;
1092
- complete(): void;
1093
- }
1094
-
1095
- declare class GroupAnimationWithThen extends GroupAnimation implements AnimationPlaybackControlsWithThen {
1096
- then(onResolve: VoidFunction, _onReject?: VoidFunction): Promise<void>;
1097
- }
1098
-
1099
- declare class JSAnimation<T extends number | string> extends WithPromise implements AnimationPlaybackControlsWithThen {
1100
- state: AnimationPlayState;
1101
- startTime: number | null;
1102
- /**
1103
- * The driver that's controlling the animation loop. Normally this is a requestAnimationFrame loop
1104
- * but in tests we can pass in a synchronous loop.
1105
- */
1106
- private driver?;
1107
- private isStopped;
1108
- private generator;
1109
- private calculatedDuration;
1110
- private resolvedDuration;
1111
- private totalDuration;
1112
- private options;
1113
- /**
1114
- * The current time of the animation.
1115
- */
1116
- private currentTime;
1117
- /**
1118
- * The time at which the animation was paused.
1119
- */
1120
- private holdTime;
1121
- /**
1122
- * Playback speed as a factor. 0 would be stopped, -1 reverse and 2 double speed.
1123
- */
1124
- private playbackSpeed;
1125
- private mixKeyframes;
1126
- private mirroredGenerator;
1127
- constructor(options: ValueAnimationOptions<T>);
1128
- initAnimation(): void;
1129
- updateTime(timestamp: number): void;
1130
- tick(timestamp: number, sample?: boolean): AnimationState<T>;
1131
- /**
1132
- * Allows the returned animation to be awaited or promise-chained. Currently
1133
- * resolves when the animation finishes at all but in a future update could/should
1134
- * reject if its cancels.
1135
- */
1136
- then(resolve: VoidFunction, reject?: VoidFunction): Promise<void>;
1137
- get duration(): number;
1138
- get iterationDuration(): number;
1139
- get time(): number;
1140
- set time(newTime: number);
1141
- get speed(): number;
1142
- set speed(newSpeed: number);
1143
- play(): void;
1144
- pause(): void;
1145
- /**
1146
- * This method is bound to the instance to fix a pattern where
1147
- * animation.stop is returned as a reference from a useEffect.
1148
- */
1149
- stop: () => void;
1150
- complete(): void;
1151
- finish(): void;
1152
- cancel(): void;
1153
- private teardown;
1154
- private stopDriver;
1155
- sample(sampleTime: number): AnimationState<T>;
1156
- attachTimeline(timeline: TimelineWithFallback): VoidFunction;
1157
- }
1158
- declare function animateValue<T extends number | string>(options: ValueAnimationOptions<T>): JSAnimation<T>;
1159
-
1160
- interface NativeAnimationOptions<V extends AnyResolvedKeyframe = number> extends DOMValueAnimationOptions<V> {
1161
- pseudoElement?: string;
1162
- startTime?: number;
1163
- }
1164
- /**
1165
- * NativeAnimation implements AnimationPlaybackControls for the browser's Web Animations API.
1166
- */
1167
- declare class NativeAnimation<T extends AnyResolvedKeyframe> extends WithPromise implements AnimationPlaybackControlsWithThen {
1168
- /**
1169
- * The interfaced Web Animation API animation
1170
- */
1171
- protected animation: Animation;
1172
- protected finishedTime: number | null;
1173
- protected options: NativeAnimationOptions;
1174
- private allowFlatten;
1175
- private isStopped;
1176
- private isPseudoElement;
1177
- constructor(options?: NativeAnimationOptions);
1178
- updateMotionValue?(value?: T): void;
1179
- play(): void;
1180
- pause(): void;
1181
- complete(): void;
1182
- cancel(): void;
1183
- stop(): void;
1184
- /**
1185
- * WAAPI doesn't natively have any interruption capabilities.
1186
- *
1187
- * In this method, we commit styles back to the DOM before cancelling
1188
- * the animation.
1189
- *
1190
- * This is designed to be overridden by NativeAnimationExtended, which
1191
- * will create a renderless JS animation and sample it twice to calculate
1192
- * its current value, "previous" value, and therefore allow
1193
- * Motion to also correctly calculate velocity for any subsequent animation
1194
- * while deferring the commit until the next animation frame.
1195
- */
1196
- protected commitStyles(): void;
1197
- get duration(): number;
1198
- get iterationDuration(): number;
1199
- get time(): number;
1200
- set time(newTime: number);
1201
- /**
1202
- * The playback speed of the animation.
1203
- * 1 = normal speed, 2 = double speed, 0.5 = half speed.
1204
- */
1205
- get speed(): number;
1206
- set speed(newSpeed: number);
1207
- get state(): AnimationPlayState;
1208
- get startTime(): number;
1209
- set startTime(newStartTime: number);
1210
- /**
1211
- * Attaches a timeline to the animation, for instance the `ScrollTimeline`.
1212
- */
1213
- attachTimeline({ timeline, observe }: TimelineWithFallback): VoidFunction;
1214
- }
1215
-
1216
- type NativeAnimationOptionsExtended<T extends AnyResolvedKeyframe> = NativeAnimationOptions & ValueAnimationOptions<T> & NativeAnimationOptions;
1217
- declare class NativeAnimationExtended<T extends AnyResolvedKeyframe> extends NativeAnimation<T> {
1218
- options: NativeAnimationOptionsExtended<T>;
1219
- constructor(options: NativeAnimationOptionsExtended<T>);
1220
- /**
1221
- * WAAPI doesn't natively have any interruption capabilities.
1222
- *
1223
- * Rather than read commited styles back out of the DOM, we can
1224
- * create a renderless JS animation and sample it twice to calculate
1225
- * its current value, "previous" value, and therefore allow
1226
- * Motion to calculate velocity for any subsequent animation.
1227
- */
1228
- updateMotionValue(value?: T): void;
1229
- }
1230
-
1231
- declare class NativeAnimationWrapper<T extends AnyResolvedKeyframe> extends NativeAnimation<T> {
1232
- constructor(animation: Animation);
1233
- }
1234
-
1235
- declare const animationMapKey: (name: string, pseudoElement?: string) => string;
1236
- declare function getAnimationMap(element: Element): Map<any, any>;
1237
-
1238
- type CSSVariableName = `--${string}`;
1239
- type CSSVariableToken = `var(${CSSVariableName})`;
1240
- declare const isCSSVariableName: (key?: AnyResolvedKeyframe | null) => key is `--${string}`;
1241
- declare const isCSSVariableToken: (value?: string) => value is `var(--${string})`;
1242
-
1243
- declare function parseCSSVariable(current: string): string[] | undefined[];
1244
- declare function getVariableValue(current: CSSVariableToken, element: Element, depth?: number): AnyResolvedKeyframe | undefined;
1245
-
1246
- declare function getValueTransition(transition: any, key: string): any;
1247
-
1248
- declare function makeAnimationInstant(options: Partial<{
1249
- duration: ValueAnimationOptions["duration"];
1250
- type: ValueAnimationOptions["type"];
1251
- }>): void;
1252
-
1253
- declare function inertia({ keyframes, velocity, power, timeConstant, bounceDamping, bounceStiffness, modifyTarget, min, max, restDelta, restSpeed, }: ValueAnimationOptions<number>): KeyframeGenerator<number>;
1254
-
1255
- declare function defaultEasing(values: any[], easing?: EasingFunction): EasingFunction[];
1256
- declare function keyframes<T extends AnyResolvedKeyframe>({ duration, keyframes: keyframeValues, times, ease, }: ValueAnimationOptions<T>): KeyframeGenerator<T>;
1257
-
1258
- declare function spring(optionsOrVisualDuration?: ValueAnimationOptions<number> | number, bounce?: number): KeyframeGenerator<number>;
1259
- declare namespace spring {
1260
- var applyToOptions: (options: Transition) => Transition;
1261
- }
1262
-
1263
- /**
1264
- * Implement a practical max duration for keyframe generation
1265
- * to prevent infinite loops
1266
- */
1267
- declare const maxGeneratorDuration = 20000;
1268
- declare function calcGeneratorDuration(generator: KeyframeGenerator<unknown>): number;
1269
-
1270
- /**
1271
- * Create a progress => progress easing function from a generator.
1272
- */
1273
- declare function createGeneratorEasing(options: Transition, scale: number | undefined, createGenerator: GeneratorFactory): {
1274
- type: string;
1275
- ease: (progress: number) => number;
1276
- duration: number;
1277
- };
1278
-
1279
- declare function isGenerator(type?: AnimationGeneratorType): type is GeneratorFactory;
1280
-
1281
- declare class DOMKeyframesResolver<T extends AnyResolvedKeyframe> extends KeyframeResolver<T> {
1282
- name: string;
1283
- element?: WithRender;
1284
- private removedTransforms?;
1285
- private measuredOrigin?;
1286
- constructor(unresolvedKeyframes: UnresolvedKeyframes<AnyResolvedKeyframe>, onComplete: OnKeyframesResolved<T>, name?: string, motionValue?: MotionValue<T>, element?: WithRender);
1287
- readKeyframes(): void;
1288
- resolveNoneKeyframes(): void;
1289
- measureInitialState(): void;
1290
- measureEndState(): void;
1291
- }
1292
-
1293
- declare function defaultOffset(arr: any[]): number[];
1294
-
1295
- declare function fillOffset(offset: number[], remaining: number): void;
1296
-
1297
- declare function convertOffsetToTimes(offset: number[], duration: number): number[];
1298
-
1299
- declare function applyPxDefaults(keyframes: ValueKeyframe[] | UnresolvedValueKeyframe[], name: string): void;
1300
-
1301
- declare function fillWildcards(keyframes: ValueKeyframe[] | UnresolvedValueKeyframe[]): void;
1302
-
1303
- declare const cubicBezierAsString: ([a, b, c, d]: BezierDefinition) => string;
1304
-
1305
- declare function isWaapiSupportedEasing(easing?: Easing | Easing[]): boolean;
1306
-
1307
- declare function mapEasingToNativeEasing(easing: Easing | Easing[] | undefined, duration: number): undefined | string | string[];
1308
-
1309
- declare const supportedWaapiEasing: {
1310
- linear: string;
1311
- ease: string;
1312
- easeIn: string;
1313
- easeOut: string;
1314
- easeInOut: string;
1315
- circIn: string;
1316
- circOut: string;
1317
- backIn: string;
1318
- backOut: string;
1319
- };
1320
-
1321
- declare function startWaapiAnimation(element: Element, valueName: string, keyframes: ValueKeyframesDefinition, { delay, duration, repeat, repeatType, ease, times, }?: ValueTransition, pseudoElement?: string | undefined): Animation;
1322
-
1323
- declare const supportsPartialKeyframes: () => boolean;
1324
-
1325
- declare function supportsBrowserAnimation<T extends AnyResolvedKeyframe>(options: ValueAnimationOptionsWithRenderContext<T>): any;
1326
-
1327
- /**
1328
- * A list of values that can be hardware-accelerated.
1329
- */
1330
- declare const acceleratedValues: Set<string>;
1331
-
1332
- declare function applyGeneratorOptions({ type, ...options }: ValueTransition): ValueTransition;
1333
-
1334
- declare const generateLinearEasing: (easing: EasingFunction, duration: number, resolution?: number) => string;
1335
-
1336
- declare class MotionValueState {
1337
- latest: {
1338
- [name: string]: AnyResolvedKeyframe;
1339
- };
1340
- private values;
1341
- set(name: string, value: MotionValue, render?: VoidFunction, computed?: MotionValue, useDefaultValueType?: boolean): () => void;
1342
- get(name: string): MotionValue | undefined;
1343
- destroy(): void;
1344
- }
1345
-
1346
- declare const addAttrValue: (element: HTMLElement | SVGElement, state: MotionValueState, key: string, value: MotionValue) => () => void;
1347
- declare const attrEffect: (subject: ElementOrSelector, values: Record<string, MotionValue<any>>) => () => void;
1348
-
1349
- declare const propEffect: (subject: {
1350
- [key: string]: any;
1351
- }, values: Record<string, MotionValue<any>>) => VoidFunction;
1352
-
1353
- declare const addStyleValue: (element: HTMLElement | SVGElement, state: MotionValueState, key: string, value: MotionValue) => () => void;
1354
- declare const styleEffect: (subject: ElementOrSelector, values: Record<string, MotionValue<any>>) => () => void;
1355
-
1356
- declare const svgEffect: (subject: ElementOrSelector, values: Record<string, MotionValue<any>>) => () => void;
1357
-
1358
- declare const frame: Batcher;
1359
- declare const cancelFrame: (process: Process) => void;
1360
- declare const frameData: FrameData;
1361
- declare const frameSteps: Steps;
1362
-
1363
- type Process = (data: FrameData) => void;
1364
- type Schedule = (process: Process, keepAlive?: boolean, immediate?: boolean) => Process;
1365
- interface Step {
1366
- schedule: Schedule;
1367
- cancel: (process: Process) => void;
1368
- process: (data: FrameData) => void;
1369
- }
1370
- type StepId = "setup" | "read" | "resolveKeyframes" | "preUpdate" | "update" | "preRender" | "render" | "postRender";
1371
- type CancelProcess = (process: Process) => void;
1372
- type Batcher = {
1373
- [key in StepId]: Schedule;
1374
- };
1375
- type Steps = {
1376
- [key in StepId]: Step;
1377
- };
1378
- interface FrameData {
1379
- delta: number;
1380
- timestamp: number;
1381
- isProcessing: boolean;
1382
- }
1383
-
1384
- declare function createRenderBatcher(scheduleNextBatch: (callback: Function) => void, allowKeepAlive: boolean): {
1385
- schedule: Batcher;
1386
- cancel: (process: Process) => void;
1387
- state: FrameData;
1388
- steps: Steps;
1389
- };
1390
-
1391
- declare const microtask: Batcher;
1392
- declare const cancelMicrotask: (process: Process) => void;
1393
-
1394
- /**
1395
- * An eventloop-synchronous alternative to performance.now().
1396
- *
1397
- * Ensures that time measurements remain consistent within a synchronous context.
1398
- * Usually calling performance.now() twice within the same synchronous context
1399
- * will return different values which isn't useful for animations when we're usually
1400
- * trying to sync animations to the same frame.
1401
- */
1402
- declare const time: {
1403
- now: () => number;
1404
- set: (newTime: number) => void;
1405
- };
1406
-
1407
- declare const isDragging: {
1408
- x: boolean;
1409
- y: boolean;
1410
- };
1411
- declare function isDragActive(): boolean;
1412
-
1413
- declare function setDragLock(axis: boolean | "x" | "y" | "lockDirection"): (() => void) | null;
1414
-
1415
- /**
1416
- * Passed in to pan event handlers like `onPan` the `PanInfo` object contains
1417
- * information about the current state of the tap gesture such as its
1418
- * `point`, `delta`, `offset` and `velocity`.
1419
- *
1420
- * ```jsx
1421
- * <motion.div onPan={(event, info) => {
1422
- * console.log(info.point.x, info.point.y)
1423
- * }} />
1424
- * ```
1425
- *
1426
- * @public
1427
- */
1428
- interface PanInfo {
1429
- /**
1430
- * Contains `x` and `y` values for the current pan position relative
1431
- * to the device or page.
1432
- *
1433
- * ```jsx
1434
- * function onPan(event, info) {
1435
- * console.log(info.point.x, info.point.y)
1436
- * }
1437
- *
1438
- * <motion.div onPan={onPan} />
1439
- * ```
1440
- *
1441
- * @public
1442
- */
1443
- point: Point;
1444
- /**
1445
- * Contains `x` and `y` values for the distance moved since
1446
- * the last event.
1447
- *
1448
- * ```jsx
1449
- * function onPan(event, info) {
1450
- * console.log(info.delta.x, info.delta.y)
1451
- * }
1452
- *
1453
- * <motion.div onPan={onPan} />
1454
- * ```
1455
- *
1456
- * @public
1457
- */
1458
- delta: Point;
1459
- /**
1460
- * Contains `x` and `y` values for the distance moved from
1461
- * the first pan event.
1462
- *
1463
- * ```jsx
1464
- * function onPan(event, info) {
1465
- * console.log(info.offset.x, info.offset.y)
1466
- * }
1467
- *
1468
- * <motion.div onPan={onPan} />
1469
- * ```
1470
- *
1471
- * @public
1472
- */
1473
- offset: Point;
1474
- /**
1475
- * Contains `x` and `y` values for the current velocity of the pointer, in px/ms.
1476
- *
1477
- * ```jsx
1478
- * function onPan(event, info) {
1479
- * console.log(info.velocity.x, info.velocity.y)
1480
- * }
1481
- *
1482
- * <motion.div onPan={onPan} />
1483
- * ```
1484
- *
1485
- * @public
1486
- */
1487
- velocity: Point;
1488
- }
1489
- type PanHandler = (event: Event, info: PanInfo) => void;
1490
-
1491
- type DragHandler = (event: MouseEvent | TouchEvent | PointerEvent, info: PanInfo) => void;
1492
- type DragElastic = boolean | number | Partial<BoundingBox>;
1493
- interface ResolvedConstraints {
1494
- x: Partial<Axis>;
1495
- y: Partial<Axis>;
1496
- }
1497
- interface ResolvedElastic {
1498
- x: Axis;
1499
- y: Axis;
1500
- }
1501
-
1502
- type ElementOrSelector = Element | Element[] | NodeListOf<Element> | string;
1503
- interface WithQuerySelectorAll {
1504
- querySelectorAll: Element["querySelectorAll"];
1505
- }
1506
- interface AnimationScope<T = any> {
1507
- readonly current: T;
1508
- animations: any[];
1509
- }
1510
- interface SelectorCache {
1511
- [key: string]: NodeListOf<Element>;
1512
- }
1513
- declare function resolveElements(elementOrSelector: ElementOrSelector, scope?: AnimationScope, selectorCache?: SelectorCache): Element[];
1514
-
1515
- /**
1516
- * Options for event listeners.
1517
- *
1518
- * @public
1519
- */
1520
- interface EventOptions {
1521
- /**
1522
- * Use passive event listeners. Doing so allows the browser to optimize
1523
- * scrolling performance by not allowing the use of `preventDefault()`.
1524
- *
1525
- * @default true
1526
- */
1527
- passive?: boolean;
1528
- /**
1529
- * Remove the event listener after the first event.
1530
- *
1531
- * @default false
1532
- */
1533
- once?: boolean;
1534
- }
1535
-
1536
- /**
1537
- * A function to be called when a hover gesture starts.
1538
- *
1539
- * This function can optionally return a function that will be called
1540
- * when the hover gesture ends.
1541
- *
1542
- * @public
1543
- */
1544
- type OnHoverStartEvent = (element: Element, event: PointerEvent) => void | OnHoverEndEvent;
1545
- /**
1546
- * A function to be called when a hover gesture ends.
1547
- *
1548
- * @public
1549
- */
1550
- type OnHoverEndEvent = (event: PointerEvent) => void;
1551
- /**
1552
- * Create a hover gesture. hover() is different to .addEventListener("pointerenter")
1553
- * in that it has an easier syntax, filters out polyfilled touch events, interoperates
1554
- * with drag gestures, and automatically removes the "pointerennd" event listener when the hover ends.
1555
- *
1556
- * @public
1557
- */
1558
- declare function hover(elementOrSelector: ElementOrSelector, onHoverStart: OnHoverStartEvent, options?: EventOptions): VoidFunction;
1559
-
1560
- interface PressGestureInfo {
1561
- success: boolean;
1562
- }
1563
- type OnPressEndEvent = (event: PointerEvent, info: PressGestureInfo) => void;
1564
- type OnPressStartEvent = (element: Element, event: PointerEvent) => OnPressEndEvent | void;
1565
-
1566
- interface PointerEventOptions extends EventOptions {
1567
- useGlobalTarget?: boolean;
1568
- }
1569
- /**
1570
- * Create a press gesture.
1571
- *
1572
- * Press is different to `"pointerdown"`, `"pointerup"` in that it
1573
- * automatically filters out secondary pointer events like right
1574
- * click and multitouch.
1575
- *
1576
- * It also adds accessibility support for keyboards, where
1577
- * an element with a press gesture will receive focus and
1578
- * trigger on Enter `"keydown"` and `"keyup"` events.
1579
- *
1580
- * This is different to a browser's `"click"` event, which does
1581
- * respond to keyboards but only for the `"click"` itself, rather
1582
- * than the press start and end/cancel. The element also needs
1583
- * to be focusable for this to work, whereas a press gesture will
1584
- * make an element focusable by default.
1585
- *
1586
- * @public
1587
- */
1588
- declare function press(targetOrSelector: ElementOrSelector, onPressStart: OnPressStartEvent, options?: PointerEventOptions): VoidFunction;
1589
-
1590
- /**
1591
- * Recursively traverse up the tree to check whether the provided child node
1592
- * is the parent or a descendant of it.
1593
- *
1594
- * @param parent - Element to find
1595
- * @param child - Element to test against parent
1596
- */
1597
- declare const isNodeOrChild: (parent: Element | null, child?: Element | null) => boolean;
1598
-
1599
- declare const isPrimaryPointer: (event: PointerEvent) => boolean;
1600
-
1601
- interface EventInfo {
1602
- point: Point;
1603
- }
1604
- /**
1605
- * A generic set of string/number values
1606
- */
1607
- interface ResolvedValues {
1608
- [key: string]: AnyResolvedKeyframe;
1609
- }
1610
- type AnimationDefinition = VariantLabels | TargetAndTransition | TargetResolver;
1611
- /**
1612
- * An object that specifies values to animate to. Each value may be set either as
1613
- * a single value, or an array of values.
1614
- *
1615
- * It may also option contain these properties:
1616
- *
1617
- * - `transition`: Specifies transitions for all or individual values.
1618
- * - `transitionEnd`: Specifies values to set when the animation finishes.
1619
- *
1620
- * ```jsx
1621
- * const target = {
1622
- * x: "0%",
1623
- * opacity: 0,
1624
- * transition: { duration: 1 },
1625
- * transitionEnd: { display: "none" }
1626
- * }
1627
- * ```
1628
- *
1629
- * @public
1630
- */
1631
- type TargetAndTransition = Target & {
1632
- transition?: Transition;
1633
- transitionEnd?: ResolvedValues;
1634
- };
1635
- type TargetResolver = (custom: any, current: ResolvedValues, velocity: ResolvedValues) => TargetAndTransition | string;
1636
- /**
1637
- * Either a string, or array of strings, that reference variants defined via the `variants` prop.
1638
- * @public
1639
- */
1640
- type VariantLabels = string | string[];
1641
- type Variant = TargetAndTransition | TargetResolver;
1642
- interface Variants {
1643
- [key: string]: Variant;
1644
- }
1645
- /**
1646
- * @deprecated
1647
- */
1648
- type LegacyAnimationControls = {
1649
- /**
1650
- * Subscribes a component's animation controls to this.
1651
- *
1652
- * @param controls - The controls to subscribe
1653
- * @returns An unsubscribe function.
1654
- */
1655
- subscribe(visualElement: any): () => void;
1656
- /**
1657
- * Starts an animation on all linked components.
1658
- *
1659
- * @remarks
1660
- *
1661
- * ```jsx
1662
- * controls.start("variantLabel")
1663
- * controls.start({
1664
- * x: 0,
1665
- * transition: { duration: 1 }
1666
- * })
1667
- * ```
1668
- *
1669
- * @param definition - Properties or variant label to animate to
1670
- * @param transition - Optional `transition` to apply to a variant
1671
- * @returns - A `Promise` that resolves when all animations have completed.
1672
- *
1673
- * @public
1674
- */
1675
- start(definition: AnimationDefinition, transitionOverride?: Transition): Promise<any>;
1676
- /**
1677
- * Instantly set to a set of properties or a variant.
1678
- *
1679
- * ```jsx
1680
- * // With properties
1681
- * controls.set({ opacity: 0 })
1682
- *
1683
- * // With variants
1684
- * controls.set("hidden")
1685
- * ```
1686
- *
1687
- * @privateRemarks
1688
- * We could perform a similar trick to `.start` where this can be called before mount
1689
- * and we maintain a list of of pending actions that get applied on mount. But the
1690
- * expectation of `set` is that it happens synchronously and this would be difficult
1691
- * to do before any children have even attached themselves. It's also poor practise
1692
- * and we should discourage render-synchronous `.start` calls rather than lean into this.
1693
- *
1694
- * @public
1695
- */
1696
- set(definition: AnimationDefinition): void;
1697
- /**
1698
- * Stops animations on all linked components.
1699
- *
1700
- * ```jsx
1701
- * controls.stop()
1702
- * ```
1703
- *
1704
- * @public
1705
- */
1706
- stop(): void;
1707
- mount(): () => void;
1708
- };
1709
- interface MotionNodeAnimationOptions {
1710
- /**
1711
- * Properties, variant label or array of variant labels to start in.
1712
- *
1713
- * Set to `false` to initialise with the values in `animate` (disabling the mount animation)
1714
- *
1715
- * ```jsx
1716
- * // As values
1717
- * <motion.div initial={{ opacity: 1 }} />
1718
- *
1719
- * // As variant
1720
- * <motion.div initial="visible" variants={variants} />
1721
- *
1722
- * // Multiple variants
1723
- * <motion.div initial={["visible", "active"]} variants={variants} />
1724
- *
1725
- * // As false (disable mount animation)
1726
- * <motion.div initial={false} animate={{ opacity: 0 }} />
1727
- * ```
1728
- */
1729
- initial?: TargetAndTransition | VariantLabels | boolean;
1730
- /**
1731
- * Values to animate to, variant label(s), or `LegacyAnimationControls`.
1732
- *
1733
- * ```jsx
1734
- * // As values
1735
- * <motion.div animate={{ opacity: 1 }} />
1736
- *
1737
- * // As variant
1738
- * <motion.div animate="visible" variants={variants} />
1739
- *
1740
- * // Multiple variants
1741
- * <motion.div animate={["visible", "active"]} variants={variants} />
1742
- *
1743
- * // LegacyAnimationControls
1744
- * <motion.div animate={animation} />
1745
- * ```
1746
- */
1747
- animate?: TargetAndTransition | VariantLabels | boolean | LegacyAnimationControls;
1748
- /**
1749
- * A target to animate to when this component is removed from the tree.
1750
- *
1751
- * This component **must** be the first animatable child of an `AnimatePresence` to enable this exit animation.
1752
- *
1753
- * This limitation exists because React doesn't allow components to defer unmounting until after
1754
- * an animation is complete. Once this limitation is fixed, the `AnimatePresence` component will be unnecessary.
1755
- *
1756
- * ```jsx
1757
- * import { AnimatePresence, motion } from 'framer-motion'
1758
- *
1759
- * export const MyComponent = ({ isVisible }) => {
1760
- * return (
1761
- * <AnimatePresence>
1762
- * {isVisible && (
1763
- * <motion.div
1764
- * initial={{ opacity: 0 }}
1765
- * animate={{ opacity: 1 }}
1766
- * exit={{ opacity: 0 }}
1767
- * />
1768
- * )}
1769
- * </AnimatePresence>
1770
- * )
1771
- * }
1772
- * ```
1773
- */
1774
- exit?: TargetAndTransition | VariantLabels;
1775
- /**
1776
- * Variants allow you to define animation states and organise them by name. They allow
1777
- * you to control animations throughout a component tree by switching a single `animate` prop.
1778
- *
1779
- * Using `transition` options like `delayChildren` and `when`, you can orchestrate
1780
- * when children animations play relative to their parent.
1781
-
1782
- *
1783
- * After passing variants to one or more `motion` component's `variants` prop, these variants
1784
- * can be used in place of values on the `animate`, `initial`, `whileFocus`, `whileTap` and `whileHover` props.
1785
- *
1786
- * ```jsx
1787
- * const variants = {
1788
- * active: {
1789
- * backgroundColor: "#f00"
1790
- * },
1791
- * inactive: {
1792
- * backgroundColor: "#fff",
1793
- * transition: { duration: 2 }
1794
- * }
1795
- * }
1796
- *
1797
- * <motion.div variants={variants} animate="active" />
1798
- * ```
1799
- */
1800
- variants?: Variants;
1801
- /**
1802
- * Default transition. If no `transition` is defined in `animate`, it will use the transition defined here.
1803
- * ```jsx
1804
- * const spring = {
1805
- * type: "spring",
1806
- * damping: 10,
1807
- * stiffness: 100
1808
- * }
1809
- *
1810
- * <motion.div transition={spring} animate={{ scale: 1.2 }} />
1811
- * ```
1812
- */
1813
- transition?: Transition;
1814
- }
1815
- interface MotionNodeEventOptions {
1816
- /**
1817
- * Callback with latest motion values, fired max once per frame.
1818
- *
1819
- * ```jsx
1820
- * function onUpdate(latest) {
1821
- * console.log(latest.x, latest.opacity)
1822
- * }
1823
- *
1824
- * <motion.div animate={{ x: 100, opacity: 0 }} onUpdate={onUpdate} />
1825
- * ```
1826
- */
1827
- onUpdate?(latest: ResolvedValues): void;
1828
- /**
1829
- * Callback when animation defined in `animate` begins.
1830
- *
1831
- * The provided callback will be called with the triggering animation definition.
1832
- * If this is a variant, it'll be the variant name, and if a target object
1833
- * then it'll be the target object.
1834
- *
1835
- * This way, it's possible to figure out which animation has started.
1836
- *
1837
- * ```jsx
1838
- * function onStart() {
1839
- * console.log("Animation started")
1840
- * }
1841
- *
1842
- * <motion.div animate={{ x: 100 }} onAnimationStart={onStart} />
1843
- * ```
1844
- */
1845
- onAnimationStart?(definition: AnimationDefinition): void;
1846
- /**
1847
- * Callback when animation defined in `animate` is complete.
1848
- *
1849
- * The provided callback will be called with the triggering animation definition.
1850
- * If this is a variant, it'll be the variant name, and if a target object
1851
- * then it'll be the target object.
1852
- *
1853
- * This way, it's possible to figure out which animation has completed.
1854
- *
1855
- * ```jsx
1856
- * function onComplete() {
1857
- * console.log("Animation completed")
1858
- * }
1859
- *
1860
- * <motion.div
1861
- * animate={{ x: 100 }}
1862
- * onAnimationComplete={definition => {
1863
- * console.log('Completed animating', definition)
1864
- * }}
1865
- * />
1866
- * ```
1867
- */
1868
- onAnimationComplete?(definition: AnimationDefinition): void;
1869
- onBeforeLayoutMeasure?(box: Box): void;
1870
- onLayoutMeasure?(box: Box, prevBox: Box): void;
1871
- onLayoutAnimationStart?(): void;
1872
- onLayoutAnimationComplete?(): void;
1873
- }
1874
- interface MotionNodePanHandlers {
1875
- /**
1876
- * Callback function that fires when the pan gesture is recognised on this element.
1877
- *
1878
- * **Note:** For pan gestures to work correctly with touch input, the element needs
1879
- * touch scrolling to be disabled on either x/y or both axis with the
1880
- * [touch-action](https://developer.mozilla.org/en-US/docs/Web/CSS/touch-action) CSS rule.
1881
- *
1882
- * ```jsx
1883
- * function onPan(event, info) {
1884
- * console.log(info.point.x, info.point.y)
1885
- * }
1886
- *
1887
- * <motion.div onPan={onPan} />
1888
- * ```
1889
- *
1890
- * @param event - The originating pointer event.
1891
- * @param info - A {@link PanInfo} object containing `x` and `y` values for:
1892
- *
1893
- * - `point`: Relative to the device or page.
1894
- * - `delta`: Distance moved since the last event.
1895
- * - `offset`: Offset from the original pan event.
1896
- * - `velocity`: Current velocity of the pointer.
1897
- */
1898
- onPan?(event: PointerEvent, info: PanInfo): void;
1899
- /**
1900
- * Callback function that fires when the pan gesture begins on this element.
1901
- *
1902
- * ```jsx
1903
- * function onPanStart(event, info) {
1904
- * console.log(info.point.x, info.point.y)
1905
- * }
1906
- *
1907
- * <motion.div onPanStart={onPanStart} />
1908
- * ```
1909
- *
1910
- * @param event - The originating pointer event.
1911
- * @param info - A {@link PanInfo} object containing `x`/`y` values for:
1912
- *
1913
- * - `point`: Relative to the device or page.
1914
- * - `delta`: Distance moved since the last event.
1915
- * - `offset`: Offset from the original pan event.
1916
- * - `velocity`: Current velocity of the pointer.
1917
- */
1918
- onPanStart?(event: PointerEvent, info: PanInfo): void;
1919
- /**
1920
- * Callback function that fires when we begin detecting a pan gesture. This
1921
- * is analogous to `onMouseStart` or `onTouchStart`.
1922
- *
1923
- * ```jsx
1924
- * function onPanSessionStart(event, info) {
1925
- * console.log(info.point.x, info.point.y)
1926
- * }
1927
- *
1928
- * <motion.div onPanSessionStart={onPanSessionStart} />
1929
- * ```
1930
- *
1931
- * @param event - The originating pointer event.
1932
- * @param info - An {@link EventInfo} object containing `x`/`y` values for:
1933
- *
1934
- * - `point`: Relative to the device or page.
1935
- */
1936
- onPanSessionStart?(event: PointerEvent, info: EventInfo): void;
1937
- /**
1938
- * Callback function that fires when the pan gesture ends on this element.
1939
- *
1940
- * ```jsx
1941
- * function onPanEnd(event, info) {
1942
- * console.log(info.point.x, info.point.y)
1943
- * }
1944
- *
1945
- * <motion.div onPanEnd={onPanEnd} />
1946
- * ```
1947
- *
1948
- * @param event - The originating pointer event.
1949
- * @param info - A {@link PanInfo} object containing `x`/`y` values for:
1950
- *
1951
- * - `point`: Relative to the device or page.
1952
- * - `delta`: Distance moved since the last event.
1953
- * - `offset`: Offset from the original pan event.
1954
- * - `velocity`: Current velocity of the pointer.
1955
- */
1956
- onPanEnd?(event: PointerEvent, info: PanInfo): void;
1957
- }
1958
- interface MotionNodeHoverHandlers {
1959
- /**
1960
- * Properties or variant label to animate to while the hover gesture is recognised.
1961
- *
1962
- * ```jsx
1963
- * <motion.div whileHover={{ scale: 1.2 }} />
1964
- * ```
1965
- */
1966
- whileHover?: VariantLabels | TargetAndTransition;
1967
- /**
1968
- * Callback function that fires when pointer starts hovering over the component.
1969
- *
1970
- * ```jsx
1971
- * <motion.div onHoverStart={() => console.log('Hover starts')} />
1972
- * ```
1973
- */
1974
- onHoverStart?(event: MouseEvent, info: EventInfo): void;
1975
- /**
1976
- * Callback function that fires when pointer stops hovering over the component.
1977
- *
1978
- * ```jsx
1979
- * <motion.div onHoverEnd={() => console.log("Hover ends")} />
1980
- * ```
1981
- */
1982
- onHoverEnd?(event: MouseEvent, info: EventInfo): void;
1983
- }
1984
- /**
1985
- * Passed in to tap event handlers like `onTap` the `TapInfo` object contains
1986
- * information about the tap gesture such as it‘s location.
1987
- *
1988
- * ```jsx
1989
- * function onTap(event, info) {
1990
- * console.log(info.point.x, info.point.y)
1991
- * }
1992
- *
1993
- * <motion.div onTap={onTap} />
1994
- * ```
1995
- *
1996
- * @public
1997
- */
1998
- interface TapInfo {
1999
- /**
2000
- * Contains `x` and `y` values for the tap gesture relative to the
2001
- * device or page.
2002
- *
2003
- * ```jsx
2004
- * function onTapStart(event, info) {
2005
- * console.log(info.point.x, info.point.y)
2006
- * }
2007
- *
2008
- * <motion.div onTapStart={onTapStart} />
2009
- * ```
2010
- *
2011
- * @public
2012
- */
2013
- point: Point;
2014
- }
2015
- interface MotionNodeTapHandlers {
2016
- /**
2017
- * Callback when the tap gesture successfully ends on this element.
2018
- *
2019
- * ```jsx
2020
- * function onTap(event, info) {
2021
- * console.log(info.point.x, info.point.y)
2022
- * }
2023
- *
2024
- * <motion.div onTap={onTap} />
2025
- * ```
2026
- *
2027
- * @param event - The originating pointer event.
2028
- * @param info - An {@link TapInfo} object containing `x` and `y` values for the `point` relative to the device or page.
2029
- */
2030
- onTap?(event: MouseEvent | TouchEvent | PointerEvent, info: TapInfo): void;
2031
- /**
2032
- * Callback when the tap gesture starts on this element.
2033
- *
2034
- * ```jsx
2035
- * function onTapStart(event, info) {
2036
- * console.log(info.point.x, info.point.y)
2037
- * }
2038
- *
2039
- * <motion.div onTapStart={onTapStart} />
2040
- * ```
2041
- *
2042
- * @param event - The originating pointer event.
2043
- * @param info - An {@link TapInfo} object containing `x` and `y` values for the `point` relative to the device or page.
2044
- */
2045
- onTapStart?(event: MouseEvent | TouchEvent | PointerEvent, info: TapInfo): void;
2046
- /**
2047
- * Callback when the tap gesture ends outside this element.
2048
- *
2049
- * ```jsx
2050
- * function onTapCancel(event, info) {
2051
- * console.log(info.point.x, info.point.y)
2052
- * }
2053
- *
2054
- * <motion.div onTapCancel={onTapCancel} />
2055
- * ```
2056
- *
2057
- * @param event - The originating pointer event.
2058
- * @param info - An {@link TapInfo} object containing `x` and `y` values for the `point` relative to the device or page.
2059
- */
2060
- onTapCancel?(event: MouseEvent | TouchEvent | PointerEvent, info: TapInfo): void;
2061
- /**
2062
- * Properties or variant label to animate to while the component is pressed.
2063
- *
2064
- * ```jsx
2065
- * <motion.div whileTap={{ scale: 0.8 }} />
2066
- * ```
2067
- */
2068
- whileTap?: VariantLabels | TargetAndTransition;
2069
- /**
2070
- * If `true`, the tap gesture will attach its start listener to window.
2071
- *
2072
- * Note: This is not supported publically.
2073
- */
2074
- globalTapTarget?: boolean;
2075
- }
2076
- /**
2077
- * @deprecated - Use MotionNodeTapHandlers
2078
- */
2079
- interface TapHandlers extends MotionNodeTapHandlers {
2080
- }
2081
- interface MotionNodeFocusHandlers {
2082
- /**
2083
- * Properties or variant label to animate to while the focus gesture is recognised.
2084
- *
2085
- * ```jsx
2086
- * <motion.input whileFocus={{ scale: 1.2 }} />
2087
- * ```
2088
- */
2089
- whileFocus?: VariantLabels | TargetAndTransition;
2090
- }
2091
- /**
2092
- * TODO: Replace with types from inView()
2093
- */
2094
- type ViewportEventHandler = (entry: IntersectionObserverEntry | null) => void;
2095
- interface ViewportOptions {
2096
- root?: {
2097
- current: Element | null;
2098
- };
2099
- once?: boolean;
2100
- margin?: string;
2101
- amount?: "some" | "all" | number;
2102
- }
2103
- interface MotionNodeViewportOptions {
2104
- whileInView?: VariantLabels | TargetAndTransition;
2105
- onViewportEnter?: ViewportEventHandler;
2106
- onViewportLeave?: ViewportEventHandler;
2107
- viewport?: ViewportOptions;
2108
- }
2109
- interface MotionNodeDraggableOptions {
2110
- /**
2111
- * Enable dragging for this element. Set to `false` by default.
2112
- * Set `true` to drag in both directions.
2113
- * Set `"x"` or `"y"` to only drag in a specific direction.
2114
- *
2115
- * ```jsx
2116
- * <motion.div drag="x" />
2117
- * ```
2118
- */
2119
- drag?: boolean | "x" | "y";
2120
- /**
2121
- * Properties or variant label to animate to while the drag gesture is recognised.
2122
- *
2123
- * ```jsx
2124
- * <motion.div whileDrag={{ scale: 1.2 }} />
2125
- * ```
2126
- */
2127
- whileDrag?: VariantLabels | TargetAndTransition;
2128
- /**
2129
- * If `true`, this will lock dragging to the initially-detected direction. Defaults to `false`.
2130
- *
2131
- * ```jsx
2132
- * <motion.div drag dragDirectionLock />
2133
- * ```
2134
- */
2135
- dragDirectionLock?: boolean;
2136
- /**
2137
- * Allows drag gesture propagation to child components. Set to `false` by
2138
- * default.
2139
- *
2140
- * ```jsx
2141
- * <motion.div drag="x" dragPropagation />
2142
- * ```
2143
- */
2144
- dragPropagation?: boolean;
2145
- /**
2146
- * Applies constraints on the permitted draggable area.
2147
- *
2148
- * It can accept an object of optional `top`, `left`, `right`, and `bottom` values, measured in pixels.
2149
- * This will define a distance from the named edge of the draggable component.
2150
- *
2151
- * Alternatively, it can accept a `ref` to another component created with React's `useRef` hook.
2152
- * This `ref` should be passed both to the draggable component's `dragConstraints` prop, and the `ref`
2153
- * of the component you want to use as constraints.
2154
- *
2155
- * ```jsx
2156
- * // In pixels
2157
- * <motion.div
2158
- * drag="x"
2159
- * dragConstraints={{ left: 0, right: 300 }}
2160
- * />
2161
- *
2162
- * // As a ref to another component
2163
- * const MyComponent = () => {
2164
- * const constraintsRef = useRef(null)
2165
- *
2166
- * return (
2167
- * <motion.div ref={constraintsRef}>
2168
- * <motion.div drag dragConstraints={constraintsRef} />
2169
- * </motion.div>
2170
- * )
2171
- * }
2172
- * ```
2173
- */
2174
- dragConstraints?: false | Partial<BoundingBox> | {
2175
- current: Element | null;
2176
- };
2177
- /**
2178
- * The degree of movement allowed outside constraints. 0 = no movement, 1 =
2179
- * full movement.
2180
- *
2181
- * Set to `0.5` by default. Can also be set as `false` to disable movement.
2182
- *
2183
- * By passing an object of `top`/`right`/`bottom`/`left`, individual values can be set
2184
- * per constraint. Any missing values will be set to `0`.
2185
- *
2186
- * ```jsx
2187
- * <motion.div
2188
- * drag
2189
- * dragConstraints={{ left: 0, right: 300 }}
2190
- * dragElastic={0.2}
2191
- * />
2192
- * ```
2193
- */
2194
- dragElastic?: DragElastic;
2195
- /**
2196
- * Apply momentum from the pan gesture to the component when dragging
2197
- * finishes. Set to `true` by default.
2198
- *
2199
- * ```jsx
2200
- * <motion.div
2201
- * drag
2202
- * dragConstraints={{ left: 0, right: 300 }}
2203
- * dragMomentum={false}
2204
- * />
2205
- * ```
2206
- */
2207
- dragMomentum?: boolean;
2208
- /**
2209
- * Allows you to change dragging inertia parameters.
2210
- * 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.
2211
- * See {@link https://motion.dev/docs/react-motion-component#dragtransition | Inertia} for all properties you can use.
2212
- *
2213
- * ```jsx
2214
- * <motion.div
2215
- * drag
2216
- * dragTransition={{ bounceStiffness: 600, bounceDamping: 10 }}
2217
- * />
2218
- * ```
2219
- */
2220
- dragTransition?: InertiaOptions;
2221
- /**
2222
- * Usually, dragging is initiated by pressing down on a component and moving it. For some
2223
- * use-cases, for instance clicking at an arbitrary point on a video scrubber, we
2224
- * might want to initiate dragging from a different component than the draggable one.
2225
- *
2226
- * By creating a `dragControls` using the `useDragControls` hook, we can pass this into
2227
- * the draggable component's `dragControls` prop. It exposes a `start` method
2228
- * that can start dragging from pointer events on other components.
2229
- *
2230
- * ```jsx
2231
- * const dragControls = useDragControls()
2232
- *
2233
- * function startDrag(event) {
2234
- * dragControls.start(event, { snapToCursor: true })
2235
- * }
2236
- *
2237
- * return (
2238
- * <>
2239
- * <div onPointerDown={startDrag} />
2240
- * <motion.div drag="x" dragControls={dragControls} />
2241
- * </>
2242
- * )
2243
- * ```
2244
- */
2245
- dragControls?: any;
2246
- /**
2247
- * If true, element will snap back to its origin when dragging ends.
2248
- *
2249
- * Enabling this is the equivalent of setting all `dragConstraints` axes to `0`
2250
- * with `dragElastic={1}`, but when used together `dragConstraints` can define
2251
- * a wider draggable area and `dragSnapToOrigin` will ensure the element
2252
- * animates back to its origin on release.
2253
- */
2254
- dragSnapToOrigin?: boolean;
2255
- /**
2256
- * By default, if `drag` is defined on a component then an event listener will be attached
2257
- * to automatically initiate dragging when a user presses down on it.
2258
- *
2259
- * By setting `dragListener` to `false`, this event listener will not be created.
2260
- *
2261
- * ```jsx
2262
- * const dragControls = useDragControls()
2263
- *
2264
- * function startDrag(event) {
2265
- * dragControls.start(event, { snapToCursor: true })
2266
- * }
2267
- *
2268
- * return (
2269
- * <>
2270
- * <div onPointerDown={startDrag} />
2271
- * <motion.div
2272
- * drag="x"
2273
- * dragControls={dragControls}
2274
- * dragListener={false}
2275
- * />
2276
- * </>
2277
- * )
2278
- * ```
2279
- */
2280
- dragListener?: boolean;
2281
- /**
2282
- * If `dragConstraints` is set to a React ref, this callback will call with the measured drag constraints.
2283
- *
2284
- * @public
2285
- */
2286
- onMeasureDragConstraints?: (constraints: BoundingBox) => BoundingBox | void;
2287
- /**
2288
- * Usually, dragging uses the layout project engine, and applies transforms to the underlying VisualElement.
2289
- * Passing MotionValues as _dragX and _dragY instead applies drag updates to these motion values.
2290
- * This allows you to manually control how updates from a drag gesture on an element is applied.
2291
- *
2292
- * @public
2293
- */
2294
- _dragX?: MotionValue<number>;
2295
- /**
2296
- * Usually, dragging uses the layout project engine, and applies transforms to the underlying VisualElement.
2297
- * Passing MotionValues as _dragX and _dragY instead applies drag updates to these motion values.
2298
- * This allows you to manually control how updates from a drag gesture on an element is applied.
2299
- *
2300
- * @public
2301
- */
2302
- _dragY?: MotionValue<number>;
2303
- }
2304
- interface MotionNodeDragHandlers {
2305
- /**
2306
- * Callback function that fires when dragging starts.
2307
- *
2308
- * ```jsx
2309
- * <motion.div
2310
- * drag
2311
- * onDragStart={
2312
- * (event, info) => console.log(info.point.x, info.point.y)
2313
- * }
2314
- * />
2315
- * ```
2316
- *
2317
- * @public
2318
- */
2319
- onDragStart?(event: MouseEvent | TouchEvent | PointerEvent, info: PanInfo): void;
2320
- /**
2321
- * Callback function that fires when dragging ends.
2322
- *
2323
- * ```jsx
2324
- * <motion.div
2325
- * drag
2326
- * onDragEnd={
2327
- * (event, info) => console.log(info.point.x, info.point.y)
2328
- * }
2329
- * />
2330
- * ```
2331
- *
2332
- * @public
2333
- */
2334
- onDragEnd?(event: MouseEvent | TouchEvent | PointerEvent, info: PanInfo): void;
2335
- /**
2336
- * Callback function that fires when the component is dragged.
2337
- *
2338
- * ```jsx
2339
- * <motion.div
2340
- * drag
2341
- * onDrag={
2342
- * (event, info) => console.log(info.point.x, info.point.y)
2343
- * }
2344
- * />
2345
- * ```
2346
- *
2347
- * @public
2348
- */
2349
- onDrag?(event: MouseEvent | TouchEvent | PointerEvent, info: PanInfo): void;
2350
- /**
2351
- * Callback function that fires a drag direction is determined.
2352
- *
2353
- * ```jsx
2354
- * <motion.div
2355
- * drag
2356
- * dragDirectionLock
2357
- * onDirectionLock={axis => console.log(axis)}
2358
- * />
2359
- * ```
2360
- *
2361
- * @public
2362
- */
2363
- onDirectionLock?(axis: "x" | "y"): void;
2364
- /**
2365
- * Callback function that fires when drag momentum/bounce transition finishes.
2366
- *
2367
- * ```jsx
2368
- * <motion.div
2369
- * drag
2370
- * onDragTransitionEnd={() => console.log('Drag transition complete')}
2371
- * />
2372
- * ```
2373
- *
2374
- * @public
2375
- */
2376
- onDragTransitionEnd?(): void;
2377
- }
2378
- interface MotionNodeLayoutOptions {
2379
- /**
2380
- * If `true`, this component will automatically animate to its new position when
2381
- * its layout changes.
2382
- *
2383
- * ```jsx
2384
- * <motion.div layout />
2385
- * ```
2386
- *
2387
- * This will perform a layout animation using performant transforms. Part of this technique
2388
- * involved animating an element's scale. This can introduce visual distortions on children,
2389
- * `boxShadow` and `borderRadius`.
2390
- *
2391
- * To correct distortion on immediate children, add `layout` to those too.
2392
- *
2393
- * `boxShadow` and `borderRadius` will automatically be corrected if they are already being
2394
- * animated on this component. Otherwise, set them directly via the `initial` prop.
2395
- *
2396
- * If `layout` is set to `"position"`, the size of the component will change instantly and
2397
- * only its position will animate.
2398
- *
2399
- * If `layout` is set to `"size"`, the position of the component will change instantly and
2400
- * only its size will animate.
2401
- *
2402
- * If `layout` is set to `"preserve-aspect"`, the component will animate size & position if
2403
- * the aspect ratio remains the same between renders, and just position if the ratio changes.
2404
- *
2405
- * @public
2406
- */
2407
- layout?: boolean | "position" | "size" | "preserve-aspect";
2408
- /**
2409
- * Enable shared layout transitions between different components with the same `layoutId`.
2410
- *
2411
- * When a component with a layoutId is removed from the React tree, and then
2412
- * added elsewhere, it will visually animate from the previous component's bounding box
2413
- * and its latest animated values.
2414
- *
2415
- * ```jsx
2416
- * {items.map(item => (
2417
- * <motion.li layout>
2418
- * {item.name}
2419
- * {item.isSelected && <motion.div layoutId="underline" />}
2420
- * </motion.li>
2421
- * ))}
2422
- * ```
2423
- *
2424
- * If the previous component remains in the tree it will crossfade with the new component.
2425
- *
2426
- * @public
2427
- */
2428
- layoutId?: string;
2429
- /**
2430
- * A callback that will fire when a layout animation on this component starts.
2431
- *
2432
- * @public
2433
- */
2434
- onLayoutAnimationStart?(): void;
2435
- /**
2436
- * A callback that will fire when a layout animation on this component completes.
2437
- *
2438
- * @public
2439
- */
2440
- onLayoutAnimationComplete?(): void;
2441
- /**
2442
- * @public
2443
- */
2444
- layoutDependency?: any;
2445
- /**
2446
- * Whether a projection node should measure its scroll when it or its descendants update their layout.
2447
- *
2448
- * @public
2449
- */
2450
- layoutScroll?: boolean;
2451
- /**
2452
- * Whether an element should be considered a "layout root", where
2453
- * all children will be forced to resolve relatively to it.
2454
- * Currently used for `position: sticky` elements in Framer.
2455
- */
2456
- layoutRoot?: boolean;
2457
- /**
2458
- * Attached to a portal root to ensure we attach the child to the document root and don't
2459
- * perform scale correction on it.
2460
- */
2461
- "data-framer-portal-id"?: string;
2462
- /**
2463
- * By default, shared layout elements will crossfade. By setting this
2464
- * to `false`, this element will take its default opacity throughout the animation.
2465
- */
2466
- layoutCrossfade?: boolean;
2467
- }
2468
- /**
2469
- * @deprecated - Use MotionNodeDragHandlers/MotionNodeDraggableOptions
2470
- */
2471
- interface DraggableProps extends MotionNodeDragHandlers, MotionNodeDraggableOptions {
2472
- }
2473
- type TransformTemplate = (transform: TransformProperties, generatedTransform: string) => string;
2474
- interface MotionNodeAdvancedOptions {
2475
- /**
2476
- * Custom data to use to resolve dynamic variants differently for each animating component.
2477
- *
2478
- * ```jsx
2479
- * const variants = {
2480
- * visible: (custom) => ({
2481
- * opacity: 1,
2482
- * transition: { delay: custom * 0.2 }
2483
- * })
2484
- * }
2485
- *
2486
- * <motion.div custom={0} animate="visible" variants={variants} />
2487
- * <motion.div custom={1} animate="visible" variants={variants} />
2488
- * <motion.div custom={2} animate="visible" variants={variants} />
2489
- * ```
2490
- *
2491
- * @public
2492
- */
2493
- custom?: any;
2494
- /**
2495
- * @public
2496
- * Set to `false` to prevent inheriting variant changes from its parent.
2497
- */
2498
- inherit?: boolean;
2499
- /**
2500
- * @public
2501
- * Set to `false` to prevent throwing an error when a `motion` component is used within a `LazyMotion` set to strict.
2502
- */
2503
- ignoreStrict?: boolean;
2504
- /**
2505
- * Provide a set of motion values to perform animations on.
2506
- */
2507
- values?: {
2508
- [key: string]: MotionValue<number> | MotionValue<string>;
2509
- };
2510
- /**
2511
- * By default, Motion generates a `transform` property with a sensible transform order. `transformTemplate`
2512
- * can be used to create a different order, or to append/preprend the automatically generated `transform` property.
2513
- *
2514
- * ```jsx
2515
- * <motion.div
2516
- * style={{ x: 0, rotate: 180 }}
2517
- * transformTemplate={
2518
- * ({ x, rotate }) => `rotate(${rotate}deg) translateX(${x}px)`
2519
- * }
2520
- * />
2521
- * ```
2522
- *
2523
- * @param transform - The latest animated transform props.
2524
- * @param generatedTransform - The transform string as automatically generated by Motion
2525
- *
2526
- * @public
2527
- */
2528
- transformTemplate?: TransformTemplate;
2529
- "data-framer-appear-id"?: string;
2530
- }
2531
- interface MotionNodeOptions extends MotionNodeAnimationOptions, MotionNodeEventOptions, MotionNodePanHandlers, MotionNodeTapHandlers, MotionNodeHoverHandlers, MotionNodeFocusHandlers, MotionNodeViewportOptions, MotionNodeDragHandlers, MotionNodeDraggableOptions, MotionNodeLayoutOptions, MotionNodeAdvancedOptions {
2532
- }
2533
-
2534
- declare function defaultTransformValue(name: string): number;
2535
- declare function parseValueFromTransform(transform: string | undefined, name: string): number;
2536
- declare const readTransformValue: (instance: HTMLElement, name: string) => number;
2537
-
2538
- declare function getComputedStyle(element: HTMLElement | SVGElement, name: string): string;
2539
-
2540
- declare function setStyle(element: HTMLElement | SVGElement, name: string, value: AnyResolvedKeyframe): void;
2541
-
2542
- declare const positionalKeys: Set<string>;
2543
-
2544
- /**
2545
- * Generate a list of every possible transform key.
2546
- */
2547
- declare const transformPropOrder: string[];
2548
- /**
2549
- * A quick lookup for transform props.
2550
- */
2551
- declare const transformProps: Set<string>;
2552
-
2553
- interface ResizeInfo {
2554
- width: number;
2555
- height: number;
2556
- }
2557
- type ResizeHandler<I> = (element: I, info: ResizeInfo) => void;
2558
- type WindowResizeHandler = (info: ResizeInfo) => void;
2559
-
2560
- declare function resize(onResize: WindowResizeHandler): VoidFunction;
2561
- declare function resize(target: ElementOrSelector, onResize: ResizeHandler<Element>): VoidFunction;
2562
-
2563
- type Update = (progress: number) => void;
2564
- declare function observeTimeline(update: Update, timeline: ProgressTimeline): () => void;
2565
-
2566
- declare const stepsOrder: StepId[];
2567
- type StepNames = (typeof stepsOrder)[number];
2568
-
2569
- interface Summary {
2570
- min: number;
2571
- max: number;
2572
- avg: number;
2573
- }
2574
- type FrameloopStatNames = "rate" | StepNames;
2575
- interface Stats<T> {
2576
- frameloop: {
2577
- [key in FrameloopStatNames]: T;
2578
- };
2579
- animations: {
2580
- mainThread: T;
2581
- waapi: T;
2582
- layout: T;
2583
- };
2584
- layoutProjection: {
2585
- nodes: T;
2586
- calculatedTargetDeltas: T;
2587
- calculatedProjections: T;
2588
- };
2589
- }
2590
- type StatsBuffer = number[];
2591
- type FrameStats = Stats<number>;
2592
- type StatsRecording = Stats<StatsBuffer>;
2593
- type StatsSummary = Stats<Summary>;
2594
-
2595
- declare function reportStats(): StatsSummary;
2596
- declare function recordStats(): typeof reportStats;
2597
-
2598
- declare const activeAnimations: {
2599
- layout: number;
2600
- mainThread: number;
2601
- waapi: number;
2602
- };
2603
-
2604
- type InactiveStatsBuffer = {
2605
- value: null;
2606
- addProjectionMetrics: null;
2607
- };
2608
- type ActiveStatsBuffer = {
2609
- value: StatsRecording;
2610
- addProjectionMetrics: (metrics: {
2611
- nodes: number;
2612
- calculatedTargetDeltas: number;
2613
- calculatedProjections: number;
2614
- }) => void;
2615
- };
2616
- declare const statsBuffer: InactiveStatsBuffer | ActiveStatsBuffer;
2617
-
2618
- type Mixer<T> = (p: number) => T;
2619
- type MixerFactory<T> = (a: T, b: T) => Mixer<T>;
2620
-
2621
- interface InterpolateOptions<T> {
2622
- clamp?: boolean;
2623
- ease?: EasingFunction | EasingFunction[];
2624
- mixer?: MixerFactory<T>;
2625
- }
2626
- /**
2627
- * Create a function that maps from a numerical input array to a generic output array.
2628
- *
2629
- * Accepts:
2630
- * - Numbers
2631
- * - Colors (hex, hsl, hsla, rgb, rgba)
2632
- * - Complex (combinations of one or more numbers or strings)
2633
- *
2634
- * ```jsx
2635
- * const mixColor = interpolate([0, 1], ['#fff', '#000'])
2636
- *
2637
- * mixColor(0.5) // 'rgba(128, 128, 128, 1)'
2638
- * ```
2639
- *
2640
- * TODO Revisit this approach once we've moved to data models for values,
2641
- * probably not needed to pregenerate mixer functions.
2642
- *
2643
- * @public
2644
- */
2645
- declare function interpolate<T>(input: number[], output: T[], { clamp: isClamp, ease, mixer }?: InterpolateOptions<T>): (v: number) => T;
2646
-
2647
- /**
2648
- * Checks if an element is an HTML element in a way
2649
- * that works across iframes
2650
- */
2651
- declare function isHTMLElement(element: unknown): element is HTMLElement;
2652
-
2653
- /**
2654
- * Checks if an element is an SVG element in a way
2655
- * that works across iframes
2656
- */
2657
- declare function isSVGElement(element: unknown): element is SVGElement;
2658
-
2659
- /**
2660
- * Checks if an element is specifically an SVGSVGElement (the root SVG element)
2661
- * in a way that works across iframes
2662
- */
2663
- declare function isSVGSVGElement(element: unknown): element is SVGSVGElement;
2664
-
2665
- declare function mix<T>(from: T, to: T): Mixer<T>;
2666
- declare function mix(from: number, to: number, p: number): number;
2667
-
2668
- type Transformer = (v: any) => any;
2669
- type ValueType = {
2670
- test: (v: any) => boolean;
2671
- parse: (v: any) => any;
2672
- transform?: Transformer;
2673
- createTransformer?: (template: string) => Transformer;
2674
- default?: any;
2675
- getAnimatableNone?: (v: any) => any;
2676
- };
2677
- type NumberMap = {
2678
- [key: string]: number;
2679
- };
2680
- type RGBA = {
2681
- red: number;
2682
- green: number;
2683
- blue: number;
2684
- alpha: number;
2685
- };
2686
- type HSLA = {
2687
- hue: number;
2688
- saturation: number;
2689
- lightness: number;
2690
- alpha: number;
2691
- };
2692
- type Color = HSLA | RGBA;
2693
-
2694
- declare const mixLinearColor: (from: number, to: number, v: number) => number;
2695
- declare const mixColor: (from: Color | string, to: Color | string) => (p: number) => string | Color;
2696
-
2697
- type MixableArray = Array<number | RGBA | HSLA | string>;
2698
- interface MixableObject {
2699
- [key: string]: AnyResolvedKeyframe | RGBA | HSLA;
2700
- }
2701
- declare function getMixer<T>(a: T): ((from: string | Color, to: string | Color) => (p: number) => string | Color) | ((origin: AnyResolvedKeyframe, target: AnyResolvedKeyframe) => Function) | typeof mixArray | typeof mixObject;
2702
- declare function mixArray(a: MixableArray, b: MixableArray): (p: number) => (string | number | RGBA | HSLA)[];
2703
- declare function mixObject(a: MixableObject, b: MixableObject): (v: number) => {
2704
- [x: string]: AnyResolvedKeyframe | RGBA | HSLA;
2705
- };
2706
- declare const mixComplex: (origin: AnyResolvedKeyframe, target: AnyResolvedKeyframe) => Function;
2707
-
2708
- declare function mixImmediate<T>(a: T, b: T): (p: number) => T;
2709
-
2710
- declare const mixNumber: (from: number, to: number, progress: number) => number;
2711
-
2712
- declare const invisibleValues: Set<string>;
2713
- /**
2714
- * Returns a function that, when provided a progress value between 0 and 1,
2715
- * will return the "none" or "hidden" string only when the progress is that of
2716
- * the origin or target.
2717
- */
2718
- declare function mixVisibility(origin: string, target: string): (p: number) => string;
2719
-
2720
- type StaggerOrigin = "first" | "last" | "center" | number;
2721
- type StaggerOptions = {
2722
- startDelay?: number;
2723
- from?: StaggerOrigin;
2724
- ease?: Easing;
2725
- };
2726
- declare function getOriginIndex(from: StaggerOrigin, total: number): number;
2727
- declare function stagger(duration?: number, { startDelay, from, ease }?: StaggerOptions): DynamicOption<number>;
2728
-
2729
- /**
2730
- * Add the ability for test suites to manually set support flags
2731
- * to better test more environments.
2732
- */
2733
- declare const supportsFlags: Record<string, boolean | undefined>;
2734
-
2735
- declare const supportsLinearEasing: () => boolean;
2736
-
2737
- declare global {
2738
- interface Window {
2739
- ScrollTimeline: ScrollTimeline;
2740
- }
2741
- }
2742
- declare class ScrollTimeline implements ProgressTimeline {
2743
- constructor(options: ScrollOptions);
2744
- currentTime: null | {
2745
- value: number;
2746
- };
2747
- cancel?: VoidFunction;
2748
- }
2749
- declare const supportsScrollTimeline: () => boolean;
2750
-
2751
- /**
2752
- * @public
2753
- */
2754
- interface TransformOptions<T> {
2755
- /**
2756
- * Clamp values to within the given range. Defaults to `true`
2757
- *
2758
- * @public
2759
- */
2760
- clamp?: boolean;
2761
- /**
2762
- * Easing functions to use on the interpolations between each value in the input and output ranges.
2763
- *
2764
- * If provided as an array, the array must be one item shorter than the input and output ranges, as the easings apply to the transition **between** each.
2765
- *
2766
- * @public
2767
- */
2768
- ease?: EasingFunction | EasingFunction[];
2769
- /**
2770
- * Provide a function that can interpolate between any two values in the provided range.
2771
- *
2772
- * @public
2773
- */
2774
- mixer?: (from: T, to: T) => (v: number) => any;
2775
- }
2776
- /**
2777
- * Transforms numbers into other values by mapping them from an input range to an output range.
2778
- * Returns the type of the input provided.
2779
- *
2780
- * @remarks
2781
- *
2782
- * Given an input range of `[0, 200]` and an output range of
2783
- * `[0, 1]`, this function will return a value between `0` and `1`.
2784
- * The input range must be a linear series of numbers. The output range
2785
- * can be any supported value type, such as numbers, colors, shadows, arrays, objects and more.
2786
- * Every value in the output range must be of the same type and in the same format.
2787
- *
2788
- * ```jsx
2789
- * export function MyComponent() {
2790
- * const inputRange = [0, 200]
2791
- * const outputRange = [0, 1]
2792
- * const output = transform(100, inputRange, outputRange)
2793
- *
2794
- * // Returns 0.5
2795
- * return <div>{output}</div>
2796
- * }
2797
- * ```
2798
- *
2799
- * @param inputValue - A number to transform between the input and output ranges.
2800
- * @param inputRange - A linear series of numbers (either all increasing or decreasing).
2801
- * @param outputRange - A series of numbers, colors, strings, or arrays/objects of those. Must be the same length as `inputRange`.
2802
- * @param options - Clamp: Clamp values to within the given range. Defaults to `true`.
2803
- *
2804
- * @public
2805
- */
2806
- declare function transform<T>(inputValue: number, inputRange: number[], outputRange: T[], options?: TransformOptions<T>): T;
2807
- /**
2808
- *
2809
- * Transforms numbers into other values by mapping them from an input range to an output range.
2810
- *
2811
- * Given an input range of `[0, 200]` and an output range of
2812
- * `[0, 1]`, this function will return a value between `0` and `1`.
2813
- * The input range must be a linear series of numbers. The output range
2814
- * can be any supported value type, such as numbers, colors, shadows, arrays, objects and more.
2815
- * Every value in the output range must be of the same type and in the same format.
2816
- *
2817
- * ```jsx
2818
- * export function MyComponent() {
2819
- * const inputRange = [-200, -100, 100, 200]
2820
- * const outputRange = [0, 1, 1, 0]
2821
- * const convertRange = transform(inputRange, outputRange)
2822
- * const output = convertRange(-150)
2823
- *
2824
- * // Returns 0.5
2825
- * return <div>{output}</div>
2826
- * }
2827
- *
2828
- * ```
2829
- *
2830
- * @param inputRange - A linear series of numbers (either all increasing or decreasing).
2831
- * @param outputRange - A series of numbers, colors or strings. Must be the same length as `inputRange`.
2832
- * @param options - Clamp: clamp values to within the given range. Defaults to `true`.
2833
- *
2834
- * @public
2835
- */
2836
- declare function transform<T>(inputRange: number[], outputRange: T[], options?: TransformOptions<T>): (inputValue: number) => T;
2837
-
2838
- type MapInputRange = number[];
2839
- /**
2840
- * Create a `MotionValue` that maps the output of another `MotionValue` by
2841
- * mapping it from one range of values into another.
2842
- *
2843
- * @remarks
2844
- *
2845
- * Given an input range of `[-200, -100, 100, 200]` and an output range of
2846
- * `[0, 1, 1, 0]`, the returned `MotionValue` will:
2847
- *
2848
- * - When provided a value between `-200` and `-100`, will return a value between `0` and `1`.
2849
- * - When provided a value between `-100` and `100`, will return `1`.
2850
- * - When provided a value between `100` and `200`, will return a value between `1` and `0`
2851
- *
2852
- * The input range must be a linear series of numbers. The output range
2853
- * can be any value type supported by Motion: numbers, colors, shadows, etc.
2854
- *
2855
- * Every value in the output range must be of the same type and in the same format.
2856
- *
2857
- * ```jsx
2858
- * const x = motionValue(0)
2859
- * const xRange = [-200, -100, 100, 200]
2860
- * const opacityRange = [0, 1, 1, 0]
2861
- * const opacity = mapValue(x, xRange, opacityRange)
2862
- * ```
2863
- *
2864
- * @param inputValue - `MotionValue`
2865
- * @param inputRange - A linear series of numbers (either all increasing or decreasing)
2866
- * @param outputRange - A series of numbers, colors or strings. Must be the same length as `inputRange`.
2867
- * @param options -
2868
- *
2869
- * - clamp: boolean. Clamp values to within the given range. Defaults to `true`
2870
- * - ease: EasingFunction[]. Easing functions to use on the interpolations between each value in the input and output ranges. If provided as an array, the array must be one item shorter than the input and output ranges, as the easings apply to the transition between each.
2871
- *
2872
- * @returns `MotionValue`
2873
- *
2874
- * @public
2875
- */
2876
- declare function mapValue<O>(inputValue: MotionValue<number>, inputRange: MapInputRange, outputRange: O[], options?: TransformOptions<O>): MotionValue<O>;
2877
-
2878
- /**
2879
- * Create a `MotionValue` that animates to its latest value using a spring.
2880
- * Can either be a value or track another `MotionValue`.
2881
- *
2882
- * ```jsx
2883
- * const x = motionValue(0)
2884
- * const y = transformValue(() => x.get() * 2) // double x
2885
- * ```
2886
- *
2887
- * @param transformer - A transform function. This function must be pure with no side-effects or conditional statements.
2888
- * @returns `MotionValue`
2889
- *
2890
- * @public
2891
- */
2892
- declare function springValue<T extends AnyResolvedKeyframe>(source: T | MotionValue<T>, options?: SpringOptions): MotionValue<T>;
2893
- declare function attachSpring<T extends AnyResolvedKeyframe>(value: MotionValue<T>, source: T | MotionValue<T>, options?: SpringOptions): VoidFunction;
2894
-
2895
- type TransformInputRange = number[];
2896
- type SingleTransformer<I, O> = (input: I) => O;
2897
- type MultiTransformer<I, O> = (input: I[]) => O;
2898
- type ValueTransformer<I, O> = SingleTransformer<I, O> | MultiTransformer<I, O>;
2899
- /**
2900
- * Create a `MotionValue` that transforms the output of other `MotionValue`s by
2901
- * passing their latest values through a transform function.
2902
- *
2903
- * Whenever a `MotionValue` referred to in the provided function is updated,
2904
- * it will be re-evaluated.
2905
- *
2906
- * ```jsx
2907
- * const x = motionValue(0)
2908
- * const y = transformValue(() => x.get() * 2) // double x
2909
- * ```
2910
- *
2911
- * @param transformer - A transform function. This function must be pure with no side-effects or conditional statements.
2912
- * @returns `MotionValue`
2913
- *
2914
- * @public
2915
- */
2916
- declare function transformValue<O>(transform: () => O): MotionValue<O>;
2917
-
2918
- declare const color: {
2919
- test: (v: any) => boolean;
2920
- parse: (v: any) => RGBA | HSLA;
2921
- transform: (v: HSLA | RGBA | string) => string;
2922
- getAnimatableNone: (v: string) => string;
2923
- };
2924
-
2925
- declare function parseHex(v: string): RGBA;
2926
- declare const hex: {
2927
- test: (v: any) => boolean;
2928
- parse: typeof parseHex;
2929
- transform: ({ red, green, blue, alpha }: RGBA) => string;
2930
- };
2931
-
2932
- declare const hsla: {
2933
- test: (v: any) => boolean;
2934
- parse: (v: string | Color) => HSLA;
2935
- transform: ({ hue, saturation, lightness, alpha }: HSLA) => string;
2936
- };
2937
-
2938
- declare function hslaToRgba({ hue, saturation, lightness, alpha }: HSLA): RGBA;
2939
-
2940
- declare const rgbUnit: {
2941
- transform: (v: number) => number;
2942
- test: (v: number) => boolean;
2943
- parse: typeof parseFloat;
2944
- };
2945
- declare const rgba: {
2946
- test: (v: any) => boolean;
2947
- parse: (v: string | Color) => RGBA;
2948
- transform: ({ red, green, blue, alpha }: RGBA) => string;
2949
- };
2950
-
2951
- declare function test(v: any): boolean;
2952
- type ComplexValues = Array<CSSVariableToken | AnyResolvedKeyframe | Color>;
2953
- interface ValueIndexes {
2954
- color: number[];
2955
- number: number[];
2956
- var: number[];
2957
- }
2958
- interface ComplexValueInfo {
2959
- values: ComplexValues;
2960
- split: string[];
2961
- indexes: ValueIndexes;
2962
- types: Array<keyof ValueIndexes>;
2963
- }
2964
- declare function analyseComplexValue(value: AnyResolvedKeyframe): ComplexValueInfo;
2965
- declare function parseComplexValue(v: AnyResolvedKeyframe): ComplexValues;
2966
- declare function createTransformer(source: AnyResolvedKeyframe): (v: Array<CSSVariableToken | Color | number | string>) => string;
2967
- declare function getAnimatableNone$1(v: AnyResolvedKeyframe): string;
2968
- declare const complex: {
2969
- test: typeof test;
2970
- parse: typeof parseComplexValue;
2971
- createTransformer: typeof createTransformer;
2972
- getAnimatableNone: typeof getAnimatableNone$1;
2973
- };
2974
-
2975
- /**
2976
- * A list of value types commonly used for dimensions
2977
- */
2978
- declare const dimensionValueTypes: ({
2979
- test: (v: number) => boolean;
2980
- parse: typeof parseFloat;
2981
- transform: (v: number) => number;
2982
- } | {
2983
- test: (v: AnyResolvedKeyframe) => boolean;
2984
- parse: typeof parseFloat;
2985
- transform: (v: string | number) => string;
2986
- } | ValueType)[];
2987
- /**
2988
- * Tests a dimensional value against the list of dimension ValueTypes
2989
- */
2990
- declare const findDimensionValueType: (v: any) => {
2991
- test: (v: number) => boolean;
2992
- parse: typeof parseFloat;
2993
- transform: (v: number) => number;
2994
- } | {
2995
- test: (v: AnyResolvedKeyframe) => boolean;
2996
- parse: typeof parseFloat;
2997
- transform: (v: string | number) => string;
2998
- } | ValueType | undefined;
2999
-
3000
- interface ValueTypeMap {
3001
- [key: string]: ValueType;
3002
- }
3003
-
3004
- /**
3005
- * A map of default value types for common values
3006
- */
3007
- declare const defaultValueTypes: ValueTypeMap;
3008
- /**
3009
- * Gets the default ValueType for the provided value key
3010
- */
3011
- declare const getDefaultValueType: (key: string) => ValueType;
3012
-
3013
- declare const numberValueTypes: ValueTypeMap;
3014
-
3015
- declare const transformValueTypes: ValueTypeMap;
3016
-
3017
- declare const number: {
3018
- test: (v: number) => boolean;
3019
- parse: typeof parseFloat;
3020
- transform: (v: number) => number;
3021
- };
3022
- declare const alpha: {
3023
- transform: (v: number) => number;
3024
- test: (v: number) => boolean;
3025
- parse: typeof parseFloat;
3026
- };
3027
- declare const scale: {
3028
- default: number;
3029
- test: (v: number) => boolean;
3030
- parse: typeof parseFloat;
3031
- transform: (v: number) => number;
3032
- };
3033
-
3034
- declare const degrees: {
3035
- test: (v: AnyResolvedKeyframe) => boolean;
3036
- parse: typeof parseFloat;
3037
- transform: (v: number | string) => string;
3038
- };
3039
- declare const percent: {
3040
- test: (v: AnyResolvedKeyframe) => boolean;
3041
- parse: typeof parseFloat;
3042
- transform: (v: number | string) => string;
3043
- };
3044
- declare const px: {
3045
- test: (v: AnyResolvedKeyframe) => boolean;
3046
- parse: typeof parseFloat;
3047
- transform: (v: number | string) => string;
3048
- };
3049
- declare const vh: {
3050
- test: (v: AnyResolvedKeyframe) => boolean;
3051
- parse: typeof parseFloat;
3052
- transform: (v: number | string) => string;
3053
- };
3054
- declare const vw: {
3055
- test: (v: AnyResolvedKeyframe) => boolean;
3056
- parse: typeof parseFloat;
3057
- transform: (v: number | string) => string;
3058
- };
3059
- declare const progressPercentage: {
3060
- parse: (v: string) => number;
3061
- transform: (v: number) => string;
3062
- test: (v: AnyResolvedKeyframe) => boolean;
3063
- };
3064
-
3065
- /**
3066
- * Tests a provided value against a ValueType
3067
- */
3068
- declare const testValueType: (v: any) => (type: ValueType) => boolean;
3069
-
3070
- declare function getAnimatableNone(key: string, value: string): any;
3071
-
3072
- /**
3073
- * Tests a value against the list of ValueTypes
3074
- */
3075
- declare const findValueType: (v: any) => {
3076
- test: (v: number) => boolean;
3077
- parse: typeof parseFloat;
3078
- transform: (v: number) => number;
3079
- } | {
3080
- test: (v: AnyResolvedKeyframe) => boolean;
3081
- parse: typeof parseFloat;
3082
- transform: (v: string | number) => string;
3083
- } | ValueType | {
3084
- test: (v: any) => boolean;
3085
- parse: (v: any) => RGBA | HSLA;
3086
- transform: (v: string | RGBA | HSLA) => string;
3087
- getAnimatableNone: (v: string) => string;
3088
- } | {
3089
- test: (v: any) => boolean;
3090
- parse: (v: AnyResolvedKeyframe) => ComplexValues;
3091
- createTransformer: (source: AnyResolvedKeyframe) => (v: (string | number | Color)[]) => string;
3092
- getAnimatableNone: (v: AnyResolvedKeyframe) => string;
3093
- } | undefined;
3094
-
3095
- /**
3096
- * Provided a value and a ValueType, returns the value as that value type.
3097
- */
3098
- declare const getValueAsType: (value: any, type?: ValueType) => any;
3099
-
3100
- declare const isMotionValue: (value: any) => value is MotionValue<any>;
3101
-
3102
- type ViewTransitionAnimationDefinition = {
3103
- keyframes: DOMKeyframesDefinition;
3104
- options: AnimationOptions;
3105
- };
3106
- type ViewTransitionTarget = {
3107
- layout?: ViewTransitionAnimationDefinition;
3108
- enter?: ViewTransitionAnimationDefinition;
3109
- exit?: ViewTransitionAnimationDefinition;
3110
- new?: ViewTransitionAnimationDefinition;
3111
- old?: ViewTransitionAnimationDefinition;
3112
- };
3113
- type ViewTransitionOptions = AnimationOptions & {
3114
- interrupt?: "wait" | "immediate";
3115
- };
3116
- type ViewTransitionTargetDefinition = string | Element;
3117
-
3118
- declare class ViewTransitionBuilder {
3119
- private currentSubject;
3120
- targets: Map<ViewTransitionTargetDefinition, ViewTransitionTarget>;
3121
- update: () => void | Promise<void>;
3122
- options: ViewTransitionOptions;
3123
- notifyReady: (value: GroupAnimation) => void;
3124
- private readyPromise;
3125
- constructor(update: () => void | Promise<void>, options?: ViewTransitionOptions);
3126
- get(subject: ViewTransitionTargetDefinition): this;
3127
- layout(keyframes: DOMKeyframesDefinition, options?: AnimationOptions): this;
3128
- new(keyframes: DOMKeyframesDefinition, options?: AnimationOptions): this;
3129
- old(keyframes: DOMKeyframesDefinition, options?: AnimationOptions): this;
3130
- enter(keyframes: DOMKeyframesDefinition, options?: AnimationOptions): this;
3131
- exit(keyframes: DOMKeyframesDefinition, options?: AnimationOptions): this;
3132
- crossfade(options?: AnimationOptions): this;
3133
- updateTarget(target: "enter" | "exit" | "layout" | "new" | "old", keyframes: DOMKeyframesDefinition, options?: AnimationOptions): void;
3134
- then(resolve: () => void, reject?: () => void): Promise<void>;
3135
- }
3136
- declare function animateView(update: () => void | Promise<void>, defaultOptions?: ViewTransitionOptions): ViewTransitionBuilder;
3137
-
3138
- declare function getViewAnimationLayerInfo(pseudoElement: string): {
3139
- layer: string;
3140
- type: string;
3141
- } | null;
3142
-
3143
- declare function getViewAnimations(): Animation[];
3144
-
3145
- /**
3146
- * @deprecated
3147
- *
3148
- * Import as `frame` instead.
3149
- */
3150
- declare const sync: Batcher;
3151
- /**
3152
- * @deprecated
3153
- *
3154
- * Use cancelFrame(callback) instead.
3155
- */
3156
- declare const cancelSync: Record<string, (process: Process) => void>;
3157
-
3158
- export { type AcceptedAnimations, type ActiveStatsBuffer, type AnimationDefinition, type AnimationGeneratorName, type AnimationGeneratorType, type AnimationOptions, type AnimationOrchestrationOptions, type AnimationPlaybackControls, type AnimationPlaybackControlsWithThen, type AnimationPlaybackLifecycles, type AnimationPlaybackOptions, type AnimationScope, type AnimationState, type AnyResolvedKeyframe, AsyncMotionValueAnimation, type Batcher, type CSSStyleDeclarationWithTransform, type CSSVariableName, type CSSVariableToken, type CancelProcess, type Color, type ComplexValueInfo, type ComplexValues, type DOMKeyframesDefinition, DOMKeyframesResolver, type DOMValueAnimationOptions, type DecayOptions, type DragElastic, type DragHandler, type DraggableProps, type DurationSpringOptions, type DynamicOption, type ElementOrSelector, type EventInfo, type EventOptions, type FrameData, type FrameStats, type GeneratorFactory, type GeneratorFactoryFunction, GroupAnimation, GroupAnimationWithThen, type GroupedAnimations, type HSLA, type InactiveStatsBuffer, type InertiaOptions, type InterpolateOptions, JSAnimation, type KeyframeGenerator, type KeyframeOptions, KeyframeResolver, type LegacyAnimationControls, type MapInputRange, type Mixer, type MixerFactory, type MotionNodeAdvancedOptions, type MotionNodeAnimationOptions, type MotionNodeDragHandlers, type MotionNodeDraggableOptions, type MotionNodeEventOptions, type MotionNodeFocusHandlers, type MotionNodeHoverHandlers, type MotionNodeLayoutOptions, type MotionNodeOptions, type MotionNodePanHandlers, type MotionNodeTapHandlers, type MotionNodeViewportOptions, MotionValue, type MotionValueEventCallbacks, type MotionValueOptions, type MultiTransformer, NativeAnimation, NativeAnimationExtended, type NativeAnimationOptions, type NativeAnimationOptionsExtended, NativeAnimationWrapper, type NumberMap, type OnHoverEndEvent, type OnHoverStartEvent, type OnKeyframesResolved, type OnPressEndEvent, type OnPressStartEvent, type Owner, type PanHandler, type PanInfo, type PassiveEffect, type PointerEventOptions, type PressGestureInfo, type Process, type ProgressTimeline, type RGBA, type RepeatType, type ResolvedConstraints, type ResolvedElastic, type ResolvedKeyframes, type ResolvedValueKeyframe, type ResolvedValues, type SVGAttributes, type SVGForcedAttrKeyframesDefinition, type SVGForcedAttrProperties, type SVGForcedAttrTransitions, type SVGKeyframesDefinition, type SVGPathKeyframesDefinition, type SVGPathProperties, type SVGPathTransitions, type SVGTransitions, type Schedule, type SelectorCache, type SingleTransformer, type Spring, type SpringOptions, type StaggerOptions, type StaggerOrigin, type StartAnimation, type Stats, type StatsBuffer, type StatsRecording, type StatsSummary, type Step, type StepId, type Steps, type StyleKeyframesDefinition, type StyleTransitions, type Subscriber, type Summary, type TapHandlers, type TapInfo, type Target, type TargetAndTransition, type TargetResolver, type TimelineWithFallback, type TransformInputRange, type TransformOptions, type TransformProperties, type TransformTemplate, type Transformer, type Transition, type TransitionWithValueOverrides, type Tween, type UnresolvedKeyframes, type UnresolvedValueKeyframe, type ValueAnimationOptions, type ValueAnimationOptionsWithRenderContext, type ValueAnimationTransition, type ValueAnimationWithDynamicDelay, type ValueIndexes, type ValueKeyframe, type ValueKeyframesDefinition, type ValueTransformer, type ValueTransition, type ValueType, type ValueTypeMap, type VariableKeyframesDefinition, type VariableTransitions, type Variant, type VariantLabels, type Variants, type VelocityOptions, type ViewTransitionAnimationDefinition, ViewTransitionBuilder, type ViewTransitionOptions, type ViewTransitionTarget, type ViewTransitionTargetDefinition, type ViewportEventHandler, type ViewportOptions, type WithQuerySelectorAll, acceleratedValues, activeAnimations, addAttrValue, addStyleValue, alpha, analyseComplexValue, animateValue, animateView, animationMapKey, applyGeneratorOptions, applyPxDefaults, attachSpring, attrEffect, calcGeneratorDuration, cancelFrame, cancelMicrotask, cancelSync, collectMotionValues, color, complex, convertOffsetToTimes, createGeneratorEasing, createRenderBatcher, cubicBezierAsString, defaultEasing, defaultOffset, defaultTransformValue, defaultValueTypes, degrees, dimensionValueTypes, fillOffset, fillWildcards, findDimensionValueType, findValueType, flushKeyframeResolvers, frame, frameData, frameSteps, generateLinearEasing, getAnimatableNone, getAnimationMap, getComputedStyle, getDefaultValueType, getMixer, getOriginIndex, getValueAsType, getValueTransition, getVariableValue, getViewAnimationLayerInfo, getViewAnimations, hex, hover, hsla, hslaToRgba, inertia, interpolate, invisibleValues, isCSSVariableName, isCSSVariableToken, isDragActive, isDragging, isGenerator, isHTMLElement, isMotionValue, isNodeOrChild, isPrimaryPointer, isSVGElement, isSVGSVGElement, isWaapiSupportedEasing, keyframes, makeAnimationInstant, mapEasingToNativeEasing, mapValue, maxGeneratorDuration, microtask, mix, mixArray, mixColor, mixComplex, mixImmediate, mixLinearColor, mixNumber, mixObject, mixVisibility, motionValue, number, numberValueTypes, observeTimeline, parseCSSVariable, parseValueFromTransform, percent, positionalKeys, press, progressPercentage, propEffect, px, readTransformValue, recordStats, resize, resolveElements, rgbUnit, rgba, scale, setDragLock, setStyle, spring, springValue, stagger, startWaapiAnimation, statsBuffer, styleEffect, supportedWaapiEasing, supportsBrowserAnimation, supportsFlags, supportsLinearEasing, supportsPartialKeyframes, supportsScrollTimeline, svgEffect, sync, testValueType, time, transform, transformPropOrder, transformProps, transformValue, transformValueTypes, vh, vw };