@thednp/tween 0.0.1 → 0.0.3
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 +112 -109
- package/dist/preact/preact.d.mts +62 -0
- package/dist/preact/preact.d.mts.map +1 -0
- package/dist/preact/preact.mjs +181 -0
- package/dist/preact/preact.mjs.map +1 -0
- package/dist/react/react.d.mts +62 -0
- package/dist/react/react.d.mts.map +1 -0
- package/dist/react/react.mjs +183 -0
- package/dist/react/react.mjs.map +1 -0
- package/dist/solid/solid.d.mts +60 -0
- package/dist/solid/solid.d.mts.map +1 -0
- package/dist/solid/solid.mjs +157 -0
- package/dist/solid/solid.mjs.map +1 -0
- package/dist/svelte/svelte.d.mts.map +1 -0
- package/dist/svelte/svelte.mjs.map +1 -0
- package/dist/svelte/tween.svelte.d.ts +58 -0
- package/dist/svelte/tween.svelte.js +156 -0
- package/dist/tween/index.d.mts +939 -0
- package/dist/tween/index.d.mts.map +1 -0
- package/dist/tween/index.mjs +1929 -0
- package/dist/tween/index.mjs.map +1 -0
- package/dist/tween.min.js +8 -0
- package/dist/tween.min.js.map +1 -0
- package/dist/vue/vue.d.mts +61 -0
- package/dist/vue/vue.d.mts.map +1 -0
- package/dist/vue/vue.mjs +157 -0
- package/dist/vue/vue.mjs.map +1 -0
- package/package.json +49 -40
- package/dist/index.cjs +0 -621
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -184
- package/dist/index.d.mts +0 -184
- package/dist/index.mjs +0 -610
- package/dist/index.mjs.map +0 -1
- package/dist/react.cjs +0 -61
- package/dist/react.cjs.map +0 -1
- package/dist/react.d.cts +0 -9
- package/dist/react.d.mts +0 -9
- package/dist/react.mjs +0 -55
- package/dist/react.mjs.map +0 -1
- package/dist/solid.cjs +0 -81
- package/dist/solid.cjs.map +0 -1
- package/dist/solid.d.cts +0 -9
- package/dist/solid.d.mts +0 -9
- package/dist/solid.mjs +0 -75
- package/dist/solid.mjs.map +0 -1
- package/dist/tween.iife.js +0 -2
- package/dist/tween.iife.js.map +0 -1
- package/wiki/Easing.md +0 -58
- package/wiki/React.md +0 -255
- package/wiki/Solid.md +0 -149
- package/wiki/Timeline.md +0 -207
- package/wiki/Tween.md +0 -230
|
@@ -0,0 +1,939 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @thednp/tween v0.0.3 (https://github.com/thednp/tween)
|
|
3
|
+
* Copyright 2026 © thednp
|
|
4
|
+
* Licensed under MIT (https://github.com/thednp/tween/blob/master/LICENSE)
|
|
5
|
+
*/
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
//#region src/Tween.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* Lightweight tween engine for interpolating values over time.
|
|
11
|
+
* Supports numbers and via extensions it enxtends to arrays
|
|
12
|
+
* (e.g. RGB, points), nested objects, and SVG path morphing.
|
|
13
|
+
*
|
|
14
|
+
* @template T - The type of the target object (usually a plain object with numeric properties)
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* const tween = new Tween({ x: 0, opacity: 1 })
|
|
19
|
+
* .to({ x: 300, opacity: 0 })
|
|
20
|
+
* .duration(1.5)
|
|
21
|
+
* .easing(Easing.Elastic.Out)
|
|
22
|
+
* .start();
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @param initialValues The initial values object
|
|
26
|
+
*/
|
|
27
|
+
declare class Tween<T extends TweenProps = TweenProps> {
|
|
28
|
+
state: T;
|
|
29
|
+
private _state;
|
|
30
|
+
private _startIsSet;
|
|
31
|
+
private _repeat;
|
|
32
|
+
private _yoyo;
|
|
33
|
+
private _reversed;
|
|
34
|
+
private _initialRepeat;
|
|
35
|
+
private _startFired;
|
|
36
|
+
private _propsStart;
|
|
37
|
+
private _propsEnd;
|
|
38
|
+
private _isPlaying;
|
|
39
|
+
private _duration;
|
|
40
|
+
private _delay;
|
|
41
|
+
private _pauseStart;
|
|
42
|
+
private _repeatDelay;
|
|
43
|
+
private _startTime;
|
|
44
|
+
private _errors;
|
|
45
|
+
private _interpolators;
|
|
46
|
+
private _validators;
|
|
47
|
+
private _easing;
|
|
48
|
+
private _onUpdate?;
|
|
49
|
+
private _onComplete?;
|
|
50
|
+
private _onStart?;
|
|
51
|
+
private _onStop?;
|
|
52
|
+
private _onPause?;
|
|
53
|
+
private _onResume?;
|
|
54
|
+
private _onRepeat?;
|
|
55
|
+
private _runtime;
|
|
56
|
+
/**
|
|
57
|
+
* Creates a new Tween instance.
|
|
58
|
+
* @param initialValues - The initial state of the animated object
|
|
59
|
+
*/
|
|
60
|
+
constructor(initialValues: T);
|
|
61
|
+
/**
|
|
62
|
+
* A boolean that returns `true` when tween is playing.
|
|
63
|
+
*/
|
|
64
|
+
get isPlaying(): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* A boolean that returns `true` when tween is paused.
|
|
67
|
+
*/
|
|
68
|
+
get isPaused(): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* A boolean that returns `true` when initial values are valid.
|
|
71
|
+
*/
|
|
72
|
+
get isValidState(): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* A boolean that returns `true` when all values are valid.
|
|
75
|
+
*/
|
|
76
|
+
get isValid(): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Returns the configured duration in seconds.
|
|
79
|
+
*/
|
|
80
|
+
getDuration(): number;
|
|
81
|
+
/**
|
|
82
|
+
* Returns the total duration in seconds. It's calculated as a sum of
|
|
83
|
+
* the delay, duration multiplied by repeat value, repeat delay multiplied
|
|
84
|
+
* by repeat value.
|
|
85
|
+
*/
|
|
86
|
+
get totalDuration(): number;
|
|
87
|
+
/**
|
|
88
|
+
* Returns the validator configured for a given property.
|
|
89
|
+
*/
|
|
90
|
+
getValidator(propName: string): ValidationFunction | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* Returns the errors Map, mainly used by external validators.
|
|
93
|
+
*/
|
|
94
|
+
getErrors(): Map<string, string>;
|
|
95
|
+
/**
|
|
96
|
+
* Starts the tween (adds it to the global update loop).
|
|
97
|
+
* Triggers `onStart` if set.
|
|
98
|
+
* @param time - Optional explicit start time (defaults to `now()`)
|
|
99
|
+
* @param overrideStart - If true, resets starting values even if already set
|
|
100
|
+
* @returns this
|
|
101
|
+
*/
|
|
102
|
+
start(time?: number, overrideStart?: boolean): this;
|
|
103
|
+
/**
|
|
104
|
+
* Starts the tween from current values.
|
|
105
|
+
* @param time - Optional explicit start time (defaults to `now()`)
|
|
106
|
+
* @returns this
|
|
107
|
+
*/
|
|
108
|
+
startFromLast(time?: number): this;
|
|
109
|
+
/**
|
|
110
|
+
* Immediately stops the tween and removes it from the update loop.
|
|
111
|
+
* Triggers `onStop` if set.
|
|
112
|
+
* @returns this
|
|
113
|
+
*/
|
|
114
|
+
stop(): this;
|
|
115
|
+
/**
|
|
116
|
+
* Reverses playback direction and mirrors current time position.
|
|
117
|
+
* @returns this
|
|
118
|
+
*/
|
|
119
|
+
reverse(): this;
|
|
120
|
+
/**
|
|
121
|
+
* Pause playback and capture the pause time.
|
|
122
|
+
* @param time - Time of pause
|
|
123
|
+
* @returns this
|
|
124
|
+
*/
|
|
125
|
+
pause(time?: number): this;
|
|
126
|
+
/**
|
|
127
|
+
* Resume playback and reset the pause time.
|
|
128
|
+
* @param time - Time of pause
|
|
129
|
+
* @returns this
|
|
130
|
+
*/
|
|
131
|
+
resume(time?: number): this;
|
|
132
|
+
/**
|
|
133
|
+
* Sets the starting values for properties.
|
|
134
|
+
* @param startValues - Partial object with starting values
|
|
135
|
+
* @returns this
|
|
136
|
+
*/
|
|
137
|
+
from(startValues: Partial<T> | DeepPartial<T>): this;
|
|
138
|
+
/**
|
|
139
|
+
* Sets the ending values for properties.
|
|
140
|
+
* @param endValues - Partial object with target values
|
|
141
|
+
* @returns this
|
|
142
|
+
*/
|
|
143
|
+
to(endValues: Partial<T> | DeepPartial<T>): this;
|
|
144
|
+
/**
|
|
145
|
+
* Sets the duration of the tween in seconds.
|
|
146
|
+
* Internally it's converted to milliseconds.
|
|
147
|
+
* @param duration - Time in seconds
|
|
148
|
+
* @default 1 second
|
|
149
|
+
* @returns this
|
|
150
|
+
*/
|
|
151
|
+
duration(seconds?: number): this;
|
|
152
|
+
/**
|
|
153
|
+
* Sets the delay in seconds before the tween starts.
|
|
154
|
+
* Internally it's converted to milliseconds.
|
|
155
|
+
* @param delay - Time in seconds
|
|
156
|
+
* @default 0 seconds
|
|
157
|
+
* @returns this
|
|
158
|
+
*/
|
|
159
|
+
delay(seconds?: number): this;
|
|
160
|
+
/**
|
|
161
|
+
* Sets how many times to repeat.
|
|
162
|
+
* @param times - How many times to repeat
|
|
163
|
+
* @default 0 times
|
|
164
|
+
* @returns this
|
|
165
|
+
*/
|
|
166
|
+
repeat(times?: number): this;
|
|
167
|
+
/**
|
|
168
|
+
* Sets a number of seconds to delay the animation
|
|
169
|
+
* after each repeat.
|
|
170
|
+
* @param amount - How many seconds to delay
|
|
171
|
+
* @default 0 seconds
|
|
172
|
+
* @returns this
|
|
173
|
+
*/
|
|
174
|
+
repeatDelay(amount?: number): this;
|
|
175
|
+
/**
|
|
176
|
+
* Sets to tween from end to start values.
|
|
177
|
+
* The easing is also goes backwards.
|
|
178
|
+
* This requires repeat value of at least 1.
|
|
179
|
+
* @param yoyo - When `true` values are reversed on every uneven repeat
|
|
180
|
+
* @default false
|
|
181
|
+
* @returns this
|
|
182
|
+
*/
|
|
183
|
+
yoyo(yoyo?: boolean): this;
|
|
184
|
+
/**
|
|
185
|
+
* Sets the easing function.
|
|
186
|
+
* @param easing - Function that maps progress [0,1] → eased progress [0,1]
|
|
187
|
+
* @default linear
|
|
188
|
+
* @returns this
|
|
189
|
+
*/
|
|
190
|
+
easing(easing?: EasingFunction): this;
|
|
191
|
+
/**
|
|
192
|
+
* Registers a callback fired when `.start()` is called.
|
|
193
|
+
* @param callback - Receives state at start time
|
|
194
|
+
* @returns this
|
|
195
|
+
*/
|
|
196
|
+
onStart(callback: TweenCallback<T>): this;
|
|
197
|
+
/**
|
|
198
|
+
* Registers a callback fired on every frame.
|
|
199
|
+
* @param callback - Receives current state, elapsed (0–1)
|
|
200
|
+
* @returns this
|
|
201
|
+
*/
|
|
202
|
+
onUpdate(callback?: TweenUpdateCallback<T>): this;
|
|
203
|
+
/**
|
|
204
|
+
* Registers a callback fired when the tween reaches progress = 1.
|
|
205
|
+
* @param callback - Receives final state
|
|
206
|
+
* @returns this
|
|
207
|
+
*/
|
|
208
|
+
onComplete(callback: TweenCallback<T>): this;
|
|
209
|
+
/**
|
|
210
|
+
* Registers a callback fired when `.stop()` is called.
|
|
211
|
+
* @param callback - Receives state at stop time
|
|
212
|
+
* @returns this
|
|
213
|
+
*/
|
|
214
|
+
onStop(callback: TweenCallback<T>): this;
|
|
215
|
+
/**
|
|
216
|
+
* Registers a callback fired when `pause()` was called.
|
|
217
|
+
*/
|
|
218
|
+
onPause(cb: TweenCallback<T>): this;
|
|
219
|
+
/**
|
|
220
|
+
* Registers a callback fired when `.resume()` was called.
|
|
221
|
+
*/
|
|
222
|
+
onResume(cb: TweenCallback<T>): this;
|
|
223
|
+
/**
|
|
224
|
+
* Registers a callback that is invoked **every time** one full cycle
|
|
225
|
+
* (repeat iteration) * of the tween has completed — but **before**
|
|
226
|
+
* the next repeat begins (if any remain).
|
|
227
|
+
*
|
|
228
|
+
* This is different from `onComplete`, which only fires once at the
|
|
229
|
+
* very end of the entire tween (after all repeats are finished).
|
|
230
|
+
*/
|
|
231
|
+
onRepeat(cb?: TweenCallback<T>): this;
|
|
232
|
+
/**
|
|
233
|
+
* Manually advances the tween to the given time.
|
|
234
|
+
* @param time - Current absolute time (performance.now style)
|
|
235
|
+
*
|
|
236
|
+
* @returns `true` if the tween is still playing after the update, `false`
|
|
237
|
+
* otherwise.
|
|
238
|
+
*/
|
|
239
|
+
update(time?: number): boolean;
|
|
240
|
+
/**
|
|
241
|
+
* Public method to register an extension for a given property.
|
|
242
|
+
*
|
|
243
|
+
* **NOTES**
|
|
244
|
+
* - the extension will validate the initial values once `.use()` is called.
|
|
245
|
+
* - the `.use()` method must be called before `.to()` / `.from()`.
|
|
246
|
+
*
|
|
247
|
+
* @param property The property name
|
|
248
|
+
* @param extension The extension object
|
|
249
|
+
* @returns this
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
*
|
|
253
|
+
* const tween = new Tween({ myProp: { x: 0, y: 0 } });
|
|
254
|
+
* tween.use("myProp", objectConfig);
|
|
255
|
+
*/
|
|
256
|
+
use(property: string, {
|
|
257
|
+
interpolate,
|
|
258
|
+
validate
|
|
259
|
+
}: PropConfig): this;
|
|
260
|
+
/**
|
|
261
|
+
* Internal method to reset state to initial values.
|
|
262
|
+
* @internal
|
|
263
|
+
*/
|
|
264
|
+
private _resetState;
|
|
265
|
+
/**
|
|
266
|
+
* Reset starting values, end values and runtime.
|
|
267
|
+
*/
|
|
268
|
+
clear(): this;
|
|
269
|
+
/**
|
|
270
|
+
* Internal method to handle instrumentation of start and end values for interpolation.
|
|
271
|
+
* @internal
|
|
272
|
+
*/
|
|
273
|
+
private _setProps;
|
|
274
|
+
/**
|
|
275
|
+
* Internal method to handle validation of initial values, start and end values.
|
|
276
|
+
* @internal
|
|
277
|
+
*/
|
|
278
|
+
private _evaluate;
|
|
279
|
+
/**
|
|
280
|
+
* Internal method to provide feedback on validation issues.
|
|
281
|
+
* @internal
|
|
282
|
+
*/
|
|
283
|
+
private _report;
|
|
284
|
+
}
|
|
285
|
+
//#endregion
|
|
286
|
+
//#region src/Timeline.d.ts
|
|
287
|
+
/**
|
|
288
|
+
* Timeline orchestrates multiple tweens with scheduling, overlaps, labels and repeat.
|
|
289
|
+
* Supports numbers and via extensions it enxtends to arrays
|
|
290
|
+
* (e.g. RGB, points), nested objects, and SVG path morphing.
|
|
291
|
+
*
|
|
292
|
+
* @template T - Type of the animated state object
|
|
293
|
+
*
|
|
294
|
+
* @example
|
|
295
|
+
* ```ts
|
|
296
|
+
* const tl = new Timeline({ x: 0, opacity: 0 })
|
|
297
|
+
* .to({ x: 300, duration: 1.2 })
|
|
298
|
+
* .to({ opacity: 1, duration: 0.8 }, "-=0.4")
|
|
299
|
+
* .play();
|
|
300
|
+
* ```
|
|
301
|
+
*
|
|
302
|
+
* @param initialValues The initial values object
|
|
303
|
+
*/
|
|
304
|
+
declare class Timeline<T extends TweenProps = TweenProps> {
|
|
305
|
+
state: T;
|
|
306
|
+
private _state;
|
|
307
|
+
private _entries;
|
|
308
|
+
private _labels;
|
|
309
|
+
private _progress;
|
|
310
|
+
private _duration;
|
|
311
|
+
private _yoyo;
|
|
312
|
+
private _reversed;
|
|
313
|
+
private _time;
|
|
314
|
+
private _pauseTime;
|
|
315
|
+
private _lastTime;
|
|
316
|
+
private _isPlaying;
|
|
317
|
+
private _repeat;
|
|
318
|
+
private _repeatDelay;
|
|
319
|
+
private _repeatDelayStart;
|
|
320
|
+
private _initialRepeat;
|
|
321
|
+
private _errors;
|
|
322
|
+
private _interpolators;
|
|
323
|
+
private _validators;
|
|
324
|
+
private _onStart?;
|
|
325
|
+
private _onStop?;
|
|
326
|
+
private _onPause?;
|
|
327
|
+
private _onResume?;
|
|
328
|
+
private _onUpdate?;
|
|
329
|
+
private _onComplete?;
|
|
330
|
+
private _onRepeat?;
|
|
331
|
+
/**
|
|
332
|
+
* Creates a new Timeline instance.
|
|
333
|
+
* @param initialValues - The initial state of the animated object
|
|
334
|
+
*/
|
|
335
|
+
constructor(initialValues: T);
|
|
336
|
+
/**
|
|
337
|
+
* Returns the current [0-1] progress value.
|
|
338
|
+
*/
|
|
339
|
+
get progress(): number;
|
|
340
|
+
/**
|
|
341
|
+
* Returns the total duration in seconds.
|
|
342
|
+
*/
|
|
343
|
+
get duration(): number;
|
|
344
|
+
/**
|
|
345
|
+
* Returns the total duration in seconds, which is a sum of all entries duration
|
|
346
|
+
* multiplied by repeat value and repeat delay multiplied by repeat value.
|
|
347
|
+
*/
|
|
348
|
+
get totalDuration(): number;
|
|
349
|
+
/**
|
|
350
|
+
* A boolean that returns `true` when timeline is playing.
|
|
351
|
+
*/
|
|
352
|
+
get isPlaying(): boolean;
|
|
353
|
+
/**
|
|
354
|
+
* A boolean that returns `true` when timeline is paused.
|
|
355
|
+
*/
|
|
356
|
+
get isPaused(): boolean;
|
|
357
|
+
/**
|
|
358
|
+
* A boolean that returns `true` when initial values are valid.
|
|
359
|
+
*/
|
|
360
|
+
get isValidState(): boolean;
|
|
361
|
+
/**
|
|
362
|
+
* A boolean that returns `true` when all values are valid.
|
|
363
|
+
*/
|
|
364
|
+
get isValid(): boolean;
|
|
365
|
+
/**
|
|
366
|
+
* Returns the validator configured for a given property.
|
|
367
|
+
*/
|
|
368
|
+
getValidator(propName: string): ValidationFunction | undefined;
|
|
369
|
+
/**
|
|
370
|
+
* Returns the errors Map, mainly used by external validators.
|
|
371
|
+
*/
|
|
372
|
+
getErrors(): Map<string, string>;
|
|
373
|
+
/**
|
|
374
|
+
* Starts or resumes playback from the beginning (or current time if resumed).
|
|
375
|
+
* Triggers the `onStart` callback if set.
|
|
376
|
+
* @param startTime - Optional explicit start timestamp (defaults to now)
|
|
377
|
+
* @returns this
|
|
378
|
+
*/
|
|
379
|
+
play(time?: number): this;
|
|
380
|
+
/**
|
|
381
|
+
* Pauses playback (preserves current time).
|
|
382
|
+
* Triggers the `onPause` callback if set.
|
|
383
|
+
* @returns this
|
|
384
|
+
*/
|
|
385
|
+
pause(time?: number): this;
|
|
386
|
+
/**
|
|
387
|
+
* Resumes from paused state (adjusts internal clock).
|
|
388
|
+
* Triggers the `onResume` callback if set.
|
|
389
|
+
* @param time - Optional current timestamp (defaults to now)
|
|
390
|
+
* @returns this
|
|
391
|
+
*/
|
|
392
|
+
resume(time?: number): this;
|
|
393
|
+
/**
|
|
394
|
+
* Reverses playback direction and mirrors current time position.
|
|
395
|
+
* @returns this
|
|
396
|
+
*/
|
|
397
|
+
reverse(): this;
|
|
398
|
+
/**
|
|
399
|
+
* Jumps to a specific time or label. When playback is reversed
|
|
400
|
+
* the time is adjusted.
|
|
401
|
+
* @param pointer - Seconds or label name
|
|
402
|
+
* @returns this
|
|
403
|
+
*/
|
|
404
|
+
seek(pointer: number | string): this;
|
|
405
|
+
/**
|
|
406
|
+
* Stops playback, resets time to 0, and restores initial state.
|
|
407
|
+
* Triggers the `onStop` callback if set.
|
|
408
|
+
* @returns this
|
|
409
|
+
*/
|
|
410
|
+
stop(): this;
|
|
411
|
+
/**
|
|
412
|
+
* Sets the number of times the timeline should repeat.
|
|
413
|
+
* @param count - Number of repeats (0 = once, Infinity = loop forever)
|
|
414
|
+
* @returns this
|
|
415
|
+
*/
|
|
416
|
+
repeat(count?: number): this;
|
|
417
|
+
/**
|
|
418
|
+
* Sets a number of seconds to delay the animation
|
|
419
|
+
* after each repeat.
|
|
420
|
+
* @param amount - How many seconds to delay
|
|
421
|
+
* @default 0 seconds
|
|
422
|
+
* @returns this
|
|
423
|
+
*/
|
|
424
|
+
repeatDelay(amount?: number): this;
|
|
425
|
+
/**
|
|
426
|
+
* Sets to Timeline entries to tween from end to start values.
|
|
427
|
+
* The easing is also goes backwards.
|
|
428
|
+
* This requires repeat value of at least 1.
|
|
429
|
+
* @param yoyo - When `true` values are reversed
|
|
430
|
+
* @default false
|
|
431
|
+
* @returns this
|
|
432
|
+
*/
|
|
433
|
+
yoyo(yoyo?: boolean): this;
|
|
434
|
+
/**
|
|
435
|
+
* Adds a named time position for use in `.seek("label")`.
|
|
436
|
+
* @param name - Label identifier
|
|
437
|
+
* @param position - Time offset or relative position
|
|
438
|
+
* @returns this
|
|
439
|
+
*/
|
|
440
|
+
label(name: string, position?: Position): this;
|
|
441
|
+
/**
|
|
442
|
+
* Adds a new tween entry to the timeline.
|
|
443
|
+
* @param config - Values to animate + duration, easing, etc.
|
|
444
|
+
* @param position - Start offset: number, "+=0.5", "-=0.3", or label name
|
|
445
|
+
* @returns this (chainable)
|
|
446
|
+
*/
|
|
447
|
+
to({
|
|
448
|
+
duration,
|
|
449
|
+
easing,
|
|
450
|
+
...values
|
|
451
|
+
}: (Partial<T> | DeepPartial<T>) & TimelineEntryConfig, position?: Position): this;
|
|
452
|
+
/**
|
|
453
|
+
* Registers a callback fired when playback begins.
|
|
454
|
+
*/
|
|
455
|
+
onStart(cb: TimelineCallback<T>): this;
|
|
456
|
+
/**
|
|
457
|
+
* Registers a callback fired when `pause()` was called.
|
|
458
|
+
*/
|
|
459
|
+
onPause(cb: TimelineCallback<T>): this;
|
|
460
|
+
/**
|
|
461
|
+
* Registers a callback fired when `.play()` / `.resume()` was called.
|
|
462
|
+
*/
|
|
463
|
+
onResume(cb: TimelineCallback<T>): this;
|
|
464
|
+
/**
|
|
465
|
+
* Registers a callback fired on explicit `.stop()`.
|
|
466
|
+
*/
|
|
467
|
+
onStop(cb: TimelineCallback<T>): this;
|
|
468
|
+
/**
|
|
469
|
+
* Registers a callback fired every frame.
|
|
470
|
+
*/
|
|
471
|
+
onUpdate(cb: TimelineCallback<T>): this;
|
|
472
|
+
/**
|
|
473
|
+
* Registers a callback fired when timeline naturally completes.
|
|
474
|
+
*/
|
|
475
|
+
onComplete(cb: TimelineCallback<T>): this;
|
|
476
|
+
/**
|
|
477
|
+
* Registers a callback fired when `.play()` / `.resume()` was called.
|
|
478
|
+
*/
|
|
479
|
+
onRepeat(cb?: TimelineCallback<T>): this;
|
|
480
|
+
/**
|
|
481
|
+
* Public method to register an extension for a given property.
|
|
482
|
+
*
|
|
483
|
+
* **NOTES**
|
|
484
|
+
* - the extension will validate the initial values once `.use()` is called.
|
|
485
|
+
* - the `.use()` method must be called before `.to()`.
|
|
486
|
+
*
|
|
487
|
+
* @param property The property name
|
|
488
|
+
* @param extension The extension object
|
|
489
|
+
* @returns this
|
|
490
|
+
*
|
|
491
|
+
* @example
|
|
492
|
+
*
|
|
493
|
+
* const timeline = new Timeline({ myProp: { x: 0, y: 0 } });
|
|
494
|
+
* timeline.use("myProp", objectConfig);
|
|
495
|
+
*/
|
|
496
|
+
use(property: string, {
|
|
497
|
+
interpolate,
|
|
498
|
+
validate
|
|
499
|
+
}: PropConfig): this;
|
|
500
|
+
/**
|
|
501
|
+
* Manually advances the timeline to the given time.
|
|
502
|
+
* @param time - Current absolute time (performance.now style)
|
|
503
|
+
*
|
|
504
|
+
* @returns `true` if the timeline is still playing after the update, `false`
|
|
505
|
+
* otherwise.
|
|
506
|
+
*/
|
|
507
|
+
update(time?: number): boolean;
|
|
508
|
+
/**
|
|
509
|
+
* Public method to clear all entries, labels and reset timers to zero
|
|
510
|
+
* or initial value (repeat).
|
|
511
|
+
*/
|
|
512
|
+
clear(): this;
|
|
513
|
+
/**
|
|
514
|
+
* Internal method to handle instrumentation of start and end values for interpolation
|
|
515
|
+
* of a tween entry. Only called once per entry on first activation.
|
|
516
|
+
* @internal
|
|
517
|
+
*/
|
|
518
|
+
private _setEntry;
|
|
519
|
+
/**
|
|
520
|
+
* Internal method to revert state to initial values and reset entry flags.
|
|
521
|
+
* @internal
|
|
522
|
+
*/
|
|
523
|
+
private _resetState;
|
|
524
|
+
/**
|
|
525
|
+
* Internal method to resolve the position relative to the current duration
|
|
526
|
+
* or a set value in seconds.
|
|
527
|
+
* @internal
|
|
528
|
+
*/
|
|
529
|
+
private _resolvePosition;
|
|
530
|
+
/**
|
|
531
|
+
* Internal method to handle validation of initial values and entries values.
|
|
532
|
+
* @internal
|
|
533
|
+
*/
|
|
534
|
+
private _evaluate;
|
|
535
|
+
/**
|
|
536
|
+
* Internal method to provide feedback on validation issues.
|
|
537
|
+
* @internal
|
|
538
|
+
*/
|
|
539
|
+
private _report;
|
|
540
|
+
}
|
|
541
|
+
//#endregion
|
|
542
|
+
//#region src/types.d.ts
|
|
543
|
+
type AnimationItem<T extends TweenProps = never> = Tween<T> | Timeline<T>;
|
|
544
|
+
type TimelineCallback<T extends TweenProps> = (state: T, progress: number) => void;
|
|
545
|
+
type TweenUpdateCallback<T extends TweenProps> = (obj: T, elapsed: number) => void;
|
|
546
|
+
type TweenCallback<T extends TweenProps> = (obj: T) => void;
|
|
547
|
+
type EasingFunction = (amount: number) => number;
|
|
548
|
+
type EasingFunctionGroup = {
|
|
549
|
+
In: EasingFunction;
|
|
550
|
+
Out: EasingFunction;
|
|
551
|
+
InOut: EasingFunction;
|
|
552
|
+
};
|
|
553
|
+
type Position = number | string;
|
|
554
|
+
/**
|
|
555
|
+
* Extend Specific
|
|
556
|
+
*/
|
|
557
|
+
type InterpolatorFunction<I extends TweenProps[never] = never> = <T extends I>(target: T, start: T, end: T, t: number) => T;
|
|
558
|
+
type ValidationResultEntry = [true] | [/** prop name */false, /** reason */string];
|
|
559
|
+
type ValidationFunction<I extends Record<string, unknown> = never> = <T extends I[keyof I]>(propName: string, target: T, ref?: T) => ValidationResultEntry;
|
|
560
|
+
type PropConfig = {
|
|
561
|
+
validate: ValidationFunction;
|
|
562
|
+
interpolate: InterpolatorFunction;
|
|
563
|
+
};
|
|
564
|
+
/**
|
|
565
|
+
* TIMELINE
|
|
566
|
+
*/
|
|
567
|
+
interface TimelineEntryConfig {
|
|
568
|
+
duration?: number; // milliseconds (to match your Tween)
|
|
569
|
+
easing?: EasingFunction;
|
|
570
|
+
}
|
|
571
|
+
interface TimelineEntry<T extends TweenProps> {
|
|
572
|
+
to: Partial<T> | DeepPartial<T>;
|
|
573
|
+
from: Partial<T> | DeepPartial<T>;
|
|
574
|
+
startTime: number; // absolute time in milliseconds
|
|
575
|
+
duration: number; // absolute time in milliseconds
|
|
576
|
+
easing: EasingFunction;
|
|
577
|
+
isActive?: boolean;
|
|
578
|
+
runtime: [propValue: T[keyof T], property: string | keyof T, interpolator: InterpolatorFunction, /*| null*/startVal: T[keyof T], endVal: T[keyof T]][];
|
|
579
|
+
}
|
|
580
|
+
type TweenRuntime<T extends TweenProps> = [targetObject: T[keyof T], property: string | keyof T, interpolator: InterpolatorFunction, /*| null*/startVal: T[keyof T], endVal: T[keyof T]];
|
|
581
|
+
/**
|
|
582
|
+
* Nested Objects
|
|
583
|
+
*/
|
|
584
|
+
type DeepObject = Record<string, Record<string, unknown>>;
|
|
585
|
+
type DeepPartial<T> = T extends Record<string, T[keyof T]> ? Partial<T> | { [P in keyof T]?: DeepPartial<T[P]> } : T;
|
|
586
|
+
/**
|
|
587
|
+
* Supported types
|
|
588
|
+
*/
|
|
589
|
+
type ArrayVal = number[] | [string, ...number[]][];
|
|
590
|
+
type BaseTweenProps = Record<string, number>;
|
|
591
|
+
type TweenProps = Record<string, number | ArrayVal | BaseTweenProps | [string, ...(CubicValues | LineValues | QuadValues | Vec3)] /* MorphPathArray | TransformArray*/[]>;
|
|
592
|
+
/**
|
|
593
|
+
* PathArray specific
|
|
594
|
+
*/
|
|
595
|
+
type LineValues = [number, number];
|
|
596
|
+
type CubicValues = [number, number, number, number, number, number];
|
|
597
|
+
type QuadValues = [number, number, number, number];
|
|
598
|
+
type MorphPathSegment = ["M" | "L", ...LineValues] | ["C", ...CubicValues] | ["Z"];
|
|
599
|
+
type PC = "M" | "m" | "L" | "l" | "C" | "c" | "Z" | "z";
|
|
600
|
+
type MorphPathArray = MorphPathSegment[];
|
|
601
|
+
type PathLike = [PC, ...number[]][];
|
|
602
|
+
/**
|
|
603
|
+
* Transform specific
|
|
604
|
+
*/
|
|
605
|
+
type RotateAxisAngle = [originX: number, originY: number, originZ: number, angle: number];
|
|
606
|
+
type Vec3 = [number, number?, number?];
|
|
607
|
+
type RotateZ = [rotateZ: number];
|
|
608
|
+
type Rotate = [rotateX: number, rotateY: number, rotateZ?: number];
|
|
609
|
+
type Translate = [translateX: number, translateY?: number, translateZ?: number];
|
|
610
|
+
type Scale = [scaleX: number, scaleY?: number, scaleZ?: number];
|
|
611
|
+
type TransformStepInternal = ["rotateAxisAngle", ...QuadValues] | ["translate", ...Vec3] | ["rotate", ...Vec3] | ["scale", ...Vec3] | ["skewX", number] | ["skewY", number] | ["perspective", number];
|
|
612
|
+
type TransformStep = ["rotateAxisAngle", ...RotateAxisAngle] | ["translate", ...Translate] | ["rotate", ...(Rotate | RotateZ)] | ["scale", ...Scale] | ["skewX", angle: number] | ["skewY", angle: number] | ["perspective", length: number];
|
|
613
|
+
type TransformArray = TransformStep[];
|
|
614
|
+
type TransformLike = [TransformStep[0], ...number[]][];
|
|
615
|
+
//#endregion
|
|
616
|
+
//#region src/Easing.d.ts
|
|
617
|
+
/**
|
|
618
|
+
* The Ease class provides a collection of easing functions for use with tween.js.
|
|
619
|
+
*/
|
|
620
|
+
declare const Easing: Readonly<{
|
|
621
|
+
Linear: Readonly<EasingFunctionGroup & {
|
|
622
|
+
None: EasingFunction;
|
|
623
|
+
}>;
|
|
624
|
+
Quadratic: Readonly<EasingFunctionGroup>;
|
|
625
|
+
Cubic: Readonly<EasingFunctionGroup>;
|
|
626
|
+
Quartic: Readonly<EasingFunctionGroup>;
|
|
627
|
+
Quintic: Readonly<EasingFunctionGroup>;
|
|
628
|
+
Sinusoidal: Readonly<EasingFunctionGroup>;
|
|
629
|
+
Exponential: Readonly<EasingFunctionGroup>;
|
|
630
|
+
Circular: Readonly<EasingFunctionGroup>;
|
|
631
|
+
Elastic: Readonly<EasingFunctionGroup>;
|
|
632
|
+
Back: Readonly<EasingFunctionGroup>;
|
|
633
|
+
Bounce: Readonly<EasingFunctionGroup>;
|
|
634
|
+
pow(power?: number): EasingFunctionGroup;
|
|
635
|
+
}>;
|
|
636
|
+
//#endregion
|
|
637
|
+
//#region src/Util.d.ts
|
|
638
|
+
declare const isString: (value: unknown) => value is string;
|
|
639
|
+
declare const isNumber: (value: unknown) => value is number;
|
|
640
|
+
declare const isArray: (value: unknown) => value is Array<unknown>;
|
|
641
|
+
declare const isFunction: (value: unknown) => value is () => unknown;
|
|
642
|
+
declare const isObject: (value: unknown) => value is Record<string, never>;
|
|
643
|
+
declare const isPlainObject: (value: unknown) => value is Record<string, never>;
|
|
644
|
+
declare const isDeepObject: (value: unknown) => value is DeepObject;
|
|
645
|
+
declare const isServer: boolean;
|
|
646
|
+
/**
|
|
647
|
+
* SSR helper to speed up UI frameworks render.
|
|
648
|
+
*
|
|
649
|
+
* Why:
|
|
650
|
+
* - skip validation
|
|
651
|
+
* - skip ministore creation
|
|
652
|
+
* - allow free-form configuration for signal based frameworks
|
|
653
|
+
*/
|
|
654
|
+
declare const dummyInstance: Record<string, typeof dummyMethod>;
|
|
655
|
+
declare const dummyMethod: () => Record<string, () => Record<string, /*elided*/any>>;
|
|
656
|
+
/**
|
|
657
|
+
* Utility to round numbers to a specified number of decimals.
|
|
658
|
+
* @param n Input number value
|
|
659
|
+
* @param round Number of decimals
|
|
660
|
+
* @returns The rounded number
|
|
661
|
+
*/
|
|
662
|
+
declare const roundTo: (n: number, round: number) => number;
|
|
663
|
+
declare const objectHasProp: <T extends object>(obj: T, prop: keyof T) => boolean;
|
|
664
|
+
/**
|
|
665
|
+
* A small utility to deep assign up to one level deep nested objects.
|
|
666
|
+
* This is to prevent breaking reactivity of miniStore.
|
|
667
|
+
*
|
|
668
|
+
* **NOTE** - This doesn't perform ANY check and expects objects to
|
|
669
|
+
* be validated beforehand.
|
|
670
|
+
* @param target The target to assign values to
|
|
671
|
+
* @param source The source object to assign values from
|
|
672
|
+
*/
|
|
673
|
+
declare function deepAssign<T extends TweenProps>(target: T, source: T): void;
|
|
674
|
+
/**
|
|
675
|
+
* Creates a clone of a target object / array without its
|
|
676
|
+
* proxy elements / properties, only their values.
|
|
677
|
+
*
|
|
678
|
+
* **NOTE** - The utility is useful to create deep clones as well.
|
|
679
|
+
* @param value An object / array with proxy elements
|
|
680
|
+
* @returns the object / array value without proxy elements
|
|
681
|
+
*/
|
|
682
|
+
declare const deproxy: <T>(value: T) => T;
|
|
683
|
+
/**
|
|
684
|
+
* Test values validity or their compatibility with the validated ones
|
|
685
|
+
* in the state. This is something we don't want to do in the runtime
|
|
686
|
+
* update loop.
|
|
687
|
+
* @param this The Tween/Timeline instance
|
|
688
|
+
* @param target The target object to validate
|
|
689
|
+
* @param reference The reference state value
|
|
690
|
+
* @returns void
|
|
691
|
+
*/
|
|
692
|
+
declare function validateValues<T extends TweenProps>(this: Timeline | Tween, target: Partial<T> | DeepPartial<T>, reference?: T): void;
|
|
693
|
+
//#endregion
|
|
694
|
+
//#region src/extend/array.d.ts
|
|
695
|
+
/**
|
|
696
|
+
* Interpolates two `Array<number>` values.
|
|
697
|
+
*
|
|
698
|
+
* **NOTE**: Values my be validated first!
|
|
699
|
+
* @param target The target `Array<number>` value
|
|
700
|
+
* @param start The start `Array<number>` value
|
|
701
|
+
* @param end The end `Array<number>` value
|
|
702
|
+
* @param t The progress value
|
|
703
|
+
* @returns The interpolated `Array<number>` value.
|
|
704
|
+
*/
|
|
705
|
+
declare const interpolateArray: InterpolatorFunction<number[]>;
|
|
706
|
+
/**
|
|
707
|
+
* Check if a value is a valid array for interpolation
|
|
708
|
+
* @param target The array to check
|
|
709
|
+
* @returns `true` is value is array and all elements are numbers
|
|
710
|
+
*/
|
|
711
|
+
declare const isValidArray: <T extends number[]>(target: unknown) => target is T;
|
|
712
|
+
/**
|
|
713
|
+
* Check if an array of numbers is compatible with a reference
|
|
714
|
+
* @param target The incoming value `from()` / `to()`
|
|
715
|
+
* @param ref The state reference value
|
|
716
|
+
* @returns [boolean, reason] tuple when arrays are compatible or
|
|
717
|
+
*/
|
|
718
|
+
declare const validateArray: <T extends number[]>(propName: string, target: unknown, ref?: T) => ValidationResultEntry;
|
|
719
|
+
/**
|
|
720
|
+
* Config for .use(propName, arrayConfig)
|
|
721
|
+
*/
|
|
722
|
+
declare const arrayConfig: {
|
|
723
|
+
interpolate: InterpolatorFunction<number[]>;
|
|
724
|
+
validate: <T extends number[]>(propName: string, target: unknown, ref?: T) => ValidationResultEntry;
|
|
725
|
+
};
|
|
726
|
+
//#endregion
|
|
727
|
+
//#region src/extend/path.d.ts
|
|
728
|
+
/**
|
|
729
|
+
* Iterates a `PathArray` and concatenates the values into a string to return it.
|
|
730
|
+
* **NOTE**: Segment values are rounded to 4 decimals by default.
|
|
731
|
+
* @param path A source PathArray
|
|
732
|
+
* @param round An optional parameter to round segment values to a number of decimals
|
|
733
|
+
* @returns A path string
|
|
734
|
+
*/
|
|
735
|
+
declare function pathToString(path: MorphPathArray, round?: number): string;
|
|
736
|
+
/**
|
|
737
|
+
* Interpolate PathArray values.
|
|
738
|
+
* **NOTE**: these values must be validated first! Check validatePath for more info.
|
|
739
|
+
* @param target - The target PathArray value
|
|
740
|
+
* @param start - A starting PathArray value
|
|
741
|
+
* @param end - An ending PathArray value
|
|
742
|
+
* @param t - The progress value
|
|
743
|
+
* @returns The interpolated PathArray value
|
|
744
|
+
*/
|
|
745
|
+
declare const interpolatePath: InterpolatorFunction<MorphPathSegment[]>;
|
|
746
|
+
/**
|
|
747
|
+
* Check if an array of arrays is potentially a PathArray
|
|
748
|
+
* @param target The incoming value `constructor()` `from()` / `to()`
|
|
749
|
+
* @returns `true` when array is potentially a PathArray
|
|
750
|
+
*/
|
|
751
|
+
declare const isPathLike: (value: unknown) => value is PathLike;
|
|
752
|
+
/**
|
|
753
|
+
* Check if an array of arrays is a valid PathArray for interpolation
|
|
754
|
+
* @param target The incoming value `from()` / `to()`
|
|
755
|
+
* @returns `true` when array is valid
|
|
756
|
+
*/
|
|
757
|
+
declare const isValidPath: (value: unknown) => value is MorphPathArray;
|
|
758
|
+
/**
|
|
759
|
+
* Validate a PathArray and check if it's compatible with a reference.
|
|
760
|
+
*
|
|
761
|
+
* **NOTE**: Path interpolation only works when both paths have:
|
|
762
|
+
* - Identical segments structure (same number and order of M/L/C/Z)
|
|
763
|
+
* - Corresponding coordinates to interpolate
|
|
764
|
+
* Complex morphs require preprocessing (e.g. KUTE.js, Flubber)
|
|
765
|
+
*
|
|
766
|
+
* @example
|
|
767
|
+
* // simple shapes
|
|
768
|
+
* const linePath1 = [["M", 0, 0],["L", 50, 50]]
|
|
769
|
+
* const linePath2 = [["M",50,50],["L",150,150]]
|
|
770
|
+
* const curvePath1 = [["M", 0, 0],["C",15,15, 35, 35, 50, 50]]
|
|
771
|
+
* const curvePath2 = [["M",50,50],["C",50,50,100,100,150,150]]
|
|
772
|
+
*
|
|
773
|
+
* // closed shapes
|
|
774
|
+
* const closedLinePath1 = [["M", 0, 0],["L", 50, 50],["Z"]]
|
|
775
|
+
* const closedLinePath2 = [["M",50,50],["L",150,150],["Z"]]
|
|
776
|
+
* const closedCurvePath1 = [["M", 0, 0],["C",15,15, 35, 35, 50, 50],["Z"]]
|
|
777
|
+
* const closedCurvePath2 = [["M",50,50],["C",50,50,100,100,150,150],["Z"]]
|
|
778
|
+
*
|
|
779
|
+
* // composit shapes (multi-path)
|
|
780
|
+
* const compositPath1 = [
|
|
781
|
+
* ["M", 0, 0],["L",50,50],
|
|
782
|
+
* ["M",50,50],["C",50,50,100,100,150,150],
|
|
783
|
+
* ]
|
|
784
|
+
* const compositPath2 = [
|
|
785
|
+
* ["M",50,50],["L",150,150],
|
|
786
|
+
* ["M", 0, 0],["C", 15, 15,35,35,50,50],
|
|
787
|
+
* ]
|
|
788
|
+
*
|
|
789
|
+
* @param target The incoming value `from()` / `to()`
|
|
790
|
+
* @param ref The state reference value
|
|
791
|
+
* @returns `true` when arrays are compatible or a reason why not
|
|
792
|
+
*/
|
|
793
|
+
declare const validatePath: <T extends MorphPathArray>(propName: string, target: unknown, ref?: T) => ValidationResultEntry;
|
|
794
|
+
/**
|
|
795
|
+
* Config for .use(propName, pathArrayConfig)
|
|
796
|
+
*/
|
|
797
|
+
declare const pathArrayConfig: {
|
|
798
|
+
interpolate: InterpolatorFunction<MorphPathSegment[]>;
|
|
799
|
+
validate: <T extends MorphPathArray>(propName: string, target: unknown, ref?: T) => ValidationResultEntry;
|
|
800
|
+
};
|
|
801
|
+
//#endregion
|
|
802
|
+
//#region src/extend/object.d.ts
|
|
803
|
+
/**
|
|
804
|
+
* Single-level object interpolator
|
|
805
|
+
* **Note**: values must be validated first!
|
|
806
|
+
*
|
|
807
|
+
* Input: { scale: { x: 1, y: 1 } }
|
|
808
|
+
* Output: interpolated flat object with same structure
|
|
809
|
+
* @param target The target value of the object
|
|
810
|
+
* @param start The start value of the object
|
|
811
|
+
* @param end The end value of the object
|
|
812
|
+
* @param t The progress value
|
|
813
|
+
* @returns The interpolated flat object with same structure.
|
|
814
|
+
*/
|
|
815
|
+
declare const interpolateObject: InterpolatorFunction<BaseTweenProps>;
|
|
816
|
+
/**
|
|
817
|
+
* Validate a simple plain object and compare its compatibility with a reference object.
|
|
818
|
+
* @param propName The property name to which this object belongs to
|
|
819
|
+
* @param target The target object itself
|
|
820
|
+
* @param ref A reference object to compare our target to
|
|
821
|
+
* @returns A [boolean, string?] tuple which represents [validity, "reason why not valid"]
|
|
822
|
+
*/
|
|
823
|
+
declare const validateObject: (propName: string, target: unknown, ref?: BaseTweenProps) => ValidationResultEntry;
|
|
824
|
+
/**
|
|
825
|
+
* Config for .use(propName, objectConfig)
|
|
826
|
+
*/
|
|
827
|
+
declare const objectConfig: {
|
|
828
|
+
interpolate: InterpolatorFunction<BaseTweenProps>;
|
|
829
|
+
validate: (propName: string, target: unknown, ref?: BaseTweenProps) => ValidationResultEntry;
|
|
830
|
+
};
|
|
831
|
+
//#endregion
|
|
832
|
+
//#region src/extend/transform.d.ts
|
|
833
|
+
/**
|
|
834
|
+
* Returns a valid CSS transform string either with transform functions (Eg.: `translate(15px) rotate(25deg)`)
|
|
835
|
+
* or `matrix(...)` / `matrix3d(...)`.
|
|
836
|
+
* When the `toMatrix` parameter is `true` it will create a DOMMatrix instance, apply transform
|
|
837
|
+
* steps and return a `matrix(...)` or `matrix3d(...)` string value.
|
|
838
|
+
* @param steps An array of TransformStep
|
|
839
|
+
* @param toMatrix An optional parameter to modify the function output
|
|
840
|
+
* @returns The valid CSS transform string value
|
|
841
|
+
*/
|
|
842
|
+
declare const transformToString: (steps: TransformStep[], toMatrix?: boolean) => string;
|
|
843
|
+
/**
|
|
844
|
+
* Convert euler rotation to axis angle.
|
|
845
|
+
* All values are degrees.
|
|
846
|
+
* @param x rotateX value
|
|
847
|
+
* @param y rotateY value
|
|
848
|
+
* @param z rotateZ value
|
|
849
|
+
* @returns The axis angle tuple [vectorX, vectorY, vectorZ, angle]
|
|
850
|
+
*/
|
|
851
|
+
declare const eulerToAxisAngle: (x: number, y: number, z: number) => [number, number, number, number];
|
|
852
|
+
/**
|
|
853
|
+
* Interpolator: takes start/end arrays of `TransformStep`s → returns interpolated `TransformStep`s.
|
|
854
|
+
* **Note** - Like `PathArray`, these values are required to have same length and structure.
|
|
855
|
+
* @example
|
|
856
|
+
* const a1: TransformArray = [
|
|
857
|
+
* ["translate", 0, 0], // [translateX, translateY]
|
|
858
|
+
* ["rotate", 0], // [rotateZ]
|
|
859
|
+
* ["rotate", 0, 0], // [rotateX, rotateY]
|
|
860
|
+
* ["rotateAxisAngle", 0, 0, 0, 0], // [originX, originY, originZ, angle]
|
|
861
|
+
* ["scale", 1], // [scale]
|
|
862
|
+
* ["scale", 1, 1], // [scaleX, scaleY]
|
|
863
|
+
* ["perspective", 800], // [length]
|
|
864
|
+
* ];
|
|
865
|
+
* const a2: TransformArray = [
|
|
866
|
+
* ["translate", 50, 50],
|
|
867
|
+
* ["rotate", 45],
|
|
868
|
+
* ["rotate", 45, 45],
|
|
869
|
+
* ["rotateAxisAngle", 1, 0, 0, 45],
|
|
870
|
+
* ["scale", 1.5],
|
|
871
|
+
* ["scale", 1.5, 1.2],
|
|
872
|
+
* ["perspective", 400],
|
|
873
|
+
* ];
|
|
874
|
+
*
|
|
875
|
+
* @param target The target `TransformArray`
|
|
876
|
+
* @param start The start `TransformArray`
|
|
877
|
+
* @param end The end `TransformArray`
|
|
878
|
+
* @param t The progress value
|
|
879
|
+
* @returns The interpolated `TransformArray`
|
|
880
|
+
*/
|
|
881
|
+
declare const interpolateTransform: InterpolatorFunction<TransformStep[]>;
|
|
882
|
+
/**
|
|
883
|
+
* Check if an array of arrays is potentially a TransformArray
|
|
884
|
+
* @param target The incoming value `constructor()` `from()` / `to()`
|
|
885
|
+
* @returns `true` when array is potentially a PathArray
|
|
886
|
+
*/
|
|
887
|
+
declare const isTransformLike: (value: unknown) => value is TransformLike;
|
|
888
|
+
/**
|
|
889
|
+
* Check if an array of arrays is a valid TransformArray for interpolation
|
|
890
|
+
* @param target The incoming value `from()` / `to()`
|
|
891
|
+
* @returns `true` when array is valid
|
|
892
|
+
*/
|
|
893
|
+
declare const isValidTransformArray: (value: unknown) => value is TransformArray;
|
|
894
|
+
/**
|
|
895
|
+
* Validator for TransformArray
|
|
896
|
+
* Checks structure + number types + optional param counts
|
|
897
|
+
*/
|
|
898
|
+
declare const validateTransform: (propName: string, target: unknown, ref?: TransformArray) => ValidationResultEntry;
|
|
899
|
+
/**
|
|
900
|
+
* Config for .use("transform", transformConfig)
|
|
901
|
+
*/
|
|
902
|
+
declare const transformConfig: {
|
|
903
|
+
interpolate: InterpolatorFunction<TransformStep[]>;
|
|
904
|
+
validate: (propName: string, target: unknown, ref?: TransformArray) => ValidationResultEntry;
|
|
905
|
+
};
|
|
906
|
+
//#endregion
|
|
907
|
+
//#region src/Now.d.ts
|
|
908
|
+
declare let _nowFunc: () => number;
|
|
909
|
+
declare const now: () => number;
|
|
910
|
+
declare function setNow(nowFunction: typeof _nowFunc): void;
|
|
911
|
+
//#endregion
|
|
912
|
+
//#region src/Runtime.d.ts
|
|
913
|
+
/**
|
|
914
|
+
* The runtime queue
|
|
915
|
+
*/
|
|
916
|
+
declare const Queue: (AnimationItem | null)[];
|
|
917
|
+
/**
|
|
918
|
+
* The hot update loop updates all items in the queue,
|
|
919
|
+
* and stops automatically when there are no items left.
|
|
920
|
+
* @param t execution time (performance.now)
|
|
921
|
+
*/
|
|
922
|
+
declare function Runtime(t?: number): void;
|
|
923
|
+
/**
|
|
924
|
+
* Add a new item to the update loop.
|
|
925
|
+
* If it's the first item, it will also start the update loop.
|
|
926
|
+
* @param newItem Tween / Timeline
|
|
927
|
+
*/
|
|
928
|
+
declare function addToQueue<T extends TweenProps>(newItem: AnimationItem<T>): void;
|
|
929
|
+
/**
|
|
930
|
+
* Remove item from the update loop.
|
|
931
|
+
* @param newItem Tween / Timeline
|
|
932
|
+
*/
|
|
933
|
+
declare function removeFromQueue<T extends TweenProps>(removedItem: AnimationItem<T>): void;
|
|
934
|
+
//#endregion
|
|
935
|
+
//#region package.json.d.ts
|
|
936
|
+
declare let version: string;
|
|
937
|
+
//#endregion
|
|
938
|
+
export { AnimationItem, ArrayVal, BaseTweenProps, CubicValues, DeepObject, DeepPartial, Easing, EasingFunction, EasingFunctionGroup, InterpolatorFunction, LineValues, MorphPathArray, MorphPathSegment, PathLike, Position, PropConfig, QuadValues, Queue, Rotate, RotateAxisAngle, RotateZ, Runtime, Scale, Timeline, TimelineCallback, TimelineEntry, TimelineEntryConfig, TransformArray, TransformLike, TransformStep, TransformStepInternal, Translate, Tween, TweenCallback, TweenProps, TweenRuntime, TweenUpdateCallback, ValidationFunction, ValidationResultEntry, Vec3, addToQueue, arrayConfig, deepAssign, deproxy, dummyInstance, eulerToAxisAngle, interpolateArray, interpolateObject, interpolatePath, interpolateTransform, isArray, isDeepObject, isFunction, isNumber, isObject, isPathLike, isPlainObject, isServer, isString, isTransformLike, isValidArray, isValidPath, isValidTransformArray, now, objectConfig, objectHasProp, pathArrayConfig, pathToString, removeFromQueue, roundTo, setNow, transformConfig, transformToString, validateArray, validateObject, validatePath, validateTransform, validateValues, version };
|
|
939
|
+
//# sourceMappingURL=index.d.mts.map
|