@mkbabb/keyframes.js 1.1.6 → 1.2.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/LICENSE +21 -674
- package/dist/keyframes.d.ts +232 -0
- package/dist/keyframes.js +867 -5239
- package/package.json +5 -13
- package/dist/keyframes.cjs +0 -27
package/dist/keyframes.d.ts
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
|
+
import { bezierPresets } from '@mkbabb/value.js';
|
|
2
|
+
import { bounceInEase } from '@mkbabb/value.js';
|
|
3
|
+
import { bounceInEaseHalf } from '@mkbabb/value.js';
|
|
4
|
+
import { bounceInOutEase } from '@mkbabb/value.js';
|
|
5
|
+
import { bounceOutEase } from '@mkbabb/value.js';
|
|
6
|
+
import { bounceOutEaseHalf } from '@mkbabb/value.js';
|
|
7
|
+
import { CSSCubicBezier } from '@mkbabb/value.js';
|
|
8
|
+
import { easeInBounce } from '@mkbabb/value.js';
|
|
9
|
+
import { easeInCirc } from '@mkbabb/value.js';
|
|
10
|
+
import { easeInCubic } from '@mkbabb/value.js';
|
|
11
|
+
import { easeInExpo } from '@mkbabb/value.js';
|
|
12
|
+
import { easeInOutCirc } from '@mkbabb/value.js';
|
|
13
|
+
import { easeInOutCubic } from '@mkbabb/value.js';
|
|
14
|
+
import { easeInOutExpo } from '@mkbabb/value.js';
|
|
15
|
+
import { easeInOutQuad } from '@mkbabb/value.js';
|
|
16
|
+
import { easeInOutSine } from '@mkbabb/value.js';
|
|
17
|
+
import { easeInQuad } from '@mkbabb/value.js';
|
|
18
|
+
import { easeInSine } from '@mkbabb/value.js';
|
|
19
|
+
import { easeOutCirc } from '@mkbabb/value.js';
|
|
20
|
+
import { easeOutCubic } from '@mkbabb/value.js';
|
|
21
|
+
import { easeOutExpo } from '@mkbabb/value.js';
|
|
22
|
+
import { easeOutQuad } from '@mkbabb/value.js';
|
|
23
|
+
import { easeOutSine } from '@mkbabb/value.js';
|
|
1
24
|
import { HueInterpolationMethod } from '@mkbabb/value.js';
|
|
2
25
|
import { InterpolatedVar } from '@mkbabb/value.js';
|
|
26
|
+
import { jumpTerms } from '@mkbabb/value.js';
|
|
27
|
+
import { linear } from '@mkbabb/value.js';
|
|
28
|
+
import { smoothStep3 } from '@mkbabb/value.js';
|
|
29
|
+
import { stepEnd } from '@mkbabb/value.js';
|
|
30
|
+
import { steppedEase } from '@mkbabb/value.js';
|
|
31
|
+
import { stepStart } from '@mkbabb/value.js';
|
|
3
32
|
import { timingFunctions } from '@mkbabb/value.js';
|
|
4
33
|
import { ValueArray } from '@mkbabb/value.js';
|
|
5
34
|
import { ValueUnit } from '@mkbabb/value.js';
|
|
@@ -49,6 +78,11 @@ declare class Animation_2<V extends Vars = any> {
|
|
|
49
78
|
reverse(): this;
|
|
50
79
|
fillForwards(): void;
|
|
51
80
|
fillBackwards(): void;
|
|
81
|
+
/**
|
|
82
|
+
* Stateless progress query. Maps [0,1] from first keyframe to last,
|
|
83
|
+
* regardless of playback direction. `apply=true` invokes transform callbacks.
|
|
84
|
+
*/
|
|
85
|
+
at(progress: number, apply?: boolean): Record<string, ValueUnit[]>;
|
|
52
86
|
interpFrames(t: number, transformFrames?: boolean): Record<string, ValueUnit<any, string | undefined>[]>;
|
|
53
87
|
onStart(): Promise<void>;
|
|
54
88
|
onEnd(): Promise<void>;
|
|
@@ -166,8 +200,22 @@ declare type AnimationOptions = {
|
|
|
166
200
|
hueMethod?: HueInterpolationMethod;
|
|
167
201
|
};
|
|
168
202
|
|
|
203
|
+
export { bezierPresets }
|
|
204
|
+
|
|
169
205
|
declare type BlendMode = "replace" | "add" | "weighted";
|
|
170
206
|
|
|
207
|
+
export { bounceInEase }
|
|
208
|
+
|
|
209
|
+
export { bounceInEaseHalf }
|
|
210
|
+
|
|
211
|
+
export { bounceInOutEase }
|
|
212
|
+
|
|
213
|
+
export { bounceOutEase }
|
|
214
|
+
|
|
215
|
+
export { bounceOutEaseHalf }
|
|
216
|
+
|
|
217
|
+
export { CSSCubicBezier }
|
|
218
|
+
|
|
171
219
|
export declare class CSSKeyframesAnimation<V extends Vars> extends Animation_2<V> {
|
|
172
220
|
constructor(options?: Partial<InputAnimationOptions>, ...targets: HTMLElement[]);
|
|
173
221
|
fromVars(vars: V[], transform?: TransformFunction<V>): this;
|
|
@@ -178,6 +226,58 @@ export declare class CSSKeyframesAnimation<V extends Vars> extends Animation_2<V
|
|
|
178
226
|
|
|
179
227
|
declare const DIRECTIONS: readonly ["normal", "reverse", "alternate", "alternate-reverse"];
|
|
180
228
|
|
|
229
|
+
export { easeInBounce }
|
|
230
|
+
|
|
231
|
+
export { easeInCirc }
|
|
232
|
+
|
|
233
|
+
export { easeInCubic }
|
|
234
|
+
|
|
235
|
+
export { easeInExpo }
|
|
236
|
+
|
|
237
|
+
export { easeInOutCirc }
|
|
238
|
+
|
|
239
|
+
export { easeInOutCubic }
|
|
240
|
+
|
|
241
|
+
export { easeInOutExpo }
|
|
242
|
+
|
|
243
|
+
export { easeInOutQuad }
|
|
244
|
+
|
|
245
|
+
export { easeInOutSine }
|
|
246
|
+
|
|
247
|
+
export { easeInQuad }
|
|
248
|
+
|
|
249
|
+
export { easeInSine }
|
|
250
|
+
|
|
251
|
+
export { easeOutCirc }
|
|
252
|
+
|
|
253
|
+
export { easeOutCubic }
|
|
254
|
+
|
|
255
|
+
export { easeOutExpo }
|
|
256
|
+
|
|
257
|
+
export { easeOutQuad }
|
|
258
|
+
|
|
259
|
+
export { easeOutSine }
|
|
260
|
+
|
|
261
|
+
export declare class ElementMorph {
|
|
262
|
+
private animation;
|
|
263
|
+
private transformOrigin;
|
|
264
|
+
private timingFunction;
|
|
265
|
+
constructor(from: HTMLElement | MorphRect, to: HTMLElement | MorphRect, options?: ElementMorphOptions);
|
|
266
|
+
/** Re-measure source and destination, rebuilding the internal animation. */
|
|
267
|
+
measure(from: HTMLElement | MorphRect, to: HTMLElement | MorphRect): this;
|
|
268
|
+
/** Get raw transform values at the given progress [0, 1]. */
|
|
269
|
+
at(progress: number): MorphValues;
|
|
270
|
+
/** Get a CSS transform string at the given progress [0, 1]. */
|
|
271
|
+
toCSSTransform(progress: number): string;
|
|
272
|
+
/** Apply the morph transform to an element at the given progress [0, 1]. */
|
|
273
|
+
apply(element: HTMLElement, progress: number): void;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export declare interface ElementMorphOptions {
|
|
277
|
+
timingFunction?: TimingFunction | TimingFunctionNames;
|
|
278
|
+
transformOrigin?: string;
|
|
279
|
+
}
|
|
280
|
+
|
|
181
281
|
declare const FILL_MODES: readonly ["none", "forwards", "backwards", "both"];
|
|
182
282
|
|
|
183
283
|
export declare const getAnimationId: (animation: Animation_2 | string) => string;
|
|
@@ -195,8 +295,112 @@ declare type InputAnimationOptions = Partial<{
|
|
|
195
295
|
hueMethod?: HueInterpolationMethod;
|
|
196
296
|
}>;
|
|
197
297
|
|
|
298
|
+
export { jumpTerms }
|
|
299
|
+
|
|
300
|
+
export { linear }
|
|
301
|
+
|
|
302
|
+
export declare class ManualTimeline extends Timeline {
|
|
303
|
+
private value;
|
|
304
|
+
constructor(options?: TimelineOptions);
|
|
305
|
+
/** Set the raw progress value. */
|
|
306
|
+
set(value: number): void;
|
|
307
|
+
protected sample(): number;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
export declare interface MorphRect {
|
|
311
|
+
x: number;
|
|
312
|
+
y: number;
|
|
313
|
+
width: number;
|
|
314
|
+
height: number;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
declare interface MorphValues {
|
|
318
|
+
[key: string]: number;
|
|
319
|
+
translateX: number;
|
|
320
|
+
translateY: number;
|
|
321
|
+
scaleX: number;
|
|
322
|
+
scaleY: number;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export declare class NumericAnimation<T extends Record<string, number>> {
|
|
326
|
+
private keyframes;
|
|
327
|
+
private segments;
|
|
328
|
+
private positions;
|
|
329
|
+
private timingFn;
|
|
330
|
+
private result;
|
|
331
|
+
constructor(keyframes: T[], options?: NumericAnimationOptions);
|
|
332
|
+
private buildSegments;
|
|
333
|
+
private buildSegment;
|
|
334
|
+
/** Map [0, 1] progress to interpolated values. Zero allocation. */
|
|
335
|
+
at(progress: number): T;
|
|
336
|
+
/** Update a keyframe's values in-place, recomputing adjacent segments. */
|
|
337
|
+
updateKeyframe(index: number, values: Partial<T>): this;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export declare interface NumericAnimationOptions {
|
|
341
|
+
timingFunction?: TimingFunction | TimingFunctionNames | undefined;
|
|
342
|
+
/** Explicit positions as percentages [0-100]. Auto-distributes if omitted. */
|
|
343
|
+
positions?: number[] | undefined;
|
|
344
|
+
}
|
|
345
|
+
|
|
198
346
|
declare type ParsedVarMap = Record<string, ValueArray>;
|
|
199
347
|
|
|
348
|
+
export declare class ScrollTimeline extends Timeline {
|
|
349
|
+
private threshold;
|
|
350
|
+
private getScrollY;
|
|
351
|
+
private getViewportHeight;
|
|
352
|
+
constructor(options?: ScrollTimelineOptions);
|
|
353
|
+
protected sample(): number;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export declare interface ScrollTimelineOptions extends TimelineOptions {
|
|
357
|
+
/** Viewport fraction for full progress. Default 0.35. */
|
|
358
|
+
threshold?: number | undefined;
|
|
359
|
+
/** Custom scroll position supplier. Default: window.scrollY. */
|
|
360
|
+
getScrollY?: (() => number) | undefined;
|
|
361
|
+
/** Custom viewport height supplier. Default: window.innerHeight. */
|
|
362
|
+
getViewportHeight?: (() => number) | undefined;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
export declare class SmoothProgress {
|
|
366
|
+
private options;
|
|
367
|
+
private targetValue;
|
|
368
|
+
private currentValue;
|
|
369
|
+
private isSettled;
|
|
370
|
+
constructor(options?: Partial<SmoothProgressOptions>);
|
|
371
|
+
get target(): number;
|
|
372
|
+
get current(): number;
|
|
373
|
+
get settled(): boolean;
|
|
374
|
+
setTarget(target: number): void;
|
|
375
|
+
/** Advance one step using fixed damping. Returns current value. */
|
|
376
|
+
tick(): number;
|
|
377
|
+
/** Frame-rate independent tick. dt is in milliseconds. */
|
|
378
|
+
tickDt(dt: number): number;
|
|
379
|
+
/** Immediately set current = target. */
|
|
380
|
+
snap(): void;
|
|
381
|
+
/** Reset to a specific value (default 0). */
|
|
382
|
+
reset(value?: number): void;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
export declare interface SmoothProgressOptions {
|
|
386
|
+
/** Damping factor (0, 1]. Higher = faster convergence. Default 0.1 */
|
|
387
|
+
damping: number;
|
|
388
|
+
/** Snap to target when |target - current| < threshold. Default 0.001 */
|
|
389
|
+
snapThreshold: number;
|
|
390
|
+
/** Starting value. Default 0 */
|
|
391
|
+
initial: number;
|
|
392
|
+
/** Clamp current to [0, 1]. Default true */
|
|
393
|
+
clamp: boolean;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
export { smoothStep3 }
|
|
397
|
+
|
|
398
|
+
export { stepEnd }
|
|
399
|
+
|
|
400
|
+
export { steppedEase }
|
|
401
|
+
|
|
402
|
+
export { stepStart }
|
|
403
|
+
|
|
200
404
|
declare interface TemplateAnimationFrame<V extends Vars> {
|
|
201
405
|
id: number;
|
|
202
406
|
start: ValueUnit;
|
|
@@ -205,10 +409,38 @@ declare interface TemplateAnimationFrame<V extends Vars> {
|
|
|
205
409
|
timingFunction?: TimingFunction;
|
|
206
410
|
}
|
|
207
411
|
|
|
412
|
+
export declare abstract class Timeline {
|
|
413
|
+
private smoother;
|
|
414
|
+
private easingFn;
|
|
415
|
+
private currentProgress;
|
|
416
|
+
constructor(options?: TimelineOptions);
|
|
417
|
+
/** Subclass returns raw [0,1] progress from its source. */
|
|
418
|
+
protected abstract sample(): number;
|
|
419
|
+
/** Advance one frame. Applies easing -> boundary snap -> smoothing. */
|
|
420
|
+
tick(): number;
|
|
421
|
+
/** Frame-rate independent variant. dt in ms. */
|
|
422
|
+
tickDt(dt: number): number;
|
|
423
|
+
get progress(): number;
|
|
424
|
+
/** True if no smoother or smoother is settled. */
|
|
425
|
+
get settled(): boolean;
|
|
426
|
+
/** Immediately converge smoother to current target. */
|
|
427
|
+
snap(): void;
|
|
428
|
+
/** Reset progress to a specific value (default 0). */
|
|
429
|
+
reset(value?: number): void;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
export declare interface TimelineOptions {
|
|
433
|
+
easing?: TimingFunction | TimingFunctionNames | undefined;
|
|
434
|
+
/** SmoothProgress config. `false` disables smoothing. Default: enabled. */
|
|
435
|
+
smoothing?: Partial<SmoothProgressOptions> | false | undefined;
|
|
436
|
+
}
|
|
437
|
+
|
|
208
438
|
declare type TimingFunction = (t: number) => number;
|
|
209
439
|
|
|
210
440
|
declare type TimingFunctionNames = keyof typeof timingFunctions;
|
|
211
441
|
|
|
442
|
+
export { timingFunctions }
|
|
443
|
+
|
|
212
444
|
declare type TransformFunction<V extends Vars> = (v: V, t: number) => void;
|
|
213
445
|
|
|
214
446
|
declare type Vars<T = any> = {
|