ziko 1.6.1 → 1.7.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.
@@ -0,0 +1,189 @@
1
+ /**
2
+ * Easing function used by animations.
3
+ *
4
+ * @param t - Normalized animation progress value between 0 and 1.
5
+ * @returns The transformed progress value.
6
+ */
7
+ export type EasingFunction = (t: number) => number;
8
+
9
+ /**
10
+ * Configuration options for a TimeAnimation instance.
11
+ */
12
+ export interface TimeAnimationOptions {
13
+ /**
14
+ * Easing function applied to the normalized progress.
15
+ *
16
+ * @default linear
17
+ */
18
+ ease?: EasingFunction;
19
+
20
+ /**
21
+ * Interval step between animation updates in milliseconds.
22
+ *
23
+ * @default 50
24
+ */
25
+ step?: number;
26
+
27
+ /**
28
+ * Initial time offset.
29
+ *
30
+ * @default 0
31
+ */
32
+ t0?: number;
33
+
34
+ /**
35
+ * Automatically start the animation after creation.
36
+ *
37
+ * @default true
38
+ */
39
+ start?: boolean;
40
+
41
+ /**
42
+ * Animation duration in milliseconds.
43
+ *
44
+ * @default 3000
45
+ */
46
+ duration?: number;
47
+ }
48
+
49
+ /**
50
+ * Runtime state of a TimeAnimation instance.
51
+ */
52
+ export interface TimeAnimationState {
53
+ /**
54
+ * Whether the animation is currently running.
55
+ */
56
+ isRunning: boolean;
57
+
58
+ /**
59
+ * Internal interval identifier.
60
+ */
61
+ animationId: ReturnType<typeof setInterval> | null;
62
+
63
+ /**
64
+ * Timestamp when the animation started.
65
+ */
66
+ startTime: number | null;
67
+
68
+ /**
69
+ * Current easing function.
70
+ */
71
+ ease: EasingFunction;
72
+
73
+ /**
74
+ * Interval step duration.
75
+ */
76
+ step: number;
77
+
78
+ /**
79
+ * Whether the animation starts automatically.
80
+ */
81
+ autoStart: boolean;
82
+
83
+ /**
84
+ * Total animation duration.
85
+ */
86
+ duration: number;
87
+ }
88
+
89
+ /**
90
+ * Callback executed on every animation tick.
91
+ *
92
+ * @param animation - Current animation instance.
93
+ */
94
+ export type AnimationCallback = (animation: TimeAnimation) => void;
95
+
96
+ /**
97
+ * Time-based animation controller.
98
+ *
99
+ * Provides start, pause, resume, stop and reset lifecycle methods.
100
+ * The callback receives the animation instance containing the current
101
+ * elapsed time and progress values.
102
+ */
103
+ export declare class TimeAnimation {
104
+ /**
105
+ * Creates a new time animation.
106
+ *
107
+ * @param callback - Function called on each animation step.
108
+ * @param options - Animation configuration.
109
+ */
110
+ constructor(
111
+ callback: AnimationCallback,
112
+ options?: TimeAnimationOptions
113
+ );
114
+
115
+ /**
116
+ * Animation state.
117
+ */
118
+ state: TimeAnimationState;
119
+
120
+ /**
121
+ * Elapsed animation time in milliseconds.
122
+ */
123
+ t: number;
124
+
125
+ /**
126
+ * Normalized progress value between 0 and 1.
127
+ */
128
+ tx: number;
129
+
130
+ /**
131
+ * Eased progress value.
132
+ */
133
+ ty: number;
134
+
135
+ /**
136
+ * Current animation step index.
137
+ */
138
+ i: number;
139
+
140
+ /**
141
+ * Starts or restarts the animation.
142
+ *
143
+ * @returns The current animation instance.
144
+ */
145
+ start(): this;
146
+
147
+ /**
148
+ * Pauses the animation.
149
+ *
150
+ * @returns The current animation instance.
151
+ */
152
+ pause(): this;
153
+
154
+ /**
155
+ * Resumes a paused animation.
156
+ *
157
+ * @returns The current animation instance.
158
+ */
159
+ resume(): this;
160
+
161
+ /**
162
+ * Stops the animation and resets its progress.
163
+ *
164
+ * @returns The current animation instance.
165
+ */
166
+ stop(): this;
167
+
168
+ /**
169
+ * Resets animation progress.
170
+ *
171
+ * @param restart - Whether to restart automatically after reset.
172
+ *
173
+ * @returns The current animation instance.
174
+ */
175
+ reset(restart?: boolean): this;
176
+ }
177
+
178
+ /**
179
+ * Creates a time-based animation instance.
180
+ *
181
+ * @param callback - Function executed on every animation tick.
182
+ * @param options - Animation configuration.
183
+ *
184
+ * @returns A new TimeAnimation instance.
185
+ */
186
+ export declare const animation: (
187
+ callback: AnimationCallback,
188
+ options?: TimeAnimationOptions
189
+ ) => TimeAnimation;
@@ -1,4 +1,5 @@
1
1
  export type * from './ease/index.d.ts'
2
2
  export type * from './clocks/index.d.ts'
3
3
  export type * from './decorators/index.d.ts'
4
- export type * from './loop/index.d.ts'
4
+ export type * from './loop/index.d.ts'
5
+ export type * from './animation/index.d.ts'