@mkbabb/keyframes.js 3.0.0 → 4.0.0
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/README.md +8 -3
- package/dist/animate-DjKYCuyH.js +21 -0
- package/dist/animations-CK1FLX_G.js +224 -0
- package/dist/engine-BZeJ58xD.js +1031 -0
- package/dist/keyframes.d.ts +1639 -178
- package/dist/keyframes.js +341 -391
- package/dist/motion-path-723lMAlR.js +31 -0
- package/dist/springTimingFunction-BgkJPP-_.js +178 -0
- package/dist/timeline-5rnU0j6r.js +281 -0
- package/package.json +43 -18
- package/dist/css-easing-DoPNckiS.js +0 -55
- package/dist/engine-B7JGZTdU.js +0 -742
package/dist/keyframes.d.ts
CHANGED
|
@@ -8,17 +8,88 @@ import { timingFunctions } from '@mkbabb/value.js';
|
|
|
8
8
|
import { ValueArray } from '@mkbabb/value.js';
|
|
9
9
|
import { ValueUnit } from '@mkbabb/value.js';
|
|
10
10
|
|
|
11
|
+
declare const accordionExpand: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Construct, target, and play an animation in one call. Returns the
|
|
15
|
+
* `CSSKeyframesAnimation` as the control handle — `await animate(...)` is NOT
|
|
16
|
+
* the pattern (it would await the *construction*, which is synchronous); await
|
|
17
|
+
* the returned handle's play promise via the `.play()` it already kicked off,
|
|
18
|
+
* or pass `autoPlay: false` and drive it yourself.
|
|
19
|
+
*
|
|
20
|
+
* @param target one or more DOM elements (or a single element) to animate.
|
|
21
|
+
* @param input a CSS string, a keyframe map, a vars array, or a MotionPath
|
|
22
|
+
* spec (`{ path }`) — dispatched on its shape.
|
|
23
|
+
* @param options animation options + optional `transform` / `autoPlay`.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // CSS string → fromString
|
|
27
|
+
* animate(box, `from { opacity: 0 } to { opacity: 1 }`, { duration: 400 });
|
|
28
|
+
* // keyframe map → fromKeyframes
|
|
29
|
+
* animate(box, { "0%": { opacity: 0 }, "100%": { opacity: 1 } });
|
|
30
|
+
* // vars array → fromVars
|
|
31
|
+
* animate(box, [{ opacity: 0 }, { opacity: 1 }], { duration: 400 });
|
|
32
|
+
* // MotionPath spec → fromMotionPath (F.W12 §S2)
|
|
33
|
+
* animate(box, { path: "path('M 0 0 Q 100 -100 200 0')", rotate: "auto" }, { duration: 2000 });
|
|
34
|
+
*/
|
|
35
|
+
declare function animate<V extends Vars = any>(target: HTMLElement | HTMLElement[], input: AnimateInput<V>, options?: AnimateOptions): CSSKeyframesAnimation<V>;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The declarative input to {@link animate} — one of the four `from*` shapes:
|
|
39
|
+
*
|
|
40
|
+
* • `string` — a CSS `@keyframes` (or bare keyframe-block) source.
|
|
41
|
+
* • `KeyframeMap` — `{ "0%": {...}, "100%": {...} }` or the `Map` form.
|
|
42
|
+
* • `V[]` — an ordered vars array (the simplest `[from, to]`
|
|
43
|
+
* pair, or more stops), distributed evenly 0→100%.
|
|
44
|
+
* • `MotionPathInput` — `{ path, from?, to?, rotate? }` — an `offset-distance`
|
|
45
|
+
* sweep over an author `offset-path` (F.W12 §S2).
|
|
46
|
+
*/
|
|
47
|
+
export declare type AnimateInput<V extends Vars> = string | KeyframeMap<V> | V[] | MotionPathInput;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Options accepted by {@link animate}. The animation-options surface, plus an
|
|
51
|
+
* optional custom `transform` renderer (forwarded to the chosen `from*`
|
|
52
|
+
* factory) and `autoPlay` (default true — set false to construct + target
|
|
53
|
+
* without starting, when the caller wants to drive the returned handle).
|
|
54
|
+
*/
|
|
55
|
+
export declare interface AnimateOptions extends Partial<InputAnimationOptions> {
|
|
56
|
+
/** Custom renderer forwarded to the `from*` factory. */
|
|
57
|
+
transform?: TransformFunction<any>;
|
|
58
|
+
/**
|
|
59
|
+
* Auto-start the animation after construction + targeting. Default true.
|
|
60
|
+
* `false` returns a constructed, targeted, NOT-yet-playing handle.
|
|
61
|
+
*/
|
|
62
|
+
autoPlay?: boolean;
|
|
63
|
+
}
|
|
64
|
+
|
|
11
65
|
declare class Animation_2<V extends Vars = any> {
|
|
12
66
|
id: number;
|
|
13
67
|
name: string | undefined;
|
|
14
68
|
superKey: string | undefined;
|
|
15
69
|
targets: HTMLElement[];
|
|
16
70
|
options: AnimationOptions;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
71
|
+
/**
|
|
72
|
+
* The frame-compilation half — template frames → sampled `frames[]`.
|
|
73
|
+
* `Animation` composes one and delegates `addFrame`/`parse` + the frame
|
|
74
|
+
* accessors (`templateFrames`/`parsedVars`/`frames`/`frameId`) to it.
|
|
75
|
+
* Assigned in the constructor once `options` exists (the compiler holds a
|
|
76
|
+
* live reference to that options object).
|
|
77
|
+
*/
|
|
78
|
+
compiler: FrameCompiler<V>;
|
|
79
|
+
/**
|
|
80
|
+
* THE rAF owner for this animation — the standalone rAF play loop and
|
|
81
|
+
* the WAAPI shadow tick both ride it, so `stop()` halts either
|
|
82
|
+
* uniformly and no raw rAF handle leaks onto the instance.
|
|
83
|
+
*/
|
|
84
|
+
readonly playback: RAFPlayback;
|
|
85
|
+
/**
|
|
86
|
+
* The live WAAPI compositor animations during a `_playWAAPI` delegation
|
|
87
|
+
* (one per target), populated by `playWAAPI` and cleared on teardown.
|
|
88
|
+
* The lifecycle methods (`stop`/`reset`) cancel these so a stopped
|
|
89
|
+
* compositor animation never keeps painting and the awaited play
|
|
90
|
+
* promise never hangs. Empty on the rAF path.
|
|
91
|
+
*/
|
|
92
|
+
_waAnimations: globalThis.Animation[];
|
|
22
93
|
startTime: number | undefined;
|
|
23
94
|
pausedTime: number;
|
|
24
95
|
t: number;
|
|
@@ -29,7 +100,7 @@ declare class Animation_2<V extends Vars = any> {
|
|
|
29
100
|
paused: boolean;
|
|
30
101
|
/**
|
|
31
102
|
* True when an `AnimationGroup` is driving this animation's
|
|
32
|
-
* `
|
|
103
|
+
* `advanceTo()` and `interpFrames()` from its own rAF loop. Set by
|
|
33
104
|
* the group at construction; standalone `.play()` / `.draw()`
|
|
34
105
|
* throw when this is true rather than racing the group.
|
|
35
106
|
*/
|
|
@@ -44,31 +115,76 @@ declare class Animation_2<V extends Vars = any> {
|
|
|
44
115
|
private resolvePromise;
|
|
45
116
|
private _playingPromise;
|
|
46
117
|
/**
|
|
47
|
-
* Pre-bound
|
|
48
|
-
* closure on every
|
|
118
|
+
* Pre-bound frame callback — allocated once to avoid creating a new
|
|
119
|
+
* closure on every playback loop start.
|
|
120
|
+
*/
|
|
121
|
+
private _boundFrame;
|
|
122
|
+
/**
|
|
123
|
+
* The ONE output buffer for the standalone play loop's `interpFrames`
|
|
124
|
+
* calls — reused every frame so steady-state playback allocates no
|
|
125
|
+
* per-frame result object (the primitive-level analogue of the group's
|
|
126
|
+
* hoisted `_grouped` buffer, gated by `proof:standalone-zero-alloc`).
|
|
127
|
+
* The play path (`_frame`) never returns this object to a consumer, so
|
|
128
|
+
* reuse is safe; `at()` (a query whose result the caller keeps) still
|
|
129
|
+
* allocates a fresh object.
|
|
130
|
+
*/
|
|
131
|
+
private _interpOut;
|
|
132
|
+
/**
|
|
133
|
+
* The compile-stable union of every frame's `flatVars` keys — the maximal
|
|
134
|
+
* key-set any `interpFrames` call can write. Fixed at `parse` (the keys
|
|
135
|
+
* never change across frames; a color-space renormalize re-derives the same
|
|
136
|
+
* carriers under the same keys). It is what `clearBuffer` null-fills to keep
|
|
137
|
+
* a reused buffer stale-free WITHOUT `delete` (F.W4 S1 — the V8 dictionary-
|
|
138
|
+
* mode trap the delete-loop fell into). Exposed (read-only) as `flatKeys`
|
|
139
|
+
* so the `AnimationGroup` can size its own composite buffer the same way.
|
|
49
140
|
*/
|
|
50
|
-
private
|
|
141
|
+
private _stableKeys;
|
|
142
|
+
/**
|
|
143
|
+
* The consumer's EXPLICIT constructor options (NOT merged with defaults) —
|
|
144
|
+
* retained so `fromString` can layer a parsed style-rule `animation`
|
|
145
|
+
* shorthand UNDER them (constructor-explicit wins over parsed-from-CSS, F.W8).
|
|
146
|
+
*/
|
|
147
|
+
protected _ctorOptions: Partial<InputAnimationOptions>;
|
|
148
|
+
/** The compile-stable union of this animation's interpolated keys. */
|
|
149
|
+
get flatKeys(): readonly string[];
|
|
150
|
+
/**
|
|
151
|
+
* The instance's ONE default DOM-style renderer, allocated once.
|
|
152
|
+
* "Did the consumer supply a custom transform?" is a reference
|
|
153
|
+
* comparison against this single value ({@link usesDefaultRenderer}) —
|
|
154
|
+
* typed and bind-proof, unlike a Symbol tag on a closure, which
|
|
155
|
+
* `Function.prototype.bind` silently drops.
|
|
156
|
+
*/
|
|
157
|
+
protected readonly _defaultTransform: TransformFunction<V>;
|
|
158
|
+
/** True when `fn` is this instance's default DOM-style renderer. */
|
|
159
|
+
usesDefaultRenderer(fn: TransformFunction<V> | undefined): boolean;
|
|
51
160
|
private dispatchAnimationEvent;
|
|
52
161
|
constructor(options?: Partial<InputAnimationOptions>, targets?: HTMLElement[] | HTMLElement | undefined, name?: string | undefined, superKey?: string | undefined);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
162
|
+
get templateFrames(): TemplateAnimationFrame<V>[];
|
|
163
|
+
set templateFrames(value: TemplateAnimationFrame<V>[]);
|
|
164
|
+
get parsedVars(): ParsedVarMap[];
|
|
165
|
+
get frames(): AnimationFrame<V>[];
|
|
166
|
+
get frameId(): number;
|
|
167
|
+
/** Append a template frame (delegated to the compiler). Chainable. */
|
|
168
|
+
addFrame<K extends V>(start: number | string | ValueUnit<number>, vars: Partial<K>, transform?: TransformFunction<K>, timingFunction?: InputAnimationOptions["timingFunction"]): Animation_2<K>;
|
|
169
|
+
/** Compile the template frames into the sampled `frames[]`. Chainable. */
|
|
170
|
+
parse(): this;
|
|
56
171
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
172
|
+
* Recompute `_stableKeys` — the union of every compiled frame's `flatVars`
|
|
173
|
+
* keys — after a (re)compile. The maximal key-set the `clearBuffer`
|
|
174
|
+
* null-fill resets, so a reused interpolation buffer stays in V8
|
|
175
|
+
* fast-properties mode without ever calling `delete` (F.W4 S1).
|
|
60
176
|
*/
|
|
61
|
-
private
|
|
177
|
+
private computeStableKeys;
|
|
62
178
|
/**
|
|
63
|
-
*
|
|
64
|
-
* For each variable at frame `ix`, find the next frame that also
|
|
65
|
-
* defines that variable and create an interpolation segment between them.
|
|
179
|
+
* Option setters — the fail-explicit contract.
|
|
66
180
|
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
181
|
+
* Genuine omission (`undefined`/`null`) means "use the default" and is
|
|
182
|
+
* always accepted; present-but-malformed input THROWS a typed
|
|
183
|
+
* `AnimationOptionError` naming the option and the offending value.
|
|
184
|
+
* This is the same posture the layer API chose ("silent no-ops were
|
|
185
|
+
* hiding consumer bugs") applied to the whole options surface — no
|
|
186
|
+
* silent fallback, no silently-preserved previous value.
|
|
69
187
|
*/
|
|
70
|
-
reconcileVars(ix: number, varIndex: Map<string, number[]>): void;
|
|
71
|
-
parse(): this;
|
|
72
188
|
setTimingFunction(timingFunction: InputAnimationOptions["timingFunction"]): this;
|
|
73
189
|
setIterationCount(iterationCount: InputAnimationOptions["iterationCount"]): this;
|
|
74
190
|
setDuration(duration: InputAnimationOptions["duration"]): this;
|
|
@@ -83,6 +199,17 @@ declare class Animation_2<V extends Vars = any> {
|
|
|
83
199
|
reverse(): this;
|
|
84
200
|
fillForwards(): void;
|
|
85
201
|
fillBackwards(): void;
|
|
202
|
+
/**
|
|
203
|
+
* Where the playhead rests after a completed play — derived ONCE from
|
|
204
|
+
* `fillMode` (forwards/both → final; none/backwards → initial). This is
|
|
205
|
+
* the explicit rest-position contract: completion paints the rest frame
|
|
206
|
+
* per this derivation, and the reduced-motion snap is "rest = final,
|
|
207
|
+
* paint it, settle" — the same path a `fillMode: forwards` completion
|
|
208
|
+
* takes, not a separate code path.
|
|
209
|
+
*/
|
|
210
|
+
get restPosition(): "initial" | "final";
|
|
211
|
+
/** Paint the rest frame per the fill contract. */
|
|
212
|
+
paintRest(): void;
|
|
86
213
|
/**
|
|
87
214
|
* Stateless progress query. Maps [0,1] from first keyframe to last,
|
|
88
215
|
* regardless of playback direction. `apply=true` invokes transform callbacks.
|
|
@@ -104,37 +231,117 @@ declare class Animation_2<V extends Vars = any> {
|
|
|
104
231
|
* zero-allocation steady-state playback.
|
|
105
232
|
* @returns Merged flat vars from all active frames
|
|
106
233
|
*/
|
|
107
|
-
interpFrames(t: number, transformFrames?: boolean, out?: Record<string, ValueUnit[]>): Record<string, ValueUnit
|
|
234
|
+
interpFrames(t: number, transformFrames?: boolean, out?: Record<string, ValueUnit[]>): Record<string, ValueUnit[]>;
|
|
235
|
+
/**
|
|
236
|
+
* Clear a reused interpolation buffer to a stale-free state WITHOUT
|
|
237
|
+
* `delete` — the V8-correct stable-key null-fill (F.W4 S1). The key-set is
|
|
238
|
+
* compile-stable (`_stableKeys` is the union of every frame's `flatVars`
|
|
239
|
+
* keys, fixed at `parse`), so null-filling it keeps the buffer in
|
|
240
|
+
* fast-properties mode AND zero-alloc. Inactive keys read back `undefined`;
|
|
241
|
+
* every consumer of a reused buffer (the group blend, the unused play-loop
|
|
242
|
+
* `_interpOut`) skips them — only the standalone return path (which never
|
|
243
|
+
* reuses a buffer) must be `undefined`-free, and it takes the alias / fresh
|
|
244
|
+
* merge above.
|
|
245
|
+
*/
|
|
246
|
+
private clearBuffer;
|
|
247
|
+
/**
|
|
248
|
+
* Interpolate ONE active frame at time `t` in place (lerp + optional
|
|
249
|
+
* transform). Lifted off the `interpFrames` hot loop so playback allocates
|
|
250
|
+
* no per-frame closure. A zero-width frame (`start === stop`, a degenerate
|
|
251
|
+
* keyframe pair) snaps to the endpoint instead of dividing by zero in
|
|
252
|
+
* `scale` (E-RT-5). The merge into the result buffer is done by the caller
|
|
253
|
+
* (F.W4 S3 — so the single-frame path can alias `flatVars` with no copy).
|
|
254
|
+
*/
|
|
255
|
+
private processFrame;
|
|
108
256
|
onStart(): Promise<void>;
|
|
109
257
|
onEnd(): Promise<void>;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
258
|
+
/**
|
|
259
|
+
* Advance the playhead to absolute clock `t` (a rAF timestamp, NOT a
|
|
260
|
+
* delta). Lazily runs `onStart` on the first call, reconciles the
|
|
261
|
+
* pause/resume clock, and ends the iteration once `t` reaches the
|
|
262
|
+
* duration. This is the DRIVER-layer advance — the one meaning of the
|
|
263
|
+
* absolute-clock step, distinct from the `tickDt(dt)` stepper surface
|
|
264
|
+
* the rest of the engine canonicalized to.
|
|
265
|
+
*/
|
|
266
|
+
advanceTo(t: number): Promise<number>;
|
|
267
|
+
/**
|
|
268
|
+
* One frame of the standalone rAF play path, driven by the shared
|
|
269
|
+
* `RAFPlayback.loop`. Returns whether the loop should continue.
|
|
270
|
+
*/
|
|
271
|
+
private _frame;
|
|
272
|
+
private _resolvePlay;
|
|
273
|
+
/** Internal rAF-based play loop — loop ownership rides `this.playback`. */
|
|
113
274
|
private _playRAF;
|
|
114
275
|
/**
|
|
115
276
|
* Play via the Web Animations API. WAAPI handles visuals on the
|
|
116
|
-
* compositor thread; a shadow
|
|
117
|
-
* `
|
|
118
|
-
* lifecycle state stay coherent with the
|
|
277
|
+
* compositor thread; a shadow loop in `playWAAPI` (riding
|
|
278
|
+
* `this.playback`) drives `advanceTo()` so events, iteration count,
|
|
279
|
+
* pause/resume, and other lifecycle state stay coherent with the
|
|
280
|
+
* rAF path.
|
|
119
281
|
*
|
|
120
282
|
* No silent fallback — eligibility is decided once in `play()`
|
|
121
283
|
* before this is invoked, and runtime errors propagate.
|
|
122
284
|
*/
|
|
123
285
|
private _playWAAPI;
|
|
124
286
|
/**
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
287
|
+
* Cancel the live WAAPI compositor animations (if any). Cancelling
|
|
288
|
+
* rejects each `wa.finished`, which `playWAAPI` catches as a halt — so
|
|
289
|
+
* this both stops the compositor paint AND unblocks the awaited play
|
|
290
|
+
* promise. No-op on the rAF path.
|
|
291
|
+
*/
|
|
292
|
+
private _cancelWAAPI;
|
|
293
|
+
/**
|
|
294
|
+
* `prefers-reduced-motion` snap: rest = final, paint it, settle — the
|
|
295
|
+
* SAME terminal path a `fillMode: forwards` completion takes, with the
|
|
296
|
+
* motion elided. The lifecycle stays observable (`animationstart` →
|
|
297
|
+
* final paint → `animationend`) so consumers' event wiring is identical
|
|
298
|
+
* to a completed normal play.
|
|
129
299
|
*/
|
|
130
300
|
private _playReducedMotion;
|
|
301
|
+
/**
|
|
302
|
+
* Mid-flight reduced-motion snap (D-LIB-3). A running rAF loop detected a
|
|
303
|
+
* live flip to `reduce`; converge to the rest frame and resolve the
|
|
304
|
+
* in-flight `play()` exactly as a forwards completion would. Distinct from
|
|
305
|
+
* `_playReducedMotion` (the up-front gate) only in that `animationstart`
|
|
306
|
+
* already fired — so here we paint final, mark done, end, settle, and
|
|
307
|
+
* release the awaiter. The WAAPI lane snaps via the same path: the up-front
|
|
308
|
+
* gate already routes reduced-motion away from WAAPI, and a live flip on a
|
|
309
|
+
* WAAPI animation cancels the compositor handles before settling.
|
|
310
|
+
*/
|
|
311
|
+
private _snapToReducedMotion;
|
|
131
312
|
play(): Promise<void>;
|
|
132
|
-
|
|
313
|
+
/**
|
|
314
|
+
* Pause playback — idempotent. Pausing an already-paused (or
|
|
315
|
+
* not-yet-started) animation is a no-op, never a resume: a method named
|
|
316
|
+
* `pause` pauses. Use {@link resume} for the explicit resume.
|
|
317
|
+
*/
|
|
318
|
+
pause(): this;
|
|
133
319
|
resume(): this;
|
|
320
|
+
/** The explicit flip: pauses if playing, resumes if paused. */
|
|
321
|
+
toggle(): this;
|
|
322
|
+
/**
|
|
323
|
+
* Halt playback where it stands: cancel the loop AND the WAAPI
|
|
324
|
+
* compositor animations, settle state, and resolve any pending `play()`
|
|
325
|
+
* promise. Never paints — `reset()` is the explicit rewind.
|
|
326
|
+
*/
|
|
134
327
|
stop(): void;
|
|
135
328
|
playing(): boolean;
|
|
136
329
|
/** Returns the effective time accounting for direction reversal. */
|
|
137
330
|
get effectiveT(): number;
|
|
331
|
+
/**
|
|
332
|
+
* Pure state teardown — flags, clocks, iteration. NEVER paints. This is
|
|
333
|
+
* the terminal half of the rest-position contract: completion paints
|
|
334
|
+
* the rest frame (via `onEnd` → `paintRest`) and then settles; the
|
|
335
|
+
* reduced-motion snap paints final and then settles. Settling is
|
|
336
|
+
* orthogonal to where the pixels rest.
|
|
337
|
+
*/
|
|
338
|
+
settle(): this;
|
|
339
|
+
/**
|
|
340
|
+
* Explicit rewind: paint the INITIAL frame, then settle. This is the
|
|
341
|
+
* user-facing "return to start" — rest position `initial`, painted
|
|
342
|
+
* deliberately — distinct from `settle()`, which tears down state and
|
|
343
|
+
* leaves the pixels where they rest.
|
|
344
|
+
*/
|
|
138
345
|
reset(): this;
|
|
139
346
|
setTargets(...targets: HTMLElement[]): this;
|
|
140
347
|
group(...animations: Animation_2<V>[]): AnimationGroup<V>;
|
|
@@ -156,6 +363,18 @@ export declare interface AnimationEngine {
|
|
|
156
363
|
getAnimationId: (animation: Animation_2 | string) => string;
|
|
157
364
|
getTimingFunction: (timingFunction: TimingFunction | TimingFunctionNames | string | undefined) => TimingFunction | undefined;
|
|
158
365
|
resolveKeyframes: (input: string | Stylesheet) => ResolvedKeyframes;
|
|
366
|
+
/** The single-call front door — dispatch + auto-target + auto-play. */
|
|
367
|
+
animate: typeof animate;
|
|
368
|
+
/** CSS-native MotionPath (F.W12) — offset-distance over an author offset-path. */
|
|
369
|
+
MotionPath: typeof MotionPath;
|
|
370
|
+
fromMotionPath: typeof fromMotionPath;
|
|
371
|
+
/**
|
|
372
|
+
* The preset library (`fadeIn`, `bounce`, `shake`, …) — heavy (each returns
|
|
373
|
+
* a `CSSKeyframesAnimation`), so it rides the dynamic boundary as a namespace
|
|
374
|
+
* instead of the light static barrel: `const { presets } = await
|
|
375
|
+
* loadAnimationEngine(); presets.fadeIn({ duration: 500 })` (F.W11).
|
|
376
|
+
*/
|
|
377
|
+
presets: typeof AnimationPresets;
|
|
159
378
|
DIRECTIONS: readonly AnimationOptions["direction"][];
|
|
160
379
|
FILL_MODES: readonly AnimationOptions["fillMode"][];
|
|
161
380
|
defaultOptions: AnimationOptions;
|
|
@@ -185,7 +404,7 @@ export declare interface AnimationFrame<V extends Vars> {
|
|
|
185
404
|
*/
|
|
186
405
|
allInterpVars: Array<InterpolatedVar<V>>;
|
|
187
406
|
transform: TransformFunction<V>;
|
|
188
|
-
timingFunction:
|
|
407
|
+
timingFunction: Easing;
|
|
189
408
|
}
|
|
190
409
|
|
|
191
410
|
export declare class AnimationGroup<V extends Vars> {
|
|
@@ -202,7 +421,7 @@ export declare class AnimationGroup<V extends Vars> {
|
|
|
202
421
|
*/
|
|
203
422
|
respectReducedMotion: boolean;
|
|
204
423
|
/**
|
|
205
|
-
* Children-per-slice before `
|
|
424
|
+
* Children-per-slice before `advanceTo()` yields to the main thread. Groups at
|
|
206
425
|
* or under this size tick in one slice (fast path); larger groups tick in
|
|
207
426
|
* batches with a `scheduler.yield()` between them so a big per-frame
|
|
208
427
|
* composite doesn't run as one long task (INP relief).
|
|
@@ -210,19 +429,38 @@ export declare class AnimationGroup<V extends Vars> {
|
|
|
210
429
|
static readonly YIELD_BATCH = 32;
|
|
211
430
|
singleTarget: boolean;
|
|
212
431
|
lastTickTime: number;
|
|
213
|
-
|
|
432
|
+
/** THE rAF owner for the group's draw loop. */
|
|
433
|
+
readonly playback: RAFPlayback;
|
|
214
434
|
resolvePromise: ((value: void | PromiseLike<void>) => void) | null;
|
|
435
|
+
private _playingPromise;
|
|
215
436
|
/**
|
|
216
|
-
* Pre-bound
|
|
217
|
-
* creating a new closure on every
|
|
437
|
+
* Pre-bound frame callback — allocated once in constructor to avoid
|
|
438
|
+
* creating a new closure on every playback loop start.
|
|
218
439
|
*/
|
|
219
|
-
private
|
|
440
|
+
private _boundFrame;
|
|
220
441
|
/**
|
|
221
442
|
* Cached entries array, sorted by layer zIndex. Rebuilt on demand
|
|
222
443
|
* via dirty flag to avoid Object.values() allocation on every frame.
|
|
223
444
|
*/
|
|
224
445
|
private _entries;
|
|
225
446
|
private _entriesDirty;
|
|
447
|
+
/**
|
|
448
|
+
* Long-lived composite buffer, cleared in place at the top of
|
|
449
|
+
* `transformFramesGrouped` (the same zero-alloc idiom `interpFrames`'s
|
|
450
|
+
* `out` buffer already uses). With it the compositor honours the class's
|
|
451
|
+
* own zero-alloc discipline — no fresh `groupedValues` object, and no
|
|
452
|
+
* per-layer `filteredValues` object, allocated per frame.
|
|
453
|
+
*/
|
|
454
|
+
private _grouped;
|
|
455
|
+
/**
|
|
456
|
+
* The compile-stable union of every child's contributed (whitelist-filtered)
|
|
457
|
+
* keys — what `_grouped` is null-filled to each frame so the composite is
|
|
458
|
+
* cleared WITHOUT `delete` (F.W4 S2: the delete-loop trapped `_grouped` in
|
|
459
|
+
* V8 dictionary mode). Recomputed only when the entry set / a layer
|
|
460
|
+
* whitelist changes (via `invalidateEntries`); stable across frames.
|
|
461
|
+
*/
|
|
462
|
+
private _groupedKeys;
|
|
463
|
+
private _groupedKeysDirty;
|
|
226
464
|
constructor(...inputs: (Animation_2<V> | AnimationGroupInput<V>)[]);
|
|
227
465
|
/**
|
|
228
466
|
* Returns the animation entries sorted by layer zIndex.
|
|
@@ -233,6 +471,16 @@ export declare class AnimationGroup<V extends Vars> {
|
|
|
233
471
|
private getEntries;
|
|
234
472
|
/** Mark entries cache stale. Called at all mutation boundaries. */
|
|
235
473
|
private invalidateEntries;
|
|
474
|
+
/**
|
|
475
|
+
* Recompute `_groupedKeys` — the union of each child's contributed keys
|
|
476
|
+
* (whitelist-filtered when the layer carries one). The maximal key-set the
|
|
477
|
+
* `transformFramesGrouped` null-fill clears, so the composite buffer stays
|
|
478
|
+
* in V8 fast-properties mode without `delete` (F.W4 S2). Children are parsed
|
|
479
|
+
* (their `flatKeys` populated) before the first composite — the group only
|
|
480
|
+
* blends during play, after child setup — and any later structural change
|
|
481
|
+
* re-dirties through `invalidateEntries`.
|
|
482
|
+
*/
|
|
483
|
+
private computeGroupedKeys;
|
|
236
484
|
setSuperKey(superKey: string): this;
|
|
237
485
|
setTargets(...targets: HTMLElement[]): this;
|
|
238
486
|
onStart(): this;
|
|
@@ -268,53 +516,83 @@ export declare class AnimationGroup<V extends Vars> {
|
|
|
268
516
|
*/
|
|
269
517
|
setChildTime(nameOrAnim: string | Animation_2<V>, t: number): this;
|
|
270
518
|
/**
|
|
271
|
-
* Advance all child animations to
|
|
272
|
-
* Awaits all child
|
|
519
|
+
* Advance all child animations to absolute clock `t`.
|
|
520
|
+
* Awaits all child advanceTo() promises so deferred state updates
|
|
273
521
|
* (startTime, this.t) resolve before interpFrames reads them.
|
|
274
522
|
*/
|
|
275
|
-
|
|
276
|
-
/** Advance one slice of children to
|
|
277
|
-
private
|
|
523
|
+
advanceTo(t: number): Promise<this>;
|
|
524
|
+
/** Advance one slice of children to absolute clock `t`, awaiting them together. */
|
|
525
|
+
private _advanceSlice;
|
|
278
526
|
/**
|
|
279
|
-
*
|
|
527
|
+
* One frame of the group's draw loop, driven by the shared
|
|
528
|
+
* `RAFPlayback.loop`. Ticks all children, then renders
|
|
280
529
|
* (single-target: grouped blending; multi-target: per-child).
|
|
281
|
-
*
|
|
530
|
+
* Returns whether the loop should continue.
|
|
282
531
|
*/
|
|
283
|
-
|
|
532
|
+
private _frame;
|
|
533
|
+
private _resolvePlay;
|
|
284
534
|
/**
|
|
285
535
|
* Start the animation group. Returns a promise that resolves
|
|
286
536
|
* when all child animations complete (or on explicit stop/reset).
|
|
537
|
+
* Re-entrant: a `play()` while one is in flight returns the same
|
|
538
|
+
* promise rather than leaking a second draw loop.
|
|
287
539
|
*
|
|
288
540
|
* Under `respectReducedMotion` + an active `prefers-reduced-motion`
|
|
289
541
|
* query, snaps every child to its final frame in a single composite —
|
|
290
542
|
* no rAF draw loop — then settles exactly as a completed play would.
|
|
291
543
|
*/
|
|
292
|
-
play(): Promise<
|
|
544
|
+
play(): Promise<void>;
|
|
293
545
|
/**
|
|
294
|
-
* `prefers-reduced-motion` snap for the group:
|
|
295
|
-
*
|
|
296
|
-
*
|
|
297
|
-
*
|
|
546
|
+
* `prefers-reduced-motion` snap for the group: rest = final, paint it,
|
|
547
|
+
* settle — the SAME terminal path a completed play takes, with the
|
|
548
|
+
* motion elided. Every child advances to its final frame, one composite
|
|
549
|
+
* paints, and `settle()` (pure teardown, never a repaint) readies the
|
|
550
|
+
* group for replay. The final frame stays on the target(s), matching
|
|
298
551
|
* `Animation._playReducedMotion`.
|
|
299
|
-
*
|
|
300
|
-
* Deliberately does NOT route through `reset()` — `reset()` repaints every
|
|
301
|
-
* child to frame 0 (`interpFrames(0, true)`, the fillBackwards
|
|
302
|
-
* cube-cutoff workaround), which would clobber the snapped final frame and
|
|
303
|
-
* leave, e.g., a `fadeIn` group invisible. The child `Animation.reset()`
|
|
304
|
-
* clears state flags only and does not repaint, so it is safe here.
|
|
305
552
|
*/
|
|
306
553
|
private _playReducedMotion;
|
|
307
554
|
/**
|
|
308
|
-
*
|
|
309
|
-
*
|
|
310
|
-
*
|
|
555
|
+
* Pause the group — idempotent. Pausing an already-paused (or
|
|
556
|
+
* not-yet-started) group is a no-op, NOT a resume. Mirrors
|
|
557
|
+
* `Animation.pause`: a method named `pause` pauses, never secretly
|
|
558
|
+
* resumes. Use {@link toggle} for the explicit flip, {@link resume}
|
|
559
|
+
* for the explicit resume.
|
|
311
560
|
*
|
|
312
|
-
*
|
|
313
|
-
* frame snapshot so the visual
|
|
314
|
-
*
|
|
561
|
+
* Cancels the rAF loop immediately (don't wait for the frame callback to
|
|
562
|
+
* self-terminate) and renders a final-frame snapshot so the visual
|
|
563
|
+
* matches the exact pause moment.
|
|
315
564
|
*/
|
|
316
565
|
pause(): this;
|
|
566
|
+
/**
|
|
567
|
+
* Resume the group — idempotent. Resuming a running (or not-yet-started)
|
|
568
|
+
* group is a no-op. Unpauses every child DIRECTLY (not via
|
|
569
|
+
* `child.resume()`, which would start each child's own rAF loop) — the
|
|
570
|
+
* group's draw loop owns the ticking — and re-registers that loop.
|
|
571
|
+
*/
|
|
572
|
+
resume(): this;
|
|
573
|
+
/** The explicit flip: pauses if playing, resumes if paused. */
|
|
574
|
+
toggle(): this;
|
|
575
|
+
/**
|
|
576
|
+
* Pure state teardown — never paints. The group analogue of
|
|
577
|
+
* `Animation.settle()`: releases every child (`managed = false`,
|
|
578
|
+
* `child.settle()`) and clears the group's own playback flags.
|
|
579
|
+
* Completion and the reduced-motion snap both end here, leaving the
|
|
580
|
+
* rest frame (per each child's fill contract) on the target(s).
|
|
581
|
+
*/
|
|
582
|
+
settle(): this;
|
|
583
|
+
/**
|
|
584
|
+
* Explicit rewind: paint every started child back to its INITIAL
|
|
585
|
+
* frame, then settle. This is the user-facing "return to start" —
|
|
586
|
+
* rest position `initial` painted deliberately, not a completion side
|
|
587
|
+
* effect. (Completion does NOT come here; it settles where the fill
|
|
588
|
+
* contract rested the pixels.)
|
|
589
|
+
*/
|
|
317
590
|
reset(): this;
|
|
591
|
+
/**
|
|
592
|
+
* Halt the draw loop, rewind to the initial frame (the transport-stop
|
|
593
|
+
* semantic the demo's controls expect), and resolve any pending
|
|
594
|
+
* `play()` promise.
|
|
595
|
+
*/
|
|
318
596
|
stop(): this;
|
|
319
597
|
playing(): boolean;
|
|
320
598
|
forcePause(): void;
|
|
@@ -352,7 +630,12 @@ export declare interface AnimationLayerConfig {
|
|
|
352
630
|
zIndex: number;
|
|
353
631
|
/** 0–1 for 'weighted' blend mode. Default: 1 */
|
|
354
632
|
weight: number;
|
|
355
|
-
/**
|
|
633
|
+
/**
|
|
634
|
+
* Default: 'replace'. Defaulting on a genuinely-omitted blend mode is
|
|
635
|
+
* the sanctioned contract (the fail-explicit seam throws only on
|
|
636
|
+
* malformed PRESENT input, never on omission) — an unspecified layer
|
|
637
|
+
* blends by replacement, the least-surprising composite.
|
|
638
|
+
*/
|
|
356
639
|
blendMode: BlendMode;
|
|
357
640
|
/** Layer toggle. Default: true */
|
|
358
641
|
enabled: boolean;
|
|
@@ -360,13 +643,33 @@ export declare interface AnimationLayerConfig {
|
|
|
360
643
|
properties?: Set<string>;
|
|
361
644
|
}
|
|
362
645
|
|
|
646
|
+
/**
|
|
647
|
+
* Typed option-validation errors — the fail-explicit seam.
|
|
648
|
+
*
|
|
649
|
+
* The engine's option setters and the light engines' easing inputs THROW on
|
|
650
|
+
* malformed input rather than silently defaulting or no-oping — the posture
|
|
651
|
+
* the layer API already chose ("silent no-ops were hiding consumer bugs",
|
|
652
|
+
* `group.ts` setLayerConfig). Defaulting happens only for genuine
|
|
653
|
+
* `undefined`: an omitted option means "use the default"; a
|
|
654
|
+
* present-but-malformed option is a consumer bug and surfaces as one of
|
|
655
|
+
* these.
|
|
656
|
+
*
|
|
657
|
+
* Value.js-free: light modules import these without touching the boundary.
|
|
658
|
+
*/
|
|
659
|
+
/** Thrown when an animation option receives malformed (non-undefined) input. */
|
|
660
|
+
export declare class AnimationOptionError extends Error {
|
|
661
|
+
readonly option: string;
|
|
662
|
+
readonly value: unknown;
|
|
663
|
+
constructor(option: string, value: unknown, reason: string);
|
|
664
|
+
}
|
|
665
|
+
|
|
363
666
|
export declare type AnimationOptions = {
|
|
364
667
|
duration: number;
|
|
365
668
|
delay: number;
|
|
366
669
|
iterationCount: number;
|
|
367
670
|
direction: (typeof DIRECTIONS)[number];
|
|
368
671
|
fillMode: (typeof FILL_MODES)[number];
|
|
369
|
-
timingFunction:
|
|
672
|
+
timingFunction: Easing;
|
|
370
673
|
useWAAPI: boolean;
|
|
371
674
|
/**
|
|
372
675
|
* When true, honor `prefers-reduced-motion: reduce` by snapping the
|
|
@@ -379,10 +682,106 @@ export declare type AnimationOptions = {
|
|
|
379
682
|
hueMethod?: HueInterpolationMethod;
|
|
380
683
|
};
|
|
381
684
|
|
|
685
|
+
declare namespace AnimationPresets {
|
|
686
|
+
export {
|
|
687
|
+
fadeIn,
|
|
688
|
+
fadeOut,
|
|
689
|
+
pulse,
|
|
690
|
+
shake,
|
|
691
|
+
bounce,
|
|
692
|
+
flip_2 as flip,
|
|
693
|
+
rotateIn,
|
|
694
|
+
slideIn,
|
|
695
|
+
heartbeat,
|
|
696
|
+
glow,
|
|
697
|
+
typewriter,
|
|
698
|
+
rainbowText,
|
|
699
|
+
warpLeft,
|
|
700
|
+
warpRight,
|
|
701
|
+
blurIn,
|
|
702
|
+
blurOut,
|
|
703
|
+
blurInOut,
|
|
704
|
+
progressBar,
|
|
705
|
+
skeletonLoading,
|
|
706
|
+
textFocusBlur,
|
|
707
|
+
gradientBackground,
|
|
708
|
+
rotateScale,
|
|
709
|
+
typingCursor,
|
|
710
|
+
accordionExpand,
|
|
711
|
+
notificationBounce,
|
|
712
|
+
spinner,
|
|
713
|
+
parallaxScroll,
|
|
714
|
+
slideInLeftKeyframes,
|
|
715
|
+
slideInLeft,
|
|
716
|
+
slideOutLeft,
|
|
717
|
+
slideInRightKeyframes,
|
|
718
|
+
slideInRight,
|
|
719
|
+
slideOutRight,
|
|
720
|
+
hover,
|
|
721
|
+
jumpUp,
|
|
722
|
+
jumpDown,
|
|
723
|
+
springScaleIn,
|
|
724
|
+
springSlideIn,
|
|
725
|
+
springPop,
|
|
726
|
+
springWobble,
|
|
727
|
+
enterPresets,
|
|
728
|
+
exitPresets,
|
|
729
|
+
attentionPresets,
|
|
730
|
+
loopPresets,
|
|
731
|
+
presetTaxonomy
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
/** Attention animations — a one-shot nudge to draw the eye. */
|
|
736
|
+
declare const attentionPresets: {
|
|
737
|
+
readonly pulse: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
738
|
+
readonly shake: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
739
|
+
readonly bounce: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
740
|
+
readonly flip: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
741
|
+
readonly notificationBounce: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
742
|
+
readonly springPop: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
743
|
+
readonly springWobble: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
744
|
+
};
|
|
745
|
+
|
|
382
746
|
export declare type BlendMode = "replace" | "add" | "weighted";
|
|
383
747
|
|
|
748
|
+
declare const blurIn: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
749
|
+
|
|
750
|
+
declare const blurInOut: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
751
|
+
|
|
752
|
+
declare const blurOut: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
753
|
+
|
|
754
|
+
declare const bounce: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
755
|
+
|
|
756
|
+
/**
|
|
757
|
+
* Feature-detect (`"ScrollTimeline" in window` / `"ViewTimeline" in window`)
|
|
758
|
+
* and construct a NATIVE `AnimationTimeline` for the additive WAAPI scroll
|
|
759
|
+
* bridge (D-LIB-2 / F-5). Returns `null` where the platform lacks the API
|
|
760
|
+
* (Firefox today, SSR, jsdom) — the caller then keeps the JS {@link Timeline}
|
|
761
|
+
* sampler, which is the proven fallback AND the only general driver over
|
|
762
|
+
* non-DOM targets.
|
|
763
|
+
*
|
|
764
|
+
* CRITICAL — the ARCH-kill HOLDS: this does NOT replace the JS sampler. Native
|
|
765
|
+
* scroll-driven is Chromium-only / not-Baseline, and the JS `Timeline` is a
|
|
766
|
+
* strictly more general caller-polled sampler (it also applies `SmoothProgress`
|
|
767
|
+
* smoothing + boundary snap the native `animation-range` path has none of). The
|
|
768
|
+
* bridge is a pure additive fast lane where supported + eligible. No polyfill.
|
|
769
|
+
*
|
|
770
|
+
* Light: a runtime `in`-detect over the `window` globals — zero static
|
|
771
|
+
* value.js / engine edge, so importing this keeps `timeline.ts` light.
|
|
772
|
+
*/
|
|
773
|
+
export declare function createNativeTimeline(spec: NativeTimelineSpec): AnimationTimeline | null;
|
|
774
|
+
|
|
384
775
|
export declare class CSSKeyframesAnimation<V extends Vars> extends Animation_2<V> {
|
|
385
776
|
constructor(options?: Partial<InputAnimationOptions>, ...targets: HTMLElement[]);
|
|
777
|
+
/**
|
|
778
|
+
* One transform-resolution seam for the three `from*` entry points:
|
|
779
|
+
* a supplied transform is the consumer's renderer (vars arrive
|
|
780
|
+
* unflattened); genuine omission resolves to the instance's ONE
|
|
781
|
+
* default DOM-style renderer, which keeps WAAPI eligibility a
|
|
782
|
+
* reference comparison (`usesDefaultRenderer`).
|
|
783
|
+
*/
|
|
784
|
+
private resolveTransform;
|
|
386
785
|
fromVars(vars: V[], transform?: TransformFunction<V>): this;
|
|
387
786
|
fromKeyframes(keyframes: Map<string, Partial<V>> | Record<string, Partial<V>>, transform?: TransformFunction<V>): this;
|
|
388
787
|
/**
|
|
@@ -394,11 +793,260 @@ export declare class CSSKeyframesAnimation<V extends Vars> extends Animation_2<V
|
|
|
394
793
|
*/
|
|
395
794
|
propertyRegistry: Map<string, PropertyDescriptor_2>;
|
|
396
795
|
fromString(keyframes: string, transform?: TransformFunction<V>): this;
|
|
796
|
+
/**
|
|
797
|
+
* Register every parsed `@property` descriptor with the UA via
|
|
798
|
+
* `CSS.registerProperty` (D-LIB-1) — one guarded pass at the end of
|
|
799
|
+
* `fromString`. Feature-detected (`CSS.registerProperty` may be absent:
|
|
800
|
+
* SSR, jsdom, older engines) so it no-ops to today's behaviour where
|
|
801
|
+
* unsupported. A duplicate-name re-registration throws a benign
|
|
802
|
+
* `InvalidModificationError` (the global registry is process-wide and
|
|
803
|
+
* idempotent for a given name) — swallowed per-descriptor so one already-
|
|
804
|
+
* registered name never aborts the rest of the pass.
|
|
805
|
+
*
|
|
806
|
+
* Baseline 2024-07-09 (newly available — feature-detect mandatory).
|
|
807
|
+
*/
|
|
808
|
+
private registerProperties;
|
|
397
809
|
transform(vars: V): void;
|
|
398
810
|
}
|
|
399
811
|
|
|
812
|
+
/**
|
|
813
|
+
* The closed-form frictional glide. Given a release `velocity` `v0`, an
|
|
814
|
+
* `initial` position `x0`, and a `friction` `k`, returns a pure sampler
|
|
815
|
+
* `(t) => { value, velocity }` evaluating
|
|
816
|
+
*
|
|
817
|
+
* x(t) = x0 + (v0 / k)·(1 − e^(−k·t))
|
|
818
|
+
* v(t) = v0·e^(−k·t)
|
|
819
|
+
*
|
|
820
|
+
* at any elapsed time `t` in SECONDS — the spring's native clock. `t ≤ 0`
|
|
821
|
+
* yields the seed state `(x0, v0)`. Allocation-free per call (one closure
|
|
822
|
+
* captured once); the returned function does no further allocation.
|
|
823
|
+
*
|
|
824
|
+
* @throws if `friction <= 0` — a non-positive coefficient has no finite
|
|
825
|
+
* resting point and is a programmer error, surfaced explicitly.
|
|
826
|
+
*/
|
|
827
|
+
export declare function decay(options: DecayOptions): (t: number) => DecaySample;
|
|
828
|
+
|
|
829
|
+
/**
|
|
830
|
+
* Frictional decay (inertial glide) — the one-line closed-form sibling of
|
|
831
|
+
* the spring solver, for the fling/flick case where there is no target to
|
|
832
|
+
* settle to, only an initial velocity bleeding off under friction.
|
|
833
|
+
*
|
|
834
|
+
* The model is a first-order velocity-proportional drag, `v'(t) = −k·v(t)`,
|
|
835
|
+
* whose closed-form position is
|
|
836
|
+
*
|
|
837
|
+
* x(t) = x0 + (v0 / k)·(1 − e^(−k·t))
|
|
838
|
+
*
|
|
839
|
+
* with velocity `v(t) = v0·e^(−k·t)`. As `t → ∞` the glide asymptotes to a
|
|
840
|
+
* finite resting point `x0 + v0/k` (the projected endpoint a release would
|
|
841
|
+
* coast to). Larger `k` → more friction → shorter glide.
|
|
842
|
+
*
|
|
843
|
+
* LIGHT module: zero static `@mkbabb/value.js` edge. Pure math — no rAF, no
|
|
844
|
+
* DOM, no allocation in the hot path. A richer canonical closed form is the
|
|
845
|
+
* value.js hand-off VJ-1; `decay` ships keyframes-local today and collapses
|
|
846
|
+
* to a thin caller once value.js publishes the canonical surface.
|
|
847
|
+
*/
|
|
848
|
+
/** Inputs to the {@link decay} frictional-glide closed form. */
|
|
849
|
+
export declare interface DecayOptions {
|
|
850
|
+
/** Starting position. Default 0. */
|
|
851
|
+
initial?: number;
|
|
852
|
+
/** Release velocity (units/s) — the flick speed handed off at release. */
|
|
853
|
+
velocity: number;
|
|
854
|
+
/**
|
|
855
|
+
* Friction coefficient (1/s). Strictly positive — larger means more
|
|
856
|
+
* drag and a shorter glide. Default 5.
|
|
857
|
+
*/
|
|
858
|
+
friction?: number;
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
/**
|
|
862
|
+
* The asymptotic resting point of a glide — the position a release of
|
|
863
|
+
* `velocity` from `initial` under `friction` coasts to as `t → ∞`
|
|
864
|
+
* (`x0 + v0/k`). The projected endpoint, useful for snap-to-target /
|
|
865
|
+
* paginated-fling decisions without running the loop.
|
|
866
|
+
*
|
|
867
|
+
* @throws if `friction <= 0` (see {@link decay}).
|
|
868
|
+
*/
|
|
869
|
+
export declare function decayRest(options: DecayOptions): number;
|
|
870
|
+
|
|
871
|
+
/** A sampled point on a decay glide: position + velocity at time `t`. */
|
|
872
|
+
export declare interface DecaySample {
|
|
873
|
+
/** Position `x(t) = x0 + v0/k·(1 − e^(−k·t))`. */
|
|
874
|
+
value: number;
|
|
875
|
+
/** Velocity `v(t) = v0·e^(−k·t)`. */
|
|
876
|
+
velocity: number;
|
|
877
|
+
}
|
|
878
|
+
|
|
400
879
|
declare const DIRECTIONS: readonly ["normal", "reverse", "alternate", "alternate-reverse"];
|
|
401
880
|
|
|
881
|
+
/**
|
|
882
|
+
* Functional sugar over {@link Draggable}: construct, `attach(element)`,
|
|
883
|
+
* and return the instance — the one-call front door for the common case.
|
|
884
|
+
* The returned `Draggable` exposes `.spring` (for `.play()` / fling-loop
|
|
885
|
+
* ownership), `.subscribe()`, `.value`/`.velocity`/`.settled`, and
|
|
886
|
+
* `.detach()`/`.dispose()`.
|
|
887
|
+
*/
|
|
888
|
+
export declare function drag(element: HTMLElement, options?: DragOptions): Draggable;
|
|
889
|
+
|
|
890
|
+
/**
|
|
891
|
+
* The single scalar axis a {@link Draggable} tracks. A 2-D drag composes
|
|
892
|
+
* two `Draggable`s (one per axis) — the engine stays one-dimensional, the
|
|
893
|
+
* caller owns the composition (KISS).
|
|
894
|
+
*/
|
|
895
|
+
export declare type DragAxis = "x" | "y";
|
|
896
|
+
|
|
897
|
+
/**
|
|
898
|
+
* A one-axis draggable: pointer-capture follow + release-velocity fling
|
|
899
|
+
* over a `SpringProgress`. The hard physics (a continuous analytic
|
|
900
|
+
* trajectory seeded from the release velocity) is the spring's; this class
|
|
901
|
+
* is the pointer-event plumbing that feeds it.
|
|
902
|
+
*
|
|
903
|
+
* Lifecycle: `attach(element)` binds `pointerdown`; a down captures the
|
|
904
|
+
* pointer and binds `pointermove`/`pointerup` for the gesture's duration;
|
|
905
|
+
* `up` re-seats the spring from `(value, releaseVelocity)` and lets it
|
|
906
|
+
* fling. `detach()` removes every listener and releases capture. The
|
|
907
|
+
* underlying spring is reachable via `.spring` for `.play()` /
|
|
908
|
+
* `.subscribe()` / fling-loop ownership.
|
|
909
|
+
*/
|
|
910
|
+
export declare class Draggable {
|
|
911
|
+
/** The spring the drag follows + flings — the physics core. */
|
|
912
|
+
readonly spring: SpringProgress;
|
|
913
|
+
private readonly axis;
|
|
914
|
+
private readonly transform;
|
|
915
|
+
private readonly velocityWindow;
|
|
916
|
+
private element;
|
|
917
|
+
private capturedPointerId;
|
|
918
|
+
/** Rolling pointer samples for release-velocity estimation. */
|
|
919
|
+
private samples;
|
|
920
|
+
private subscribers;
|
|
921
|
+
private springUnsub;
|
|
922
|
+
private readonly onPointerDown;
|
|
923
|
+
private readonly onPointerMove;
|
|
924
|
+
private readonly onPointerUp;
|
|
925
|
+
constructor(options?: DragOptions);
|
|
926
|
+
/** True while a pointer gesture is in progress (down, not yet up). */
|
|
927
|
+
get dragging(): boolean;
|
|
928
|
+
/** Current spring position. */
|
|
929
|
+
get value(): number;
|
|
930
|
+
/** Current spring velocity (units/s). */
|
|
931
|
+
get velocity(): number;
|
|
932
|
+
/** True once the post-release fling has settled. */
|
|
933
|
+
get settled(): boolean;
|
|
934
|
+
/**
|
|
935
|
+
* Bind the drag to `element`. Adds the `pointerdown` listener; the
|
|
936
|
+
* per-gesture `pointermove`/`pointerup` listeners are added on down and
|
|
937
|
+
* removed on up. Idempotent re-attach detaches the previous element
|
|
938
|
+
* first. Returns a detach handle (calling it is equivalent to
|
|
939
|
+
* {@link detach}).
|
|
940
|
+
*/
|
|
941
|
+
attach(element: HTMLElement): () => void;
|
|
942
|
+
/**
|
|
943
|
+
* Remove every listener, release any active pointer capture, and end an
|
|
944
|
+
* in-flight gesture. Leaves the spring's current state intact (a fling
|
|
945
|
+
* already in progress continues unless the caller stops it).
|
|
946
|
+
*/
|
|
947
|
+
detach(): void;
|
|
948
|
+
/**
|
|
949
|
+
* Subscribe to `(value, velocity)` emissions — both the live drag-
|
|
950
|
+
* follow and the post-release fling. Returns an unsubscribe handle.
|
|
951
|
+
* Lazily bridges to the spring's own subscription so the spring stays
|
|
952
|
+
* the single source of truth.
|
|
953
|
+
*/
|
|
954
|
+
subscribe(fn: DragSubscriber): () => void;
|
|
955
|
+
private emit;
|
|
956
|
+
/**
|
|
957
|
+
* Tear down: detach listeners + dispose the spring. After `dispose()`
|
|
958
|
+
* the draggable is inert.
|
|
959
|
+
*/
|
|
960
|
+
dispose(): void;
|
|
961
|
+
private coordOf;
|
|
962
|
+
private handleDown;
|
|
963
|
+
private handleMove;
|
|
964
|
+
private handleUp;
|
|
965
|
+
/**
|
|
966
|
+
* End the current gesture: release capture + remove the per-gesture
|
|
967
|
+
* listeners. Idempotent — safe when no gesture is active.
|
|
968
|
+
*/
|
|
969
|
+
private endGesture;
|
|
970
|
+
private pushSample;
|
|
971
|
+
/**
|
|
972
|
+
* Release velocity = average pointer velocity over the sample window,
|
|
973
|
+
* in units PER SECOND (the spring's clock). Estimated as `Δvalue / Δt`
|
|
974
|
+
* across the oldest and newest retained samples — robust to a single
|
|
975
|
+
* jittery last frame, unlike a two-point last-pair difference. Returns
|
|
976
|
+
* 0 when there is insufficient motion (a tap, or a held release).
|
|
977
|
+
*/
|
|
978
|
+
private estimateVelocity;
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
export declare interface DragOptions {
|
|
982
|
+
/**
|
|
983
|
+
* Which pointer axis drives the spring target — `clientX` (`"x"`) or
|
|
984
|
+
* `clientY` (`"y"`). Default `"x"`.
|
|
985
|
+
*/
|
|
986
|
+
axis?: DragAxis;
|
|
987
|
+
/**
|
|
988
|
+
* Map a raw pointer coordinate (px, in client space) to the spring's
|
|
989
|
+
* value domain. Default identity (track pointer pixels directly). Use
|
|
990
|
+
* e.g. `(px) => px - originPx` to track an offset, or a scale factor
|
|
991
|
+
* for a normalized [0, 1] domain.
|
|
992
|
+
*/
|
|
993
|
+
transform?: (clientCoord: number) => number;
|
|
994
|
+
/**
|
|
995
|
+
* The spring the drag drives. Supplies the physics — the fling on
|
|
996
|
+
* release re-seats THIS spring from `(currentValue, releaseVelocity)`.
|
|
997
|
+
* Defaults to a fresh `SpringProgress` with the engine defaults.
|
|
998
|
+
*/
|
|
999
|
+
spring?: SpringProgress;
|
|
1000
|
+
/**
|
|
1001
|
+
* Options for the default spring (ignored when `spring` is supplied).
|
|
1002
|
+
*/
|
|
1003
|
+
springOptions?: Partial<SpringProgressOptions>;
|
|
1004
|
+
/**
|
|
1005
|
+
* Velocity-sampling window in milliseconds. The release velocity is the
|
|
1006
|
+
* average pointer velocity over the last `velocityWindow` ms of moves —
|
|
1007
|
+
* a short window tracks flicks, a longer one smooths jitter. Default
|
|
1008
|
+
* 100ms.
|
|
1009
|
+
*/
|
|
1010
|
+
velocityWindow?: number;
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
/**
|
|
1014
|
+
* Drag / fling adapter — the INPUT layer over the already-SOTA spring
|
|
1015
|
+
* velocity core. It captures the pointer, tracks the drag as a live
|
|
1016
|
+
* `SpringProgress` target on every `pointermove`, samples the pointer
|
|
1017
|
+
* velocity over a short window, and on release hands that velocity to the
|
|
1018
|
+
* spring's re-seat (`SpringProgress` re-seats the closed-form solution from
|
|
1019
|
+
* `(x, v)` so the fling trajectory is continuous with the gesture).
|
|
1020
|
+
*
|
|
1021
|
+
* LIGHT module: zero static `@mkbabb/value.js` edge. The physics is
|
|
1022
|
+
* keyframes-local (the spring solver); this file is pure input plumbing.
|
|
1023
|
+
*
|
|
1024
|
+
* Framework-free by design — plain `addEventListener` + Pointer Capture
|
|
1025
|
+
* with explicit teardown. This is library code, not a Vue demo: a consumer
|
|
1026
|
+
* wires the returned `value`/`velocity`/`settled` reads (or `subscribe`)
|
|
1027
|
+
* into their own render layer. SSR-safe: construction does not touch the
|
|
1028
|
+
* DOM until `attach()`.
|
|
1029
|
+
*/
|
|
1030
|
+
/** A drag emission: the spring's current position + velocity. */
|
|
1031
|
+
export declare type DragSubscriber = (value: number, velocity: number) => void;
|
|
1032
|
+
|
|
1033
|
+
/**
|
|
1034
|
+
* The typed easing value — a callable curve plus, when one exists, the CSS
|
|
1035
|
+
* easing string that reproduces it (e.g. a spring's `linear()` stops).
|
|
1036
|
+
*
|
|
1037
|
+
* Replaces the former Symbol-on-a-closure side channel: the "this closure
|
|
1038
|
+
* has a CSS twin" fact now flows through the type system, so wrapping or
|
|
1039
|
+
* binding the callable can no longer silently drop it. `waapi.ts` reads
|
|
1040
|
+
* `.css` to run the true curve on the compositor; everything else reads
|
|
1041
|
+
* `.fn`.
|
|
1042
|
+
*/
|
|
1043
|
+
export declare interface Easing {
|
|
1044
|
+
/** The callable curve — the hot-path interpolation function. */
|
|
1045
|
+
fn: TimingFunction;
|
|
1046
|
+
/** CSS easing string that faithfully reproduces `fn`, when one exists. */
|
|
1047
|
+
css?: string;
|
|
1048
|
+
}
|
|
1049
|
+
|
|
402
1050
|
/**
|
|
403
1051
|
* Interpolate position and scale between two elements or rects.
|
|
404
1052
|
*
|
|
@@ -415,14 +1063,6 @@ export declare class ElementMorph {
|
|
|
415
1063
|
constructor(from: HTMLElement | MorphRect, to: HTMLElement | MorphRect, options?: ElementMorphOptions);
|
|
416
1064
|
/** Re-measure source and destination, rebuilding the internal animation. */
|
|
417
1065
|
measure(from: HTMLElement | MorphRect, to: HTMLElement | MorphRect): this;
|
|
418
|
-
/**
|
|
419
|
-
* Resolve a pending string easing *name* through the dynamic engine
|
|
420
|
-
* boundary. No-op for callable / omitted easing. Stateless `.at()` /
|
|
421
|
-
* `.toCSSTransform()` consumers that pass a name can `await .ready()`
|
|
422
|
-
* first to interpolate with the resolved easing; `.play()` awaits it
|
|
423
|
-
* automatically before the first frame.
|
|
424
|
-
*/
|
|
425
|
-
ready(): Promise<void>;
|
|
426
1066
|
/** Get raw transform values at the given progress [0, 1]. */
|
|
427
1067
|
at(progress: number): MorphValues;
|
|
428
1068
|
/** Get a CSS transform string at the given progress [0, 1]. */
|
|
@@ -442,27 +1082,200 @@ export declare class ElementMorph {
|
|
|
442
1082
|
|
|
443
1083
|
export declare interface ElementMorphOptions {
|
|
444
1084
|
/**
|
|
445
|
-
* Easing as a callable `TimingFunction
|
|
446
|
-
*
|
|
447
|
-
* `
|
|
448
|
-
*
|
|
449
|
-
* dynamic engine boundary on the first `.play()` (or `await .ready()`).
|
|
1085
|
+
* Easing as a callable `TimingFunction` or a typed `Easing` —
|
|
1086
|
+
* synchronous and value.js-free (`ElementMorph` composes
|
|
1087
|
+
* `NumericAnimation`, which enforces the same contract). Resolve a
|
|
1088
|
+
* string name first via `await resolveEasing(name)`.
|
|
450
1089
|
*/
|
|
451
|
-
timingFunction?: TimingFunction |
|
|
1090
|
+
timingFunction?: TimingFunction | Easing;
|
|
452
1091
|
/** Playback duration in milliseconds. Required for `.play()`. */
|
|
453
1092
|
duration?: number;
|
|
454
1093
|
transformOrigin?: string;
|
|
455
1094
|
}
|
|
456
1095
|
|
|
1096
|
+
/** Entrance animations — bring an element INTO view. */
|
|
1097
|
+
declare const enterPresets: {
|
|
1098
|
+
readonly fadeIn: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1099
|
+
readonly slideIn: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1100
|
+
readonly slideInLeft: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1101
|
+
readonly slideInRight: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1102
|
+
readonly rotateIn: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1103
|
+
readonly blurIn: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1104
|
+
readonly springScaleIn: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1105
|
+
readonly springSlideIn: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1106
|
+
readonly jumpUp: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1107
|
+
};
|
|
1108
|
+
|
|
1109
|
+
/** Exit animations — take an element OUT of view. */
|
|
1110
|
+
declare const exitPresets: {
|
|
1111
|
+
readonly fadeOut: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1112
|
+
readonly slideOutLeft: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1113
|
+
readonly slideOutRight: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1114
|
+
readonly blurOut: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1115
|
+
readonly warpLeft: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1116
|
+
readonly warpRight: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1117
|
+
readonly jumpDown: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1118
|
+
};
|
|
1119
|
+
|
|
1120
|
+
declare const fadeIn: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1121
|
+
|
|
1122
|
+
declare const fadeOut: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1123
|
+
|
|
457
1124
|
declare const FILL_MODES: readonly ["none", "forwards", "backwards", "both"];
|
|
458
1125
|
|
|
1126
|
+
/**
|
|
1127
|
+
* Animate a layout change on `element`: measure (First), run `mutate` (Last),
|
|
1128
|
+
* measure again, then invert + play the transform between them via
|
|
1129
|
+
* {@link ElementMorph}. Returns the play promise.
|
|
1130
|
+
*
|
|
1131
|
+
* @param element — the element whose layout `mutate` changes.
|
|
1132
|
+
* @param mutate — a synchronous DOM mutation (class toggle, reparent, …).
|
|
1133
|
+
* @param options — `{ duration, timingFunction, transformOrigin }`.
|
|
1134
|
+
*/
|
|
1135
|
+
export declare function flip(element: HTMLElement, mutate: () => void, options?: FlipOptions): Promise<void>;
|
|
1136
|
+
|
|
1137
|
+
declare const flip_2: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1138
|
+
|
|
1139
|
+
export declare interface FlipOptions {
|
|
1140
|
+
/** Playback duration in milliseconds. Defaults to `300`. */
|
|
1141
|
+
duration?: number;
|
|
1142
|
+
/**
|
|
1143
|
+
* Easing for the play phase — a callable {@link TimingFunction} or typed
|
|
1144
|
+
* {@link Easing} (e.g. `springTimingFunction(...)` for a springy FLIP).
|
|
1145
|
+
* A string name is rejected; resolve it via `await resolveEasing(name)`.
|
|
1146
|
+
*/
|
|
1147
|
+
timingFunction?: TimingFunction | Easing;
|
|
1148
|
+
transformOrigin?: string;
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
/**
|
|
1152
|
+
* Shared-element FLIP: animate element `a` onto the rect of element `b`
|
|
1153
|
+
* (Motion's `layoutId` / GSAP Flip shared-element style). Unlike `flip`, `a`
|
|
1154
|
+
* does NOT move in the DOM — it stays at its own rect (First) and the morph
|
|
1155
|
+
* carries it FORWARD onto `b`'s rect (Last). So this is a plain forward
|
|
1156
|
+
* {@link ElementMorph} play (identity at t=0 → full delta at t=1), not the
|
|
1157
|
+
* inversion `flip` runs.
|
|
1158
|
+
*
|
|
1159
|
+
* The two reads are batched — one forced layout each, before any write.
|
|
1160
|
+
*
|
|
1161
|
+
* @param a — the element to animate.
|
|
1162
|
+
* @param b — the element whose rect `a` morphs onto.
|
|
1163
|
+
* @param options — `{ duration, timingFunction, transformOrigin }`.
|
|
1164
|
+
*/
|
|
1165
|
+
export declare function flipShared(a: HTMLElement, b: HTMLElement, options?: FlipOptions): Promise<void>;
|
|
1166
|
+
|
|
1167
|
+
declare class FrameCompiler<V extends Vars = any> {
|
|
1168
|
+
private options;
|
|
1169
|
+
templateFrames: TemplateAnimationFrame<V>[];
|
|
1170
|
+
parsedVars: ParsedVarMap[];
|
|
1171
|
+
frames: AnimationFrame<V>[];
|
|
1172
|
+
/**
|
|
1173
|
+
* Next TEMPLATE frame id — a monotonic handle assigned in `addFrame`
|
|
1174
|
+
* (stable across re-parse, since `parse` does not re-add templates).
|
|
1175
|
+
* Compiled-frame ids are content-derived from `(startIx, stopIx)`
|
|
1176
|
+
* (see `createFrame`), NOT this counter, so `parse()` is idempotent.
|
|
1177
|
+
*/
|
|
1178
|
+
frameId: number;
|
|
1179
|
+
/**
|
|
1180
|
+
* The compile inputs live on the owning `Animation`'s `options` object.
|
|
1181
|
+
* The compiler holds a REFERENCE to it (the setters mutate it in place,
|
|
1182
|
+
* never replace it), so the NEXT compile always reads the current
|
|
1183
|
+
* `duration`/`easing`/`colorSpace` without re-linking. For values baked
|
|
1184
|
+
* into already-compiled frames, the setter triggers a targeted re-derive:
|
|
1185
|
+
* `setDuration` rescales `frame.time` in place; `setColorSpace`/
|
|
1186
|
+
* `setHueMethod` call {@link renormalizeColors} (the color resolution is
|
|
1187
|
+
* the only baked state that depends on them). No setter silently no-ops a
|
|
1188
|
+
* change to compiled state.
|
|
1189
|
+
*/
|
|
1190
|
+
constructor(options: AnimationOptions);
|
|
1191
|
+
convertFrameStart(frame: TemplateAnimationFrame<V>): TemplateAnimationFrame<V>;
|
|
1192
|
+
addFrame<K extends V>(start: number | string | ValueUnit<number>, vars: Partial<K>, transform?: TransformFunction<K>, timingFunction?: InputAnimationOptions["timingFunction"]): void;
|
|
1193
|
+
createFrame(startIx: number, endIx: number): AnimationFrame<V>;
|
|
1194
|
+
/**
|
|
1195
|
+
* Build an index mapping each variable name to the frame indices where
|
|
1196
|
+
* it appears. Used by reconcileVars() for O(1) "next occurrence" lookups
|
|
1197
|
+
* instead of O(N) findIndex scans per variable.
|
|
1198
|
+
*/
|
|
1199
|
+
private buildVarIndex;
|
|
1200
|
+
/**
|
|
1201
|
+
* Reconcile interpolation variables across non-adjacent keyframes.
|
|
1202
|
+
* For each variable at frame `ix`, find the next frame that also
|
|
1203
|
+
* defines that variable and create an interpolation segment between them.
|
|
1204
|
+
*
|
|
1205
|
+
* Uses a pre-built variable index (from buildVarIndex) to avoid
|
|
1206
|
+
* O(frames²) findIndex scans.
|
|
1207
|
+
*/
|
|
1208
|
+
reconcileVars(ix: number, varIndex: Map<string, number[]>): void;
|
|
1209
|
+
/**
|
|
1210
|
+
* Compile `templateFrames` into the sampled `frames[]`. `targets` is the
|
|
1211
|
+
* one DOM input — each parsed var is bound to it so computed-unit
|
|
1212
|
+
* resolution can read the live box. Pure otherwise.
|
|
1213
|
+
*/
|
|
1214
|
+
parse(targets: HTMLElement[]): void;
|
|
1215
|
+
/**
|
|
1216
|
+
* Derive a frame's `flatVars`/`vars`/`allInterpVars` from its
|
|
1217
|
+
* `interpVars` — the pre-flattened forms the hot path
|
|
1218
|
+
* (`interpFrames`) iterates without re-walking. Called once per frame
|
|
1219
|
+
* at the tail of `parse`, and again by `renormalizeColors` after a
|
|
1220
|
+
* color-space change re-derives the interp carriers in place.
|
|
1221
|
+
*/
|
|
1222
|
+
private finalizeFrameVars;
|
|
1223
|
+
/**
|
|
1224
|
+
* Re-derive the color-resolved interpolation carriers in place after a
|
|
1225
|
+
* `colorSpace`/`hueMethod` change on already-compiled frames. Only the
|
|
1226
|
+
* per-`InterpolatedVar` color resolution depends on the color space —
|
|
1227
|
+
* the flatten/sort/reconcile structure does not — so this re-runs
|
|
1228
|
+
* `createInterpVarValue` over the existing `frames`/`parsedVars` and
|
|
1229
|
+
* rebuilds the hot-path arrays, with NO re-flatten and NO re-sort. The
|
|
1230
|
+
* new carriers derive from the already-target-bound `parsedVars`, the
|
|
1231
|
+
* same provenance `parse` gives them, so DOM binding is preserved.
|
|
1232
|
+
*
|
|
1233
|
+
* The owning `Animation`'s `setColorSpace`/`setHueMethod` call this when
|
|
1234
|
+
* frames already exist; before `parse`, the option is simply read by the
|
|
1235
|
+
* next compile.
|
|
1236
|
+
*/
|
|
1237
|
+
renormalizeColors(): void;
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
/**
|
|
1241
|
+
* Build a CSS-native path-motion animation: set the author `offset-path` (and
|
|
1242
|
+
* optional `offset-rotate`) on the target(s), and sweep `offset-distance` from
|
|
1243
|
+
* → to. Returns the constructed {@link CSSKeyframesAnimation} as the control
|
|
1244
|
+
* handle (the `animate()` contract — `.play()` / `.pause()` / `.stop()` / the
|
|
1245
|
+
* awaitable play promise), consistent with the `from*` factory family.
|
|
1246
|
+
*
|
|
1247
|
+
* The returned animation passes the EXISTING WAAPI eligibility gate
|
|
1248
|
+
* (`isWAAPIEligible`) for a DOM target with a uniform CSS-twin easing, and
|
|
1249
|
+
* delegates compositor-thread via `playWAAPI` — no new eligibility predicate.
|
|
1250
|
+
*
|
|
1251
|
+
* @param target one or more DOM elements (or a single element) to move.
|
|
1252
|
+
* @param options `{ path, from?, to?, rotate?, ...animationOptions }`.
|
|
1253
|
+
*
|
|
1254
|
+
* @example
|
|
1255
|
+
* // Move a box along a quadratic path, facing along it, over 2s:
|
|
1256
|
+
* fromMotionPath(box, {
|
|
1257
|
+
* path: "path('M 0 0 Q 100 -100 200 0')",
|
|
1258
|
+
* rotate: "auto",
|
|
1259
|
+
* duration: 2000,
|
|
1260
|
+
* });
|
|
1261
|
+
*/
|
|
1262
|
+
declare function fromMotionPath<V extends Record<string, any> = any>(target: HTMLElement | HTMLElement[], options: MotionPathOptions): CSSKeyframesAnimation<V>;
|
|
1263
|
+
|
|
1264
|
+
declare const glow: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1265
|
+
|
|
1266
|
+
declare const gradientBackground: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1267
|
+
|
|
1268
|
+
declare const heartbeat: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1269
|
+
|
|
1270
|
+
declare const hover: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1271
|
+
|
|
459
1272
|
export declare type InputAnimationOptions = Partial<{
|
|
460
1273
|
duration: number | string;
|
|
461
1274
|
delay: number | string;
|
|
462
1275
|
iterationCount: number | string | "infinite" | undefined;
|
|
463
1276
|
direction: (typeof DIRECTIONS)[number];
|
|
464
1277
|
fillMode: (typeof FILL_MODES)[number];
|
|
465
|
-
timingFunction: TimingFunction | TimingFunctionNames | undefined;
|
|
1278
|
+
timingFunction: TimingFunction | Easing | TimingFunctionNames | string | undefined;
|
|
466
1279
|
/** When true (default), eligible animations may use the Web Animations API for compositor-thread execution. Set to false to force rAF. */
|
|
467
1280
|
useWAAPI: boolean;
|
|
468
1281
|
/** When true, snap `play()` to the final frame under `prefers-reduced-motion: reduce`. Default false. */
|
|
@@ -473,6 +1286,13 @@ export declare type InputAnimationOptions = Partial<{
|
|
|
473
1286
|
|
|
474
1287
|
export { InterpolatedVar }
|
|
475
1288
|
|
|
1289
|
+
declare const jumpDown: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1290
|
+
|
|
1291
|
+
declare const jumpUp: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1292
|
+
|
|
1293
|
+
/** A keyframe map: percent/keyword stops → partial var frames. */
|
|
1294
|
+
export declare type KeyframeMap<V extends Vars> = Map<string, Partial<V>> | Record<string, Partial<V>>;
|
|
1295
|
+
|
|
476
1296
|
/**
|
|
477
1297
|
* Load the heavy CSS-keyframe parsing engine — `Animation`,
|
|
478
1298
|
* `CSSKeyframesAnimation`, `AnimationGroup`, `getTimingFunction`,
|
|
@@ -493,6 +1313,19 @@ export { InterpolatedVar }
|
|
|
493
1313
|
*/
|
|
494
1314
|
export declare const loadAnimationEngine: () => Promise<AnimationEngine>;
|
|
495
1315
|
|
|
1316
|
+
/** Looping animations — run continuously (`iterationCount: Infinity`). */
|
|
1317
|
+
declare const loopPresets: {
|
|
1318
|
+
readonly heartbeat: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1319
|
+
readonly glow: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1320
|
+
readonly spinner: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1321
|
+
readonly rainbowText: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1322
|
+
readonly skeletonLoading: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1323
|
+
readonly gradientBackground: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1324
|
+
readonly parallaxScroll: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1325
|
+
readonly hover: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1326
|
+
readonly typingCursor: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1327
|
+
};
|
|
1328
|
+
|
|
496
1329
|
export declare class ManualTimeline extends Timeline {
|
|
497
1330
|
private value;
|
|
498
1331
|
constructor(options?: TimelineOptions);
|
|
@@ -516,6 +1349,82 @@ declare interface MorphValues {
|
|
|
516
1349
|
scaleY: number;
|
|
517
1350
|
}
|
|
518
1351
|
|
|
1352
|
+
/**
|
|
1353
|
+
* `MotionPath` — the class form of {@link fromMotionPath}, for callers who
|
|
1354
|
+
* prefer a named primitive alongside `CSSKeyframesAnimation`. Construction is
|
|
1355
|
+
* the factory: `new MotionPath(target, { path }).animation` is the control
|
|
1356
|
+
* handle. The factory is the canonical entry; this is a thin ergonomic wrapper.
|
|
1357
|
+
*/
|
|
1358
|
+
declare class MotionPath<V extends Record<string, any> = any> {
|
|
1359
|
+
/** The underlying offset-distance animation — the control handle. */
|
|
1360
|
+
readonly animation: CSSKeyframesAnimation<V>;
|
|
1361
|
+
constructor(target: HTMLElement | HTMLElement[], options: MotionPathOptions);
|
|
1362
|
+
/** Start (or re-enter) the path-motion play loop. */
|
|
1363
|
+
play(): Promise<void>;
|
|
1364
|
+
/** Pause the play loop, retaining the playhead. */
|
|
1365
|
+
pause(): this;
|
|
1366
|
+
/** Halt and rewind the play loop. */
|
|
1367
|
+
stop(): this;
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
/**
|
|
1371
|
+
* A MotionPath spec — the `{ path, ... }` shape that routes to
|
|
1372
|
+
* {@link fromMotionPath} (F.W12 §S2). It carries the author `offset-path`
|
|
1373
|
+
* (`path`) plus the optional `from`/`to`/`rotate` MotionPath knobs; the
|
|
1374
|
+
* animation-options + `autoPlay` ride {@link AnimateOptions} on the third
|
|
1375
|
+
* argument, exactly as every other `animate()` shape. The discriminating field
|
|
1376
|
+
* is `path` — a `string` no keyframe map / vars array carries.
|
|
1377
|
+
*/
|
|
1378
|
+
declare type MotionPathInput = Pick<MotionPathOptions, "path" | "from" | "to" | "rotate">;
|
|
1379
|
+
|
|
1380
|
+
export declare interface MotionPathOptions extends Partial<InputAnimationOptions> {
|
|
1381
|
+
/**
|
|
1382
|
+
* The author `offset-path` (required) — set on the target so the browser
|
|
1383
|
+
* resolves position from `offset-distance`. See {@link OffsetPath}.
|
|
1384
|
+
*/
|
|
1385
|
+
path: OffsetPath;
|
|
1386
|
+
/**
|
|
1387
|
+
* Start of the `offset-distance` sweep. Default `"0%"` (the path origin).
|
|
1388
|
+
* Any `<length-percentage>` the property accepts; `%` is path-relative.
|
|
1389
|
+
*/
|
|
1390
|
+
from?: string;
|
|
1391
|
+
/** End of the sweep. Default `"100%"` (the path end). */
|
|
1392
|
+
to?: string;
|
|
1393
|
+
/**
|
|
1394
|
+
* Optional `offset-rotate` set on the target for tangent-following — e.g.
|
|
1395
|
+
* `"auto"` (the element rotates to face along the path) or `"auto 90deg"`.
|
|
1396
|
+
* A STATIC author value (not animated); omitted leaves the CSS default.
|
|
1397
|
+
*/
|
|
1398
|
+
rotate?: string;
|
|
1399
|
+
/**
|
|
1400
|
+
* Auto-start the play loop after construction + targeting. Default true.
|
|
1401
|
+
* `false` returns a constructed, targeted, NOT-yet-playing handle so the
|
|
1402
|
+
* caller can drive the returned animation (`.play()` / `.pause()` / `.stop()`).
|
|
1403
|
+
*/
|
|
1404
|
+
autoPlay?: boolean;
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1407
|
+
/**
|
|
1408
|
+
* Spec for the ADDITIVE native scroll-driven bridge (D-LIB-2 / F-5).
|
|
1409
|
+
*
|
|
1410
|
+
* A `kind: "scroll"` request maps to the platform `ScrollTimeline` (scroll
|
|
1411
|
+
* progress over a `source` scroller); `kind: "view"` maps to `ViewTimeline`
|
|
1412
|
+
* (a `subject`'s view progress through its scrollport). `axis` defaults to the
|
|
1413
|
+
* platform default (`block`). value.js-free — these are DOM globals.
|
|
1414
|
+
*/
|
|
1415
|
+
export declare type NativeTimelineSpec = {
|
|
1416
|
+
kind: "scroll";
|
|
1417
|
+
source?: Element | null;
|
|
1418
|
+
axis?: ScrollAxis;
|
|
1419
|
+
} | {
|
|
1420
|
+
kind: "view";
|
|
1421
|
+
subject: Element;
|
|
1422
|
+
axis?: ScrollAxis;
|
|
1423
|
+
inset?: string;
|
|
1424
|
+
};
|
|
1425
|
+
|
|
1426
|
+
declare const notificationBounce: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1427
|
+
|
|
519
1428
|
/**
|
|
520
1429
|
* Zero-allocation numeric keyframe interpolator.
|
|
521
1430
|
*
|
|
@@ -535,24 +1444,11 @@ export declare class NumericAnimation<T extends Record<string, number>> {
|
|
|
535
1444
|
private result;
|
|
536
1445
|
private _duration;
|
|
537
1446
|
private _respectReducedMotion;
|
|
538
|
-
private
|
|
1447
|
+
private _easingFn;
|
|
539
1448
|
private _playback;
|
|
540
1449
|
constructor(keyframes: T[], options?: NumericAnimationOptions);
|
|
541
1450
|
private buildSegments;
|
|
542
1451
|
private buildSegment;
|
|
543
|
-
/**
|
|
544
|
-
* Resolve a pending string easing *name* through the dynamic engine
|
|
545
|
-
* boundary. A no-op (resolved promise) when easing was supplied as a
|
|
546
|
-
* callable or omitted. Memoized via the shared `EasingResolvable` — the
|
|
547
|
-
* `await import("./engine")` and `getTimingFunction` lookup run at most
|
|
548
|
-
* once per instance.
|
|
549
|
-
*
|
|
550
|
-
* Resolution is already kicked off eagerly at construction; `.play()`
|
|
551
|
-
* awaits this before the first frame, and stateless `.at()` consumers
|
|
552
|
-
* that pass a name can `await animation.ready()` first to interpolate
|
|
553
|
-
* with the resolved easing rather than the identity fallback.
|
|
554
|
-
*/
|
|
555
|
-
ready(): Promise<void>;
|
|
556
1452
|
/**
|
|
557
1453
|
* Map [0, 1] progress to interpolated values. Zero allocation —
|
|
558
1454
|
* returns the same pre-allocated result object on every call.
|
|
@@ -580,24 +1476,19 @@ export declare class NumericAnimation<T extends Record<string, number>> {
|
|
|
580
1476
|
|
|
581
1477
|
export declare interface NumericAnimationOptions {
|
|
582
1478
|
/**
|
|
583
|
-
* Easing as a callable `TimingFunction
|
|
584
|
-
*
|
|
585
|
-
*
|
|
1479
|
+
* Easing as a callable `TimingFunction` or a typed `Easing` — both
|
|
1480
|
+
* synchronous and value.js-free, so this engine never touches the
|
|
1481
|
+
* dynamic boundary.
|
|
586
1482
|
*
|
|
587
|
-
* A
|
|
588
|
-
*
|
|
1483
|
+
* A string easing *name* is NOT accepted here (fail-explicit: it
|
|
1484
|
+
* throws). Resolve a name once, up front, through the async factory:
|
|
589
1485
|
*
|
|
590
|
-
*
|
|
591
|
-
*
|
|
592
|
-
*
|
|
593
|
-
*
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
* identity fallback and emits a one-time dev-only warning; `await
|
|
597
|
-
* .ready()` first to interpolate with the named curve from the very first
|
|
598
|
-
* synchronous `.at()`.
|
|
599
|
-
*/
|
|
600
|
-
timingFunction?: TimingFunction | TimingFunctionNames | undefined;
|
|
1486
|
+
* ```ts
|
|
1487
|
+
* const easing = await resolveEasing("easeOutCubic");
|
|
1488
|
+
* new NumericAnimation(frames, { timingFunction: easing });
|
|
1489
|
+
* ```
|
|
1490
|
+
*/
|
|
1491
|
+
timingFunction?: TimingFunction | Easing | undefined;
|
|
601
1492
|
/** Playback duration in milliseconds. Required for `.play()`. */
|
|
602
1493
|
duration?: number | undefined;
|
|
603
1494
|
/** Explicit positions as percentages [0-100]. Auto-distributes if omitted. */
|
|
@@ -617,23 +1508,122 @@ export declare interface NumericAnimationOptions {
|
|
|
617
1508
|
/** Callback invoked each frame during `.play()` with the interpolated values. */
|
|
618
1509
|
export declare type NumericFrameCallback<T extends Record<string, number>> = (values: T) => void;
|
|
619
1510
|
|
|
1511
|
+
/**
|
|
1512
|
+
* The author's path geometry — the `offset-path` value set on the target. Any
|
|
1513
|
+
* valid CSS `offset-path`: a `path()` data string, a `ray()`, a `url(#id)`
|
|
1514
|
+
* SVG-path reference, or a basic shape. The browser resolves it to positions;
|
|
1515
|
+
* keyframes never parses it.
|
|
1516
|
+
*/
|
|
1517
|
+
export declare type OffsetPath = string;
|
|
1518
|
+
|
|
1519
|
+
declare const parallaxScroll: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1520
|
+
|
|
620
1521
|
declare type ParsedVarMap = Record<string, ValueArray>;
|
|
621
1522
|
|
|
622
1523
|
/**
|
|
623
|
-
*
|
|
624
|
-
*
|
|
625
|
-
*
|
|
626
|
-
|
|
627
|
-
|
|
1524
|
+
* The full preset taxonomy, grouped by intent. Each leaf is one of the
|
|
1525
|
+
* existing exported factory functions — the taxonomy is a discovery index over
|
|
1526
|
+
* the library, not a second copy of it.
|
|
1527
|
+
*/
|
|
1528
|
+
declare const presetTaxonomy: {
|
|
1529
|
+
readonly enter: {
|
|
1530
|
+
readonly fadeIn: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1531
|
+
readonly slideIn: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1532
|
+
readonly slideInLeft: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1533
|
+
readonly slideInRight: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1534
|
+
readonly rotateIn: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1535
|
+
readonly blurIn: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1536
|
+
readonly springScaleIn: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1537
|
+
readonly springSlideIn: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1538
|
+
readonly jumpUp: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1539
|
+
};
|
|
1540
|
+
readonly exit: {
|
|
1541
|
+
readonly fadeOut: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1542
|
+
readonly slideOutLeft: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1543
|
+
readonly slideOutRight: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1544
|
+
readonly blurOut: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1545
|
+
readonly warpLeft: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1546
|
+
readonly warpRight: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1547
|
+
readonly jumpDown: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1548
|
+
};
|
|
1549
|
+
readonly attention: {
|
|
1550
|
+
readonly pulse: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1551
|
+
readonly shake: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1552
|
+
readonly bounce: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1553
|
+
readonly flip: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1554
|
+
readonly notificationBounce: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1555
|
+
readonly springPop: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1556
|
+
readonly springWobble: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1557
|
+
};
|
|
1558
|
+
readonly loop: {
|
|
1559
|
+
readonly heartbeat: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1560
|
+
readonly glow: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1561
|
+
readonly spinner: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1562
|
+
readonly rainbowText: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1563
|
+
readonly skeletonLoading: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1564
|
+
readonly gradientBackground: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1565
|
+
readonly parallaxScroll: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1566
|
+
readonly hover: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1567
|
+
readonly typingCursor: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1568
|
+
};
|
|
1569
|
+
};
|
|
1570
|
+
|
|
1571
|
+
declare const progressBar: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1572
|
+
|
|
1573
|
+
declare const pulse: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1574
|
+
|
|
1575
|
+
/**
|
|
1576
|
+
* THE managed rAF driver. Owns the rAF handle, start timestamp, dt clock,
|
|
1577
|
+
* and resolve callback for every loop in the engine. ONE generation-guarded
|
|
1578
|
+
* frame-scheduler core ({@link _run}) backs three thin entry shapes:
|
|
628
1579
|
*
|
|
629
|
-
*
|
|
630
|
-
*
|
|
631
|
-
*
|
|
1580
|
+
* - {@link play} — duration-based progress loop (`NumericAnimation`,
|
|
1581
|
+
* `ElementMorph`), with the light reduced-motion snap gate built in.
|
|
1582
|
+
* - {@link drive} — settle-based dt loop over a {@link Tickable}
|
|
1583
|
+
* (`SmoothProgress`, `SpringProgress`): steps until the stepper settles,
|
|
1584
|
+
* auto-stopping; idempotent so target re-seats can re-arm it.
|
|
1585
|
+
* - {@link loop} — self-rescheduling frame loop over an async callback
|
|
1586
|
+
* (`Animation`, `AnimationGroup`, the WAAPI shadow tick): the callback
|
|
1587
|
+
* returns `true` to continue; rescheduling waits for the (possibly
|
|
1588
|
+
* async) callback to complete, so a slow frame never double-schedules.
|
|
1589
|
+
*
|
|
1590
|
+
* Because all three ride one core, none can diverge — the generation guard
|
|
1591
|
+
* that makes `loop` safe against a `stop()` + restart mid-frame protects
|
|
1592
|
+
* `drive` and `play` identically.
|
|
1593
|
+
*
|
|
1594
|
+
* The formerly hand-rolled copies of this lifecycle — `SmoothProgress` /
|
|
1595
|
+
* `SpringProgress` `_startLoop`/`_stopLoop` byte-siblings, the
|
|
1596
|
+
* `AnimationGroup` draw loop, `Animation._playRAF`, and the WAAPI shadow
|
|
1597
|
+
* loop — all delegate here. No other module owns a rAF handle.
|
|
632
1598
|
*/
|
|
633
1599
|
export declare class RAFPlayback {
|
|
634
1600
|
private _rafId;
|
|
635
1601
|
private _startTime;
|
|
1602
|
+
private _lastFrameT;
|
|
636
1603
|
private _resolve;
|
|
1604
|
+
/**
|
|
1605
|
+
* Monotonic generation counter, bumped on every `play`/`drive`/`loop`/
|
|
1606
|
+
* `stop`. A loop's async frame captures its generation and reschedules
|
|
1607
|
+
* ONLY when it still matches — so a `stop()` + restart while an async
|
|
1608
|
+
* frame is mid-flight cannot let the stale callback re-arm a second rAF
|
|
1609
|
+
* chain (the generation-unaware `_rafId !== null` guard could, because
|
|
1610
|
+
* the restart repopulated `_rafId`).
|
|
1611
|
+
*/
|
|
1612
|
+
private _gen;
|
|
1613
|
+
/** True while this driver owns a scheduled rAF callback. */
|
|
1614
|
+
get running(): boolean;
|
|
1615
|
+
/**
|
|
1616
|
+
* THE generation-guarded frame-scheduler core. `step(now)` does one
|
|
1617
|
+
* frame's work and returns `true` to continue, `false` to finish; it
|
|
1618
|
+
* may be async (the next frame waits for it). Every frame captures the
|
|
1619
|
+
* generation taken at start, and reschedules ONLY when it still matches
|
|
1620
|
+
* — so a `stop()` + restart mid-frame (even while an async `step` is in
|
|
1621
|
+
* flight) cannot let a stale chain re-arm a second rAF on top of the
|
|
1622
|
+
* restart's freshly-repopulated `_rafId`. On `false` (or a stale
|
|
1623
|
+
* generation that finishes) the loop cleans up. `play`/`drive`/`loop`
|
|
1624
|
+
* are the three thin entry shapes over this one core.
|
|
1625
|
+
*/
|
|
1626
|
+
private _run;
|
|
637
1627
|
/**
|
|
638
1628
|
* Drive `onTick(progress)` once per frame for `duration` ms.
|
|
639
1629
|
* `progress` is clamped to [0, 1]; the loop terminates after the
|
|
@@ -646,13 +1636,28 @@ export declare class RAFPlayback {
|
|
|
646
1636
|
* resolves on the next microtask.
|
|
647
1637
|
*/
|
|
648
1638
|
play(duration: number, onTick: (progress: number) => void, options?: RAFPlaybackOptions): Promise<void>;
|
|
649
|
-
/**
|
|
1639
|
+
/**
|
|
1640
|
+
* Drive a {@link Tickable}'s dt-stepper once per frame until it
|
|
1641
|
+
* settles, invoking `onFrame` after each step. Idempotent — a call
|
|
1642
|
+
* while the loop is already running is a no-op, so consumers re-arm
|
|
1643
|
+
* freely on every target re-seat. The loop auto-stops on settle.
|
|
1644
|
+
*/
|
|
1645
|
+
drive(tickable: Tickable, onFrame?: () => void): void;
|
|
1646
|
+
/**
|
|
1647
|
+
* Self-rescheduling frame loop over an async callback. `cb(now)`
|
|
1648
|
+
* returns `true` to continue; the next frame is scheduled only after
|
|
1649
|
+
* the callback (and any awaited work inside it) completes. `stop()`
|
|
1650
|
+
* between frames halts the loop — the in-flight callback finishes,
|
|
1651
|
+
* no further frame is scheduled.
|
|
1652
|
+
*/
|
|
1653
|
+
loop(cb: (now: number) => boolean | Promise<boolean>): void;
|
|
1654
|
+
/** Cancel a running playback. A pending play promise resolves immediately. */
|
|
650
1655
|
stop(): void;
|
|
651
1656
|
private _cleanup;
|
|
652
1657
|
}
|
|
653
1658
|
|
|
654
1659
|
/** Per-playback options for {@link RAFPlayback.play}. */
|
|
655
|
-
declare interface RAFPlaybackOptions {
|
|
1660
|
+
export declare interface RAFPlaybackOptions {
|
|
656
1661
|
/**
|
|
657
1662
|
* Honor `prefers-reduced-motion: reduce` by snapping to the final frame
|
|
658
1663
|
* (`onTick(1)`) in a single paint instead of running the rAF loop. The
|
|
@@ -668,6 +1673,8 @@ declare interface RAFPlaybackOptions {
|
|
|
668
1673
|
respectReducedMotion?: boolean | undefined;
|
|
669
1674
|
}
|
|
670
1675
|
|
|
1676
|
+
declare const rainbowText: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1677
|
+
|
|
671
1678
|
/**
|
|
672
1679
|
* Result of normalising a CSS keyframes input down to the shape the
|
|
673
1680
|
* `CSSKeyframesAnimation.fromString` flow expects: a `Map<percent →
|
|
@@ -680,6 +1687,13 @@ export declare interface ResolvedKeyframes {
|
|
|
680
1687
|
keyframes: Map<string, Record<string, unknown>>;
|
|
681
1688
|
/** per-keyframe `animation-timing-function`, keyed by percent string */
|
|
682
1689
|
timingFunctions: Map<string, string>;
|
|
1690
|
+
/**
|
|
1691
|
+
* per-keyframe `animation-composition` (`replace` | `add` | `accumulate`),
|
|
1692
|
+
* keyed by percent string — value.js lifts it onto `rule.composition`; the
|
|
1693
|
+
* adapter used to drop it. Captured (F.W8); honoring it (→ WAAPI
|
|
1694
|
+
* `composite` / rAF accumulate) is BOOKed, not half-wired.
|
|
1695
|
+
*/
|
|
1696
|
+
composition: Map<string, string>;
|
|
683
1697
|
/** `@property --foo { ... }` registry */
|
|
684
1698
|
properties: Map<string, PropertyDescriptor_2>;
|
|
685
1699
|
/**
|
|
@@ -690,6 +1704,30 @@ export declare interface ResolvedKeyframes {
|
|
|
690
1704
|
options: ReturnType<typeof extractAnimationOptions>;
|
|
691
1705
|
}
|
|
692
1706
|
|
|
1707
|
+
/**
|
|
1708
|
+
* Resolve a string easing name (a value.js registry entry — `"easeOutCubic"`,
|
|
1709
|
+
* `"ease-out-cubic"`, … — or a CSS `cubic-bezier()` literal) to a typed
|
|
1710
|
+
* {@link Easing}.
|
|
1711
|
+
*
|
|
1712
|
+
* The lookup rides the dynamic engine boundary: `import("./engine")` loads
|
|
1713
|
+
* the value.js-bearing easing registry only when a named easing is actually
|
|
1714
|
+
* used, so a light-only consumer that never calls this stays value.js-free.
|
|
1715
|
+
*
|
|
1716
|
+
* Fail-explicit: an unresolvable name throws {@link UnknownEasingError};
|
|
1717
|
+
* an engine chunk-load failure rethrows with the failing easing named —
|
|
1718
|
+
* never an unhandled rejection, never a silent identity fallback.
|
|
1719
|
+
*
|
|
1720
|
+
* ```ts
|
|
1721
|
+
* const easing = await resolveEasing("easeOutCubic");
|
|
1722
|
+
* const anim = new NumericAnimation(frames, { timingFunction: easing });
|
|
1723
|
+
* ```
|
|
1724
|
+
*/
|
|
1725
|
+
export declare function resolveEasing(name: string): Promise<Easing>;
|
|
1726
|
+
|
|
1727
|
+
declare const rotateIn: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1728
|
+
|
|
1729
|
+
declare const rotateScale: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1730
|
+
|
|
693
1731
|
declare class ScrollTimeline_2 extends Timeline {
|
|
694
1732
|
private threshold;
|
|
695
1733
|
private getScrollY;
|
|
@@ -709,6 +1747,267 @@ declare interface ScrollTimelineOptions_2 extends TimelineOptions {
|
|
|
709
1747
|
}
|
|
710
1748
|
export { ScrollTimelineOptions_2 as ScrollTimelineOptions }
|
|
711
1749
|
|
|
1750
|
+
/**
|
|
1751
|
+
* The master-playhead orchestrator. Positions child animations along one clock
|
|
1752
|
+
* and drives them via `Animation.advanceTo`. See the module docstring for the
|
|
1753
|
+
* booked name + subsumption decision.
|
|
1754
|
+
*/
|
|
1755
|
+
export declare class Sequence<V extends Vars = any> {
|
|
1756
|
+
/** Resolved segments, in insertion order. */
|
|
1757
|
+
readonly entries: SequenceEntry<V>[];
|
|
1758
|
+
/** Named positions on the master clock, registered via {@link label}. */
|
|
1759
|
+
private readonly labels;
|
|
1760
|
+
/**
|
|
1761
|
+
* The running insertion cursor (ms) — the end of the last-inserted
|
|
1762
|
+
* segment. Relative `"+="`/`"-="` positions and auto-append (`at` omitted)
|
|
1763
|
+
* measure from here, matching GSAP's append-by-default timeline.
|
|
1764
|
+
*/
|
|
1765
|
+
private cursor;
|
|
1766
|
+
/** Master clock (ms) of the current playhead. */
|
|
1767
|
+
private _time;
|
|
1768
|
+
private readonly respectReducedMotion;
|
|
1769
|
+
/** THE rAF owner for the sequence's play loop. */
|
|
1770
|
+
readonly playback: RAFPlayback;
|
|
1771
|
+
private _boundFrame;
|
|
1772
|
+
private _resolvePlay;
|
|
1773
|
+
private _playOrigin;
|
|
1774
|
+
private _playingPromise;
|
|
1775
|
+
/**
|
|
1776
|
+
* The scalar playback rate — the single field that drives `timeScale`
|
|
1777
|
+
* and `reverse`. `_rate = 1` is real-time forward (the existing
|
|
1778
|
+
* single-play default); `n` is `timeScale(n)` (slow-mo `< 1` /
|
|
1779
|
+
* fast-forward `> 1`); a negative `_rate` walks the master clock
|
|
1780
|
+
* backward (`reverse`). It scales the master clock in {@link _frame}:
|
|
1781
|
+
* `masterClock = (clock − _playOrigin) * _rate`.
|
|
1782
|
+
*/
|
|
1783
|
+
private _rate;
|
|
1784
|
+
/**
|
|
1785
|
+
* How many master-clock cycles `play()` runs before settling. `1` is the
|
|
1786
|
+
* existing single-play; `Infinity` never settles (the loop case);
|
|
1787
|
+
* `n` runs `n` cycles. The master clock folds modulo `duration`
|
|
1788
|
+
* (see {@link _fold}).
|
|
1789
|
+
*/
|
|
1790
|
+
private _repeatCount;
|
|
1791
|
+
/**
|
|
1792
|
+
* When true, odd cycles reflect the folded phase (`duration − phase`) —
|
|
1793
|
+
* the GSAP `yoyo` ping-pong. Default off (every cycle runs forward).
|
|
1794
|
+
*/
|
|
1795
|
+
private _yoyoOn;
|
|
1796
|
+
/** Whether `pause()` has halted the loop with the playhead retained. */
|
|
1797
|
+
private _paused;
|
|
1798
|
+
/**
|
|
1799
|
+
* The loop's last rAF timestamp — the re-anchor reference. The
|
|
1800
|
+
* `RAFPlayback`/`AnimationGroup` managed-pause records the loop's LAST rAF
|
|
1801
|
+
* timestamp (not `performance.now()`) so resume adjusts the origin against
|
|
1802
|
+
* the SAME clock the loop reads, with no forward jump. `Sequence` records
|
|
1803
|
+
* it here per frame (the driver does not expose it) for that one re-anchor.
|
|
1804
|
+
*/
|
|
1805
|
+
private _lastClock;
|
|
1806
|
+
constructor(options?: SequenceOptions);
|
|
1807
|
+
/** The full span of the sequence (ms): the latest segment end. */
|
|
1808
|
+
get duration(): number;
|
|
1809
|
+
/** The current master-clock position (ms). */
|
|
1810
|
+
get time(): number;
|
|
1811
|
+
/**
|
|
1812
|
+
* The normalized playhead position in `[0, 1]` — the GSAP
|
|
1813
|
+
* `Timeline.progress()` idiom. Pure division over the existing scrub:
|
|
1814
|
+
* the getter is `_time / duration`; the setter scrubs to `p * duration`
|
|
1815
|
+
* via {@link seek}.
|
|
1816
|
+
*/
|
|
1817
|
+
get progress(): number;
|
|
1818
|
+
set progress(p: number);
|
|
1819
|
+
/** The scalar playback rate (`timeScale` / sign of `reverse`). */
|
|
1820
|
+
get rate(): number;
|
|
1821
|
+
/** Register a named position on the master clock. Chainable. */
|
|
1822
|
+
label(name: string, at?: SequencePosition): this;
|
|
1823
|
+
/**
|
|
1824
|
+
* Append a child animation at `at` (absolute ms, a label, a `"+="`/`"-="`
|
|
1825
|
+
* relative token, or — omitted — the running cursor, i.e. after the
|
|
1826
|
+
* previous segment). Advances the insertion cursor to this segment's end.
|
|
1827
|
+
* Chainable.
|
|
1828
|
+
*/
|
|
1829
|
+
add(animation: Animation_2<V>, at?: SequencePosition): this;
|
|
1830
|
+
/**
|
|
1831
|
+
* Resolve a {@link SequencePosition} to an absolute ms offset.
|
|
1832
|
+
*
|
|
1833
|
+
* - omitted → the running cursor (auto-append after the previous segment).
|
|
1834
|
+
* - `number` → itself.
|
|
1835
|
+
* - `"+=n"` / `"-=n"` → cursor ± n.
|
|
1836
|
+
* - any other string → the registered label (throws if unknown — labels
|
|
1837
|
+
* are an explicit contract, a typo is a bug, not a silent 0).
|
|
1838
|
+
*/
|
|
1839
|
+
private resolvePosition;
|
|
1840
|
+
/**
|
|
1841
|
+
* Map the master playhead to each child's LOCAL clock and paint it. This is
|
|
1842
|
+
* the synchronous scrub form: for every segment, the local clock is
|
|
1843
|
+
* `clamp(masterClock − at, 0, duration)`, applied via `interpFrames(local,
|
|
1844
|
+
* true)`. Segments not yet reached rest at their initial frame; segments
|
|
1845
|
+
* past their end rest at their final frame — the timeline-scrub contract.
|
|
1846
|
+
* Chainable.
|
|
1847
|
+
*/
|
|
1848
|
+
seek(masterClock: number): this;
|
|
1849
|
+
/**
|
|
1850
|
+
* THE master-playhead → child-clock map, applied as a pure synchronous
|
|
1851
|
+
* scrub. For every segment the local clock is `clamp(masterClock − at, 0,
|
|
1852
|
+
* duration)`, painted via `interpFrames(local, true)`. This is the ONE map
|
|
1853
|
+
* both `seek` (the public scrub) and `_frame` (the rAF play loop) drive —
|
|
1854
|
+
* so play is pixel-identical to seek BY CONSTRUCTION, forward AND reverse
|
|
1855
|
+
* (the C⁰-continuity the F.W9 parity gate locks). It carries no `onEnd`/
|
|
1856
|
+
* `startTime` machinery, so re-entering a finished segment under a negative
|
|
1857
|
+
* `rate` paints the same final-frame value `seek` would — there is no
|
|
1858
|
+
* forward-monotone re-anchor window to break (F.W9 §S3 MEASURE-FIRST).
|
|
1859
|
+
*/
|
|
1860
|
+
private _applyAt;
|
|
1861
|
+
/**
|
|
1862
|
+
* Fold a raw, repeat-extended master clock down to an effective phase in
|
|
1863
|
+
* `[0, duration]` per the `repeat`/`yoyo` transport. With `repeat(1)` +
|
|
1864
|
+
* `yoyo(false)` (the defaults) this is the identity on `[0, duration]`
|
|
1865
|
+
* (the existing single-play). For `repeat`, the phase is `raw mod
|
|
1866
|
+
* duration`; for `yoyo`, odd cycles reflect (`duration − phase`) so the
|
|
1867
|
+
* playhead ping-pongs. The terminal clock of the LAST cycle resolves to
|
|
1868
|
+
* the rest phase (`duration` forward, `0` reflected) rather than wrapping
|
|
1869
|
+
* to `0` — so a settled `repeat`/`yoyo` run lands on its true end frame.
|
|
1870
|
+
*/
|
|
1871
|
+
private _fold;
|
|
1872
|
+
/**
|
|
1873
|
+
* Set targets on every child segment. Convenience for the common case
|
|
1874
|
+
* where one target receives the whole sequence; per-segment targets can be
|
|
1875
|
+
* set on each `animation` directly before `.add`. Chainable.
|
|
1876
|
+
*/
|
|
1877
|
+
setTargets(...targets: HTMLElement[]): this;
|
|
1878
|
+
/**
|
|
1879
|
+
* Drive the sequence over real time via `RAFPlayback`. Each child is driven
|
|
1880
|
+
* through the published `Animation.advanceTo(absoluteClock)` map: its
|
|
1881
|
+
* `startTime` is seeded to its resolved `at`, so `advanceTo(masterClock)`
|
|
1882
|
+
* yields the child's local clock as `masterClock − at` exactly. Resolves
|
|
1883
|
+
* when the master playhead passes the sequence `duration`.
|
|
1884
|
+
*
|
|
1885
|
+
* Re-entrant: a `play()` while one is in flight returns the same promise.
|
|
1886
|
+
* Under `respectReducedMotion` + an active query, snaps to the rest frame
|
|
1887
|
+
* in one paint (a terminal `seek(duration)`), no draw loop.
|
|
1888
|
+
*/
|
|
1889
|
+
play(): Promise<void>;
|
|
1890
|
+
private _frame;
|
|
1891
|
+
/**
|
|
1892
|
+
* True for the byte-stable default transport — forward real-time, single
|
|
1893
|
+
* cycle, no yoyo. The event-dispatch path runs ONLY here, so an existing
|
|
1894
|
+
* caller's `play()` fires the same `animationstart`/`animationend` it
|
|
1895
|
+
* always did; any transport modifier opts into the scrub-paint authority.
|
|
1896
|
+
*/
|
|
1897
|
+
private _isForwardMonotone;
|
|
1898
|
+
/**
|
|
1899
|
+
* The terminal rest phase of a `repeat`/`yoyo` run — where the playhead
|
|
1900
|
+
* lands when the final cycle closes. A forward run rests at `duration`;
|
|
1901
|
+
* an odd-cycle yoyo run that closes reflected rests at `0`. Mirrors the
|
|
1902
|
+
* boundary `_fold` resolves at the terminal clock.
|
|
1903
|
+
*/
|
|
1904
|
+
private _restPhase;
|
|
1905
|
+
/**
|
|
1906
|
+
* Re-anchor `_playOrigin` against the loop's last rAF timestamp so the
|
|
1907
|
+
* master clock is CONTINUOUS across a transport edit — the
|
|
1908
|
+
* `RAFPlayback`/`AnimationGroup` managed-pause re-anchor (no forward jump).
|
|
1909
|
+
* The invariant restored: `(clock − _playOrigin) * rate === _time` at the
|
|
1910
|
+
* edit instant. Solving for the origin: `_playOrigin = clock − _time /
|
|
1911
|
+
* rate`. With `rate = 0` the playhead is frozen, so the origin collapses
|
|
1912
|
+
* to the bare timestamp (the next non-zero rate re-anchors again).
|
|
1913
|
+
*/
|
|
1914
|
+
private _reanchor;
|
|
1915
|
+
/** Release every child back to standalone ownership and clear play flags. */
|
|
1916
|
+
private _settle;
|
|
1917
|
+
/** Halt the play loop where it stands and resolve any pending `play()`. */
|
|
1918
|
+
stop(): this;
|
|
1919
|
+
/**
|
|
1920
|
+
* Halt the play loop where it stands WITHOUT releasing the playhead — the
|
|
1921
|
+
* managed-pause contract. The rAF loop stops; `_time` and the play promise
|
|
1922
|
+
* are RETAINED (children stay `managed`, unlike `stop()`/`_settle`), so a
|
|
1923
|
+
* later {@link resume} continues from exactly here. No-op when not playing
|
|
1924
|
+
* or already paused. Chainable.
|
|
1925
|
+
*/
|
|
1926
|
+
pause(): this;
|
|
1927
|
+
/**
|
|
1928
|
+
* Resume a paused sequence — restart the rAF loop with the origin
|
|
1929
|
+
* re-anchored so the FIRST resumed frame's master clock equals the
|
|
1930
|
+
* retained `_time` (the no-forward-jump re-anchor, the same `RAFPlayback`/
|
|
1931
|
+
* `AnimationGroup` managed-pause contract — `src/animation/CLAUDE.md`
|
|
1932
|
+
* §Managed-child lifecycle). No-op when not paused. Chainable.
|
|
1933
|
+
*/
|
|
1934
|
+
resume(): this;
|
|
1935
|
+
/**
|
|
1936
|
+
* Set the scalar playback rate — slow-mo (`< 1`), real-time (`1`),
|
|
1937
|
+
* fast-forward (`> 1`), or backward (`< 0`, the {@link reverse} form). The
|
|
1938
|
+
* master clock is re-anchored so the playhead is CONTINUOUS at the
|
|
1939
|
+
* rate-change instant (no jump) — the same re-anchor as {@link resume}.
|
|
1940
|
+
* Takes effect immediately whether or not the sequence is playing.
|
|
1941
|
+
* Chainable.
|
|
1942
|
+
*/
|
|
1943
|
+
timeScale(n: number): this;
|
|
1944
|
+
/**
|
|
1945
|
+
* Flip the playback direction — the playhead walks backward from where it
|
|
1946
|
+
* stands (a negative rate) or forward again, preserving `|rate|`. C⁰-
|
|
1947
|
+
* continuous: the re-anchor keeps the playhead exactly where it is at the
|
|
1948
|
+
* flip instant (locked by the F.W9 seek↔play parity gate). Chainable.
|
|
1949
|
+
*/
|
|
1950
|
+
reverse(): this;
|
|
1951
|
+
/**
|
|
1952
|
+
* Set how many cycles `play()` runs before settling — `1` is single-play,
|
|
1953
|
+
* `n` runs `n` cycles, `Infinity` loops forever (until `stop()`). The
|
|
1954
|
+
* master clock folds modulo `duration` per cycle. Chainable.
|
|
1955
|
+
*/
|
|
1956
|
+
repeat(count: number): this;
|
|
1957
|
+
/**
|
|
1958
|
+
* Toggle yoyo (ping-pong) — when on, odd cycles run reflected
|
|
1959
|
+
* (`duration − phase`) so the playhead bounces back and forth across the
|
|
1960
|
+
* `repeat` cycles. Chainable.
|
|
1961
|
+
*/
|
|
1962
|
+
yoyo(on?: boolean): this;
|
|
1963
|
+
}
|
|
1964
|
+
|
|
1965
|
+
/** A resolved sequence segment: a child animation anchored at an absolute ms offset. */
|
|
1966
|
+
export declare interface SequenceEntry<V extends Vars> {
|
|
1967
|
+
animation: Animation_2<V>;
|
|
1968
|
+
/** Absolute offset (ms) of this segment's local t=0 on the master clock. */
|
|
1969
|
+
at: number;
|
|
1970
|
+
}
|
|
1971
|
+
|
|
1972
|
+
export declare interface SequenceOptions {
|
|
1973
|
+
/**
|
|
1974
|
+
* When true, `play()` honors `prefers-reduced-motion: reduce` by snapping
|
|
1975
|
+
* every child to its rest frame in a single paint (delegated to each
|
|
1976
|
+
* child's own reduced-motion contract via a terminal `seek`). Default
|
|
1977
|
+
* false. SSR-safe off-DOM.
|
|
1978
|
+
*/
|
|
1979
|
+
respectReducedMotion?: boolean;
|
|
1980
|
+
}
|
|
1981
|
+
|
|
1982
|
+
/**
|
|
1983
|
+
* A position on the master clock for a sequence entry.
|
|
1984
|
+
*
|
|
1985
|
+
* - `number` — an absolute offset in milliseconds from the sequence origin.
|
|
1986
|
+
* - `` `+=${n}` `` / `` `-=${n}` `` — relative to the running insertion cursor
|
|
1987
|
+
* (the end of the previously-inserted segment): `"+=200"` starts 200ms after
|
|
1988
|
+
* the cursor, `"-=200"` overlaps the previous segment by 200ms.
|
|
1989
|
+
* - any other string — a label registered via {@link Sequence.label}.
|
|
1990
|
+
*/
|
|
1991
|
+
export declare type SequencePosition = number | `+=${number}` | `-=${number}` | string;
|
|
1992
|
+
|
|
1993
|
+
declare const shake: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1994
|
+
|
|
1995
|
+
declare const skeletonLoading: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1996
|
+
|
|
1997
|
+
declare const slideIn: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
1998
|
+
|
|
1999
|
+
declare const slideInLeft: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
2000
|
+
|
|
2001
|
+
declare const slideInLeftKeyframes = "\n0% {\n transform: translateX(-100%);\n opacity: 0;\n}\n100% {\n transform: translateX(0);\n opacity: 1;\n}\n";
|
|
2002
|
+
|
|
2003
|
+
declare const slideInRight: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
2004
|
+
|
|
2005
|
+
declare const slideInRightKeyframes = "\n0% {\n transform: translateX(100%);\n opacity: 0;\n}\n100% {\n transform: translateX(0);\n opacity: 1;\n}\n";
|
|
2006
|
+
|
|
2007
|
+
declare const slideOutLeft: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
2008
|
+
|
|
2009
|
+
declare const slideOutRight: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
2010
|
+
|
|
712
2011
|
/** Per-frame callback for `.play()` mode. Receives the smoothed current value. */
|
|
713
2012
|
declare type SmoothFrameCallback = (value: number) => void;
|
|
714
2013
|
|
|
@@ -717,17 +2016,26 @@ export declare class SmoothProgress {
|
|
|
717
2016
|
private targetValue;
|
|
718
2017
|
private currentValue;
|
|
719
2018
|
private isSettled;
|
|
720
|
-
private
|
|
721
|
-
private _lastFrameT;
|
|
2019
|
+
private _playback;
|
|
722
2020
|
private _onFrame;
|
|
723
2021
|
constructor(options?: Partial<SmoothProgressOptions>);
|
|
724
2022
|
get target(): number;
|
|
725
2023
|
get current(): number;
|
|
726
2024
|
get settled(): boolean;
|
|
727
2025
|
setTarget(target: number): void;
|
|
728
|
-
/**
|
|
729
|
-
|
|
730
|
-
|
|
2026
|
+
/**
|
|
2027
|
+
* Reduced-motion snap: jump to target, settle, emit once, and stop the
|
|
2028
|
+
* managed loop — symmetric with `SpringProgress._snapSettled`. A
|
|
2029
|
+
* reduced-motion snap leaves no scheduled `drive` frame on either
|
|
2030
|
+
* stepper; the two `_snapSettled` bodies are now contract-equivalent
|
|
2031
|
+
* (value-set + settle + emit + stop), differing only in the spring's
|
|
2032
|
+
* velocity/origin fields.
|
|
2033
|
+
*/
|
|
2034
|
+
private _snapSettled;
|
|
2035
|
+
/**
|
|
2036
|
+
* THE canonical step: advance by `dt` milliseconds, frame-rate
|
|
2037
|
+
* independent. Returns the new current value.
|
|
2038
|
+
*/
|
|
731
2039
|
tickDt(dt: number): number;
|
|
732
2040
|
/** Immediately set current = target. */
|
|
733
2041
|
snap(): void;
|
|
@@ -751,8 +2059,12 @@ export declare class SmoothProgress {
|
|
|
751
2059
|
* Pairs with `.play()`. Does not touch current/target/settled state.
|
|
752
2060
|
*/
|
|
753
2061
|
stop(): void;
|
|
2062
|
+
/**
|
|
2063
|
+
* Arm the shared driver: it steps `tickDt(dt)` once per frame until
|
|
2064
|
+
* `settled` flips true, emitting `onFrame` per step. Idempotent —
|
|
2065
|
+
* the driver no-ops while already running.
|
|
2066
|
+
*/
|
|
754
2067
|
private _startLoop;
|
|
755
|
-
private _stopLoop;
|
|
756
2068
|
}
|
|
757
2069
|
|
|
758
2070
|
export declare interface SmoothProgressOptions {
|
|
@@ -782,6 +2094,42 @@ export declare interface SmoothProgressOptions {
|
|
|
782
2094
|
respectReducedMotion: boolean;
|
|
783
2095
|
}
|
|
784
2096
|
|
|
2097
|
+
declare const spinner: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
2098
|
+
|
|
2099
|
+
/**
|
|
2100
|
+
* The modern, time-based spring surface — the idiom Motion now leads its
|
|
2101
|
+
* docs with, treating `(response, dampingFraction)` as the advanced
|
|
2102
|
+
* fallback. A pure parameter translation: `response = visualDuration` and
|
|
2103
|
+
* `dampingFraction = 1 − bounce` (clamped). The solver, the `linear()`
|
|
2104
|
+
* sampler, and the live re-seat are unchanged — this is a construction-time
|
|
2105
|
+
* alternate surface, zero hot-path cost.
|
|
2106
|
+
*
|
|
2107
|
+
* Exactly one of `visualDuration` / `duration` selects the perceptual
|
|
2108
|
+
* settle time (the period mapped onto `response`); `bounce` ∈ [−1, 1]
|
|
2109
|
+
* selects overshoot (`0` ≈ critically damped, `> 0` rings, `< 0`
|
|
2110
|
+
* overdamped). The remaining {@link SpringProgressOptions} keys
|
|
2111
|
+
* (`initial`, `initialVelocity`, thresholds, `respectReducedMotion`)
|
|
2112
|
+
* carry through unchanged.
|
|
2113
|
+
*/
|
|
2114
|
+
declare interface SpringDurationOptions extends Partial<Pick<SpringProgressOptions, "initial" | "initialVelocity" | "settleThreshold" | "velocitySettleThreshold" | "respectReducedMotion">> {
|
|
2115
|
+
/**
|
|
2116
|
+
* The perceptual settle duration in seconds — mapped directly onto
|
|
2117
|
+
* `response`. The designer-facing name for the same quantity.
|
|
2118
|
+
*/
|
|
2119
|
+
visualDuration?: number;
|
|
2120
|
+
/**
|
|
2121
|
+
* Alias of {@link visualDuration} (the Motion `duration` key). When
|
|
2122
|
+
* both are supplied, `visualDuration` wins. Default 0.5.
|
|
2123
|
+
*/
|
|
2124
|
+
duration?: number;
|
|
2125
|
+
/**
|
|
2126
|
+
* Overshoot, in [−1, 1]. `0` maps to critically damped (no ring),
|
|
2127
|
+
* `> 0` rings (underdamped), `< 0` is overdamped (sluggish). Mapped
|
|
2128
|
+
* `dampingFraction = 1 − bounce`. Default 0.
|
|
2129
|
+
*/
|
|
2130
|
+
bounce?: number;
|
|
2131
|
+
}
|
|
2132
|
+
|
|
785
2133
|
/** Per-frame callback for `.play()` mode. */
|
|
786
2134
|
export declare type SpringFrameCallback = (value: number, velocity: number) => void;
|
|
787
2135
|
|
|
@@ -830,6 +2178,9 @@ export declare interface SpringLinearStopsOptions {
|
|
|
830
2178
|
maxDuration?: number;
|
|
831
2179
|
}
|
|
832
2180
|
|
|
2181
|
+
/** Spring-eased attention "pop" — the bouncy spring drives the scale pulse. */
|
|
2182
|
+
declare const springPop: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
2183
|
+
|
|
833
2184
|
/**
|
|
834
2185
|
* Live-target spring tracker. Sibling of `SmoothProgress` for animations
|
|
835
2186
|
* where the target may change mid-flight (gesture follows, drag, live
|
|
@@ -864,10 +2215,22 @@ export declare class SpringProgress {
|
|
|
864
2215
|
private omegaD;
|
|
865
2216
|
private subscribers;
|
|
866
2217
|
private disposed;
|
|
867
|
-
private
|
|
868
|
-
private _lastFrameT;
|
|
2218
|
+
private _playback;
|
|
869
2219
|
private _onFrame;
|
|
870
2220
|
constructor(options?: Partial<SpringProgressOptions>);
|
|
2221
|
+
/**
|
|
2222
|
+
* Construct a spring from the modern time-based surface
|
|
2223
|
+
* `{ visualDuration | duration, bounce }` (the idiom Motion leads its
|
|
2224
|
+
* docs with). Pure parameter translation to `(response,
|
|
2225
|
+
* dampingFraction)` — `response = visualDuration`, `dampingFraction =
|
|
2226
|
+
* 1 − bounce` (clamped) — normalized once here, then handed to the
|
|
2227
|
+
* standard constructor. The solver, the `linear()` sampler, and the
|
|
2228
|
+
* live re-seat are identical to the `(response, dampingFraction)`
|
|
2229
|
+
* path: `fromDuration({ visualDuration: d, bounce: b })` is trajectory-
|
|
2230
|
+
* identical to `new SpringProgress({ response: d, dampingFraction: 1 −
|
|
2231
|
+
* b })`.
|
|
2232
|
+
*/
|
|
2233
|
+
static fromDuration(options?: SpringDurationOptions): SpringProgress;
|
|
871
2234
|
get target(): number;
|
|
872
2235
|
get value(): number;
|
|
873
2236
|
get velocity(): number;
|
|
@@ -879,12 +2242,18 @@ export declare class SpringProgress {
|
|
|
879
2242
|
*/
|
|
880
2243
|
set target(value: number);
|
|
881
2244
|
private reseatTarget;
|
|
2245
|
+
/** Reduced-motion snap: jump to target at zero velocity, settle, emit once. */
|
|
2246
|
+
private _snapSettled;
|
|
882
2247
|
/**
|
|
883
|
-
*
|
|
884
|
-
*
|
|
885
|
-
*
|
|
2248
|
+
* THE canonical step: advance by `dt` MILLISECONDS — the {@link Tickable}
|
|
2249
|
+
* surface the shared `RAFPlayback.drive` loop steps, and the one unit
|
|
2250
|
+
* every stepper's public step takes. Returns the new value.
|
|
2251
|
+
*
|
|
2252
|
+
* The spring math is in seconds; this converts and delegates to the
|
|
2253
|
+
* private analytic stepper {@link _stepSeconds}.
|
|
886
2254
|
*/
|
|
887
|
-
|
|
2255
|
+
tickDt(dt: number): number;
|
|
2256
|
+
/* Excluded from this release type: _stepSeconds */
|
|
888
2257
|
/**
|
|
889
2258
|
* Evaluate the solver at elapsed time `t` (seconds) from the most
|
|
890
2259
|
* recent target re-seat. Equivalent to `tick(t - elapsed)` but
|
|
@@ -927,8 +2296,12 @@ export declare class SpringProgress {
|
|
|
927
2296
|
play(onFrame?: SpringFrameCallback): void;
|
|
928
2297
|
/** Cancel the managed rAF loop and detach the per-frame callback. */
|
|
929
2298
|
stop(): void;
|
|
2299
|
+
/**
|
|
2300
|
+
* Arm the shared driver: it steps `tickDt(dt)` once per frame until
|
|
2301
|
+
* `settled` flips true, emitting `onFrame` per step. Idempotent —
|
|
2302
|
+
* the driver no-ops while already running.
|
|
2303
|
+
*/
|
|
930
2304
|
private _startLoop;
|
|
931
|
-
private _stopLoop;
|
|
932
2305
|
}
|
|
933
2306
|
|
|
934
2307
|
/**
|
|
@@ -975,24 +2348,34 @@ export declare interface SpringProgressOptions {
|
|
|
975
2348
|
respectReducedMotion: boolean;
|
|
976
2349
|
}
|
|
977
2350
|
|
|
2351
|
+
/**
|
|
2352
|
+
* Spring-eased scale-in entrance — the canonical iOS "pop" with overshoot.
|
|
2353
|
+
* Uses the bouncy spring (ζ 0.5) so the element settles past 1 before resting.
|
|
2354
|
+
*/
|
|
2355
|
+
declare const springScaleIn: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
2356
|
+
|
|
2357
|
+
/** Spring-eased slide-up entrance — the snappy spring (ζ 0.78). */
|
|
2358
|
+
declare const springSlideIn: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
2359
|
+
|
|
978
2360
|
/** Subscriber callback. Receives current position + velocity each emission. */
|
|
979
2361
|
export declare type SpringSubscriber = (value: number, velocity: number) => void;
|
|
980
2362
|
|
|
981
2363
|
/**
|
|
982
|
-
* Sample a `SpringProgress(target=1, initial=0)` solver and return a
|
|
983
|
-
*
|
|
984
|
-
* `ElementMorph`, `NumericAnimation`, and
|
|
985
|
-
* directly
|
|
2364
|
+
* Sample a `SpringProgress(target=1, initial=0)` solver and return a typed
|
|
2365
|
+
* {@link Easing}: `.fn` is the callable curve — `(t: number) => number`
|
|
2366
|
+
* over t∈[0,1] — that `ElementMorph`, `NumericAnimation`, and
|
|
2367
|
+
* `Animation.addFrame` accept directly, and `.css` is the CSS `linear()`
|
|
2368
|
+
* string that reproduces it (same solver, same preset), so a WAAPI
|
|
2369
|
+
* delegation runs the true overshoot/settle on the compositor.
|
|
986
2370
|
*
|
|
987
2371
|
* This is the JS-easing sibling of `springLinearStops`: same solver,
|
|
988
2372
|
* same `(response, dampingFraction)` surface, same default
|
|
989
2373
|
* `maxDuration = response * 4`. Where `springLinearStops` emits a CSS
|
|
990
|
-
* `linear()` string for stylesheets/tokens, this returns
|
|
991
|
-
* code paths that drive interpolation directly
|
|
992
|
-
* `linear()` string.
|
|
2374
|
+
* `linear()` string for stylesheets/tokens, this returns the typed pair
|
|
2375
|
+
* for code paths that drive interpolation directly.
|
|
993
2376
|
*
|
|
994
|
-
* The
|
|
995
|
-
*
|
|
2377
|
+
* The curve satisfies `fn(0) = 0` and `fn(1) = 1` exactly. Interior
|
|
2378
|
+
* values may exceed 1 for ζ < 1 (overshoot) — e.g. the bouncy
|
|
996
2379
|
* `response 0.5 / ζ 0.45` preset peaks at ≈ 1.205 mid-curve — which is
|
|
997
2380
|
* the whole point: feeding this into `ElementMorph` produces the
|
|
998
2381
|
* canonical iOS spring overshoot without hand-rolling stops or a
|
|
@@ -1002,7 +2385,7 @@ export declare type SpringSubscriber = (value: number, velocity: number) => void
|
|
|
1002
2385
|
* const spring = springTimingFunction({ response: 0.5, dampingFraction: 0.45 });
|
|
1003
2386
|
* const morph = new ElementMorph(from, to, { timingFunction: spring });
|
|
1004
2387
|
*/
|
|
1005
|
-
export declare function springTimingFunction(opts: SpringTimingFunctionOptions):
|
|
2388
|
+
export declare function springTimingFunction(opts: SpringTimingFunctionOptions): Easing;
|
|
1006
2389
|
|
|
1007
2390
|
/**
|
|
1008
2391
|
* Options for sampling a spring response curve into a callable
|
|
@@ -1036,49 +2419,108 @@ export declare interface SpringTimingFunctionOptions {
|
|
|
1036
2419
|
maxDuration?: number;
|
|
1037
2420
|
}
|
|
1038
2421
|
|
|
2422
|
+
/** Spring-eased wobble — gentle spring (ζ 0.95) for a soft attention nudge. */
|
|
2423
|
+
declare const springWobble: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
2424
|
+
|
|
2425
|
+
/**
|
|
2426
|
+
* Build a per-index delay generator. Pure construction-time — the returned
|
|
2427
|
+
* function does only arithmetic, so it costs nothing on the hot path.
|
|
2428
|
+
*
|
|
2429
|
+
* @param countOrItems — the run length, or an array whose `.length` is used.
|
|
2430
|
+
* @param options — `{ each, from, ease }`; see {@link StaggerOptions}.
|
|
2431
|
+
*/
|
|
2432
|
+
export declare function stagger(countOrItems: number | ArrayLike<unknown>, options?: StaggerOptions): StaggerFn;
|
|
2433
|
+
|
|
2434
|
+
/**
|
|
2435
|
+
* A per-index delay function: `(i, total) => delayMs`. Carries a
|
|
2436
|
+
* `.delays(total)` helper that materializes the whole distribution as an
|
|
2437
|
+
* array — convenient when the count is known up front.
|
|
2438
|
+
*/
|
|
2439
|
+
export declare interface StaggerFn {
|
|
2440
|
+
(index: number, total: number): number;
|
|
2441
|
+
/** Materialize the delays for a run of `total` indices. */
|
|
2442
|
+
delays(total: number): number[];
|
|
2443
|
+
}
|
|
2444
|
+
|
|
2445
|
+
export declare interface StaggerOptions {
|
|
2446
|
+
/**
|
|
2447
|
+
* Per-step delay in milliseconds — the increment between adjacent indices
|
|
2448
|
+
* for a linear `from: "first"` ramp, and the unit the whole distribution
|
|
2449
|
+
* scales by. Defaults to `100`.
|
|
2450
|
+
*/
|
|
2451
|
+
each?: number;
|
|
2452
|
+
/** The origin of the distribution. Defaults to `"first"`. */
|
|
2453
|
+
from?: StaggerOrigin;
|
|
2454
|
+
/**
|
|
2455
|
+
* Reshapes the (normalized) distance-from-origin distribution before it is
|
|
2456
|
+
* scaled by `each` — a callable {@link TimingFunction} or a typed
|
|
2457
|
+
* {@link Easing}, value.js-free. A string easing NAME is rejected; resolve
|
|
2458
|
+
* it up front via `await resolveEasing(name)`. Defaults to the identity
|
|
2459
|
+
* (a linear distribution).
|
|
2460
|
+
*/
|
|
2461
|
+
ease?: TimingFunction | Easing;
|
|
2462
|
+
}
|
|
2463
|
+
|
|
2464
|
+
/**
|
|
2465
|
+
* Where the stagger originates — the index whose delay is zero, from which
|
|
2466
|
+
* the per-step delay grows outward:
|
|
2467
|
+
*
|
|
2468
|
+
* - `"first"` — index 0 (the default); a monotone ramp `0, each, 2·each, …`.
|
|
2469
|
+
* - `"last"` — the final index; the ramp reversed.
|
|
2470
|
+
* - `"center"`— the midpoint; symmetric, growing toward both ends.
|
|
2471
|
+
* - `"edges"` — both ends at zero; symmetric, growing toward the center.
|
|
2472
|
+
* - a numeric index — an explicit origin; symmetric distance from it.
|
|
2473
|
+
*/
|
|
2474
|
+
export declare type StaggerOrigin = "first" | "last" | "center" | "edges" | number;
|
|
2475
|
+
|
|
1039
2476
|
export declare interface TemplateAnimationFrame<V extends Vars> {
|
|
1040
2477
|
id: number;
|
|
1041
2478
|
start: ValueUnit;
|
|
1042
2479
|
vars: V;
|
|
1043
2480
|
transform?: TransformFunction<V>;
|
|
1044
|
-
timingFunction?:
|
|
2481
|
+
timingFunction?: Easing;
|
|
2482
|
+
}
|
|
2483
|
+
|
|
2484
|
+
declare const textFocusBlur: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
2485
|
+
|
|
2486
|
+
/**
|
|
2487
|
+
* A dt-driven stepper the {@link RAFPlayback.drive} loop can own:
|
|
2488
|
+
* `SmoothProgress` and `SpringProgress` implement it directly. The driver
|
|
2489
|
+
* steps `tickDt(dt)` once per frame until `settled` flips true.
|
|
2490
|
+
*/
|
|
2491
|
+
export declare interface Tickable {
|
|
2492
|
+
/** Advance the stepper by `dt` milliseconds; returns the new value. */
|
|
2493
|
+
tickDt(dt: number): number;
|
|
2494
|
+
/** True when the stepper has converged — the driver stops the loop. */
|
|
2495
|
+
readonly settled: boolean;
|
|
1045
2496
|
}
|
|
1046
2497
|
|
|
1047
2498
|
export declare abstract class Timeline {
|
|
1048
2499
|
private smoother;
|
|
1049
|
-
private
|
|
2500
|
+
private _easingFn;
|
|
1050
2501
|
private currentProgress;
|
|
1051
2502
|
private boundaryEpsilon;
|
|
1052
2503
|
constructor(options?: TimelineOptions);
|
|
1053
|
-
/**
|
|
1054
|
-
* Resolve a pending string easing *name* through the dynamic engine
|
|
1055
|
-
* boundary. No-op (resolved promise) for callable / omitted easing.
|
|
1056
|
-
* Resolution is already kicked off eagerly at construction; `await
|
|
1057
|
-
* timeline.ready()` before the first `tick()` to apply the eased value
|
|
1058
|
-
* immediately rather than letting it land asynchronously.
|
|
1059
|
-
*/
|
|
1060
|
-
ready(): Promise<void>;
|
|
1061
2504
|
/** Subclass returns raw [0,1] progress from its source. */
|
|
1062
2505
|
protected abstract sample(): number;
|
|
1063
2506
|
/**
|
|
1064
2507
|
* Shared progress pipeline: sample → clamp → easing → boundary snap.
|
|
1065
2508
|
* Returns the processed raw value. Does NOT advance the smoother —
|
|
1066
|
-
*
|
|
1067
|
-
* time-step method.
|
|
2509
|
+
* `_advance` drives it.
|
|
1068
2510
|
*/
|
|
1069
2511
|
private applyPipeline;
|
|
1070
2512
|
/**
|
|
1071
|
-
*
|
|
1072
|
-
*
|
|
2513
|
+
* Shared advance step: pipeline → ONE `setTarget` → ONE branch. At a
|
|
2514
|
+
* boundary ([0,1]) the smoother snaps for instant convergence; in the
|
|
2515
|
+
* interior it steps `tickDt(dt)` (the canonical ms step). Returns the
|
|
2516
|
+
* resulting progress.
|
|
1073
2517
|
*/
|
|
1074
|
-
private
|
|
2518
|
+
private _advance;
|
|
1075
2519
|
/**
|
|
1076
|
-
*
|
|
1077
|
-
*
|
|
1078
|
-
*
|
|
2520
|
+
* Advance one frame at a nominal 60fps step. Applies
|
|
2521
|
+
* easing → boundary snap → smoothing. Use {@link tickDt} when you own
|
|
2522
|
+
* a real frame clock.
|
|
1079
2523
|
*/
|
|
1080
|
-
private _advance;
|
|
1081
|
-
/** Advance one frame. Applies easing → boundary snap → smoothing. */
|
|
1082
2524
|
tick(): number;
|
|
1083
2525
|
/** Frame-rate independent variant. `dt` in milliseconds. */
|
|
1084
2526
|
tickDt(dt: number): number;
|
|
@@ -1093,20 +2535,19 @@ export declare abstract class Timeline {
|
|
|
1093
2535
|
|
|
1094
2536
|
export declare interface TimelineOptions {
|
|
1095
2537
|
/**
|
|
1096
|
-
* Easing as a callable `TimingFunction
|
|
1097
|
-
*
|
|
2538
|
+
* Easing as a callable `TimingFunction` or a typed `Easing` — both
|
|
2539
|
+
* synchronous and value.js-free, so the `Timeline` family never touches
|
|
2540
|
+
* the dynamic boundary.
|
|
1098
2541
|
*
|
|
1099
|
-
* A
|
|
2542
|
+
* A string easing *name* is NOT accepted here (fail-explicit: it
|
|
2543
|
+
* throws). Resolve a name once, up front, through the async factory:
|
|
1100
2544
|
*
|
|
1101
|
-
*
|
|
1102
|
-
*
|
|
1103
|
-
*
|
|
1104
|
-
*
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
* `await timeline.ready()` first.
|
|
1108
|
-
*/
|
|
1109
|
-
easing?: TimingFunction | TimingFunctionNames | undefined;
|
|
2545
|
+
* ```ts
|
|
2546
|
+
* const easing = await resolveEasing("ease-out-cubic");
|
|
2547
|
+
* new ScrollTimeline({ easing });
|
|
2548
|
+
* ```
|
|
2549
|
+
*/
|
|
2550
|
+
easing?: TimingFunction | Easing | undefined;
|
|
1110
2551
|
/** SmoothProgress config. `false` disables smoothing. Default: enabled. */
|
|
1111
2552
|
smoothing?: Partial<SmoothProgressOptions> | false | undefined;
|
|
1112
2553
|
/**
|
|
@@ -1123,10 +2564,30 @@ export declare type TimingFunction = (t: number) => number;
|
|
|
1123
2564
|
|
|
1124
2565
|
export declare type TimingFunctionNames = keyof typeof timingFunctions;
|
|
1125
2566
|
|
|
2567
|
+
/**
|
|
2568
|
+
* Normalize a callable or typed easing to {@link Easing}. Synchronous and
|
|
2569
|
+
* value.js-free — the light-engine input normalizer.
|
|
2570
|
+
*/
|
|
2571
|
+
export declare const toEasing: (input: TimingFunction | Easing) => Easing;
|
|
2572
|
+
|
|
1126
2573
|
export declare type TransformFunction<V extends Vars> = (v: V, t: number) => void;
|
|
1127
2574
|
|
|
2575
|
+
declare const typewriter: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
2576
|
+
|
|
2577
|
+
declare const typingCursor: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
2578
|
+
|
|
2579
|
+
/** Thrown when a string easing name cannot be resolved through the registry. */
|
|
2580
|
+
export declare class UnknownEasingError extends Error {
|
|
2581
|
+
readonly easingName: string;
|
|
2582
|
+
constructor(easingName: string);
|
|
2583
|
+
}
|
|
2584
|
+
|
|
1128
2585
|
export declare type Vars<T = any> = {
|
|
1129
2586
|
[arg: string]: number | string | T;
|
|
1130
2587
|
};
|
|
1131
2588
|
|
|
2589
|
+
declare const warpLeft: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
2590
|
+
|
|
2591
|
+
declare const warpRight: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
|
|
2592
|
+
|
|
1132
2593
|
export { }
|