anim-engine 0.3.1 → 0.4.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 -8
- package/dist/animation/create-animation.d.ts +1 -23
- package/dist/animation/create-animation.js +35 -41
- package/dist/animation/create-single-tween.d.ts +39 -0
- package/dist/animation/index.d.ts +1 -0
- package/dist/animation/runner.d.ts +5 -8
- package/dist/animation/runner.js +8 -62
- package/dist/animation/update.d.ts +1 -1
- package/dist/domain/animation.d.ts +40 -0
- package/dist/domain/color.d.ts +2 -0
- package/dist/domain/easing.d.ts +18 -0
- package/dist/{easing → domain}/easing.js +4 -37
- package/dist/domain/index.d.ts +10 -0
- package/dist/domain/interpolation.d.ts +35 -0
- package/dist/domain/resolve-value.d.ts +2 -0
- package/dist/domain/resolve-value.js +4 -0
- package/dist/domain/ticker.d.ts +8 -0
- package/dist/domain/timeline.d.ts +21 -0
- package/dist/index.d.ts +10 -17
- package/dist/index.js +7 -6
- package/dist/lerp/create-lerp.d.ts +1 -8
- package/dist/lerp/create-lerp.js +15 -15
- package/dist/lerp/index.d.ts +1 -0
- package/dist/lerp-rgba/hex-to-rgba.d.ts +13 -0
- package/dist/lerp-rgba/hex-to-rgba.js +48 -0
- package/dist/lerp-rgba/index.d.ts +2 -0
- package/dist/lerp-rgba/lerp-rgba.d.ts +13 -0
- package/dist/{color/lerp-oklab.js → lerp-rgba/lerp-rgba.js} +3 -48
- package/dist/smooth-clamp/{smooth-clamp.js → create-smooth-clamp.js} +1 -1
- package/dist/smooth-clamp/index.d.ts +1 -0
- package/dist/smooth-damp/create-smooth-damp.d.ts +1 -9
- package/dist/smooth-damp/create-smooth-damp.js +1 -1
- package/dist/smooth-damp/index.d.ts +1 -0
- package/dist/spring/create-spring.d.ts +1 -10
- package/dist/spring/create-spring.js +1 -1
- package/dist/spring/index.d.ts +1 -0
- package/dist/ticker/get-ticker.d.ts +16 -4
- package/dist/ticker/get-ticker.js +72 -2
- package/dist/ticker/index.d.ts +1 -0
- package/dist/timeline/create-timeline.d.ts +1 -21
- package/dist/timeline/create-timeline.js +8 -11
- package/dist/timeline/index.d.ts +1 -0
- package/package.json +3 -2
- package/dist/color/lerp-oklab.d.ts +0 -26
- package/dist/easing/easing.d.ts +0 -16
- package/dist/shared/internal.d.ts +0 -4
- package/dist/shared/types.d.ts +0 -28
- package/dist/ticker/ticker.d.ts +0 -22
- package/dist/ticker/ticker.js +0 -74
- /package/dist/smooth-clamp/{smooth-clamp.d.ts → create-smooth-clamp.d.ts} +0 -0
package/dist/shared/types.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export type EaseName = "linear" | "inQuad" | "outQuad" | "inOutQuad" | "inCubic" | "outCubic" | "inOutCubic" | "inQuart" | "outQuart" | "inOutQuart" | "inQuint" | "outQuint" | "inOutQuint" | "inSine" | "outSine" | "inOutSine" | "inExpo" | "outExpo" | "inOutExpo" | "inCirc" | "outCirc" | "inOutCirc" | "inBack" | "outBack" | "inOutBack" | "inElastic" | "outElastic" | "inOutElastic" | "inBounce" | "outBounce" | "inOutBounce";
|
|
2
|
-
export type EaseFunction = (t: number) => number;
|
|
3
|
-
export type AnimationStatus = "playing" | "paused" | "stopped" | "dead";
|
|
4
|
-
export type InterpolationStatus = "active" | "inactive" | "dead";
|
|
5
|
-
export type DynamicValue = number | (() => number);
|
|
6
|
-
export type Animation = {
|
|
7
|
-
play: () => Promise<Animation>;
|
|
8
|
-
pause: () => void;
|
|
9
|
-
resume: () => void;
|
|
10
|
-
stop: () => void;
|
|
11
|
-
skipToEnd: () => void;
|
|
12
|
-
kill: () => void;
|
|
13
|
-
currentValue: number;
|
|
14
|
-
velocity: number;
|
|
15
|
-
progress: number;
|
|
16
|
-
setProgress: (value: number) => void;
|
|
17
|
-
status: AnimationStatus;
|
|
18
|
-
durationMs: number;
|
|
19
|
-
};
|
|
20
|
-
export type Interpolation = {
|
|
21
|
-
start: () => void;
|
|
22
|
-
stop: () => void;
|
|
23
|
-
kill: () => void;
|
|
24
|
-
setCurrentValue: (value: number) => void;
|
|
25
|
-
currentValue: number;
|
|
26
|
-
velocity: number;
|
|
27
|
-
status: InterpolationStatus;
|
|
28
|
-
};
|
package/dist/ticker/ticker.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export type TickHandler = (deltaMs: number) => void;
|
|
2
|
-
export type TickerControls = {
|
|
3
|
-
start: () => void;
|
|
4
|
-
stop: () => void;
|
|
5
|
-
update: (deltaMs: number) => void;
|
|
6
|
-
add: (handler: TickHandler) => void;
|
|
7
|
-
remove: (handler: TickHandler) => void;
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* Create a ticker that drives active animations.
|
|
11
|
-
*
|
|
12
|
-
* Does NOT auto-start. The user must explicitly call either:
|
|
13
|
-
* - `start()` — begins a `requestAnimationFrame` loop
|
|
14
|
-
* - `update(deltaMs)` — drive manually from a game loop
|
|
15
|
-
*
|
|
16
|
-
* `add()` and `remove()` register/unregister animations without
|
|
17
|
-
* side effects on the rAF loop.
|
|
18
|
-
*
|
|
19
|
-
* Uses a flat array with undefined-tombstone removal for safe concurrent
|
|
20
|
-
* modification during iteration. Compacted after each frame.
|
|
21
|
-
*/
|
|
22
|
-
export declare const createTicker: () => TickerControls;
|
package/dist/ticker/ticker.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
//#region src/ticker/ticker.ts
|
|
2
|
-
/**
|
|
3
|
-
* Create a ticker that drives active animations.
|
|
4
|
-
*
|
|
5
|
-
* Does NOT auto-start. The user must explicitly call either:
|
|
6
|
-
* - `start()` — begins a `requestAnimationFrame` loop
|
|
7
|
-
* - `update(deltaMs)` — drive manually from a game loop
|
|
8
|
-
*
|
|
9
|
-
* `add()` and `remove()` register/unregister animations without
|
|
10
|
-
* side effects on the rAF loop.
|
|
11
|
-
*
|
|
12
|
-
* Uses a flat array with undefined-tombstone removal for safe concurrent
|
|
13
|
-
* modification during iteration. Compacted after each frame.
|
|
14
|
-
*/
|
|
15
|
-
var createTicker = () => {
|
|
16
|
-
const activeAnimations = [];
|
|
17
|
-
let needsCompact = false;
|
|
18
|
-
let animationFrameRequestId = void 0;
|
|
19
|
-
let previousFrameTime = void 0;
|
|
20
|
-
const start = () => {
|
|
21
|
-
if (animationFrameRequestId !== void 0) return;
|
|
22
|
-
previousFrameTime = void 0;
|
|
23
|
-
const tick = (now) => {
|
|
24
|
-
if (previousFrameTime !== void 0) {
|
|
25
|
-
const delta = now - previousFrameTime;
|
|
26
|
-
update(delta);
|
|
27
|
-
}
|
|
28
|
-
previousFrameTime = now;
|
|
29
|
-
animationFrameRequestId = requestAnimationFrame(tick);
|
|
30
|
-
};
|
|
31
|
-
animationFrameRequestId = requestAnimationFrame(tick);
|
|
32
|
-
};
|
|
33
|
-
const stop = () => {
|
|
34
|
-
if (animationFrameRequestId !== void 0) {
|
|
35
|
-
cancelAnimationFrame(animationFrameRequestId);
|
|
36
|
-
animationFrameRequestId = void 0;
|
|
37
|
-
}
|
|
38
|
-
previousFrameTime = void 0;
|
|
39
|
-
};
|
|
40
|
-
const update = (deltaMs) => {
|
|
41
|
-
for (let i = 0; i < activeAnimations.length; i++) {
|
|
42
|
-
const anim = activeAnimations[i];
|
|
43
|
-
if (anim) anim(deltaMs);
|
|
44
|
-
}
|
|
45
|
-
if (needsCompact) {
|
|
46
|
-
let writeIndex = 0;
|
|
47
|
-
for (let readIndex = 0; readIndex < activeAnimations.length; readIndex++) {
|
|
48
|
-
const anim = activeAnimations[readIndex];
|
|
49
|
-
if (anim !== void 0) activeAnimations[writeIndex++] = anim;
|
|
50
|
-
}
|
|
51
|
-
activeAnimations.length = writeIndex;
|
|
52
|
-
needsCompact = false;
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
const add = (handler) => {
|
|
56
|
-
activeAnimations.push(handler);
|
|
57
|
-
};
|
|
58
|
-
const remove = (handler) => {
|
|
59
|
-
const index = activeAnimations.indexOf(handler);
|
|
60
|
-
if (index >= 0) {
|
|
61
|
-
activeAnimations[index] = void 0;
|
|
62
|
-
needsCompact = true;
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
return {
|
|
66
|
-
start,
|
|
67
|
-
stop,
|
|
68
|
-
update,
|
|
69
|
-
add,
|
|
70
|
-
remove
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
//#endregion
|
|
74
|
-
export { createTicker };
|
|
File without changes
|