@tweenjs/tween.js 23.1.3 → 25.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/dist/tween.d.ts CHANGED
@@ -43,22 +43,6 @@ declare const Interpolation: {
43
43
  };
44
44
  };
45
45
 
46
- /**
47
- * Controlling groups of tweens
48
- *
49
- * Using the TWEEN singleton to manage your tweens can cause issues in large apps with many components.
50
- * In these cases, you may want to create your own smaller groups of tween
51
- */
52
- declare class Group {
53
- private _tweens;
54
- private _tweensAddedDuringUpdate;
55
- getAll(): Array<Tween<UnknownProps>>;
56
- removeAll(): void;
57
- add(tween: Tween<UnknownProps>): void;
58
- remove(tween: Tween<UnknownProps>): void;
59
- update(time?: number, preserve?: boolean): boolean;
60
- }
61
-
62
46
  /**
63
47
  * Tween.js - Licensed under the MIT license
64
48
  * https://github.com/tweenjs/tween.js
@@ -68,9 +52,8 @@ declare class Group {
68
52
  * Thank you all, you're awesome!
69
53
  */
70
54
 
71
- declare class Tween<T extends UnknownProps> {
72
- private _object;
73
- private _group;
55
+ declare class Tween<T extends UnknownProps = any> {
56
+ static autoStartOnUpdate: boolean;
74
57
  private _isPaused;
75
58
  private _pauseStart;
76
59
  private _valuesStart;
@@ -100,7 +83,20 @@ declare class Tween<T extends UnknownProps> {
100
83
  private _id;
101
84
  private _isChainStopped;
102
85
  private _propertiesAreSetUp;
103
- constructor(_object: T, _group?: Group | false);
86
+ private _object;
87
+ private _group?;
88
+ /**
89
+ * @param object - The object whose properties this Tween will animate.
90
+ * @param group - The object whose properties this Tween will animate.
91
+ */
92
+ constructor(object: T, group?: Group);
93
+ /**
94
+ * @deprecated The group parameter is now deprecated, instead use `new
95
+ * Tween(object)` then `group.add(tween)` to add a tween to a group. Use
96
+ * `new Tween(object, true)` to restore the old behavior for now, but this
97
+ * will be removed in the future.
98
+ */
99
+ constructor(object: T, group: true);
104
100
  getId(): number;
105
101
  isPlaying(): boolean;
106
102
  isPaused(): boolean;
@@ -116,7 +112,20 @@ declare class Tween<T extends UnknownProps> {
116
112
  pause(time?: number): this;
117
113
  resume(time?: number): this;
118
114
  stopChainedTweens(): this;
119
- group(group?: Group): this;
115
+ /**
116
+ * Removes the tween from the current group it is in, if any, then adds the
117
+ * tween to the specified `group`.
118
+ */
119
+ group(group: Group): this;
120
+ /**
121
+ * @deprecated The argless call signature has been removed. Use
122
+ * `tween.group(group)` or `group.add(tween)`, instead.
123
+ */
124
+ group(): this;
125
+ /**
126
+ * Removes the tween from whichever group it is in.
127
+ */
128
+ remove(): this;
120
129
  delay(amount?: number): this;
121
130
  repeat(times?: number): this;
122
131
  repeatDelay(amount?: number): this;
@@ -135,6 +144,10 @@ declare class Tween<T extends UnknownProps> {
135
144
  * @returns true if the tween is still playing after the update, false
136
145
  * otherwise (calling update on a paused tween still returns true because
137
146
  * it is still playing, just paused).
147
+ *
148
+ * @param autoStart - When true, calling update will implicitly call start()
149
+ * as well. Note, if you stop() or end() the tween, but are still calling
150
+ * update(), it will start again!
138
151
  */
139
152
  update(time?: number, autoStart?: boolean): boolean;
140
153
  private _updateProperties;
@@ -143,6 +156,33 @@ declare class Tween<T extends UnknownProps> {
143
156
  }
144
157
  type UnknownProps = Record<string, any>;
145
158
 
159
+ /**
160
+ * Controlling groups of tweens
161
+ *
162
+ * Using the TWEEN singleton to manage your tweens can cause issues in large apps with many components.
163
+ * In these cases, you may want to create your own smaller groups of tween
164
+ */
165
+ declare class Group {
166
+ private _tweens;
167
+ private _tweensAddedDuringUpdate;
168
+ constructor(...tweens: Tween[]);
169
+ getAll(): Array<Tween>;
170
+ removeAll(): void;
171
+ add(...tweens: Tween[]): void;
172
+ remove(...tweens: Tween[]): void;
173
+ /** Return true if all tweens in the group are not paused or playing. */
174
+ allStopped(): boolean;
175
+ update(time?: number): void;
176
+ /**
177
+ * @deprecated The `preserve` parameter is now defaulted to `true` and will
178
+ * be removed in a future major release, at which point all tweens of a
179
+ * group will always be preserved when calling update. To migrate, always
180
+ * use `group.add(tween)` or `group.remove(tween)` to manually add or remove
181
+ * tweens, and do not rely on tweens being automatically added or removed.
182
+ */
183
+ update(time?: number, preserve?: boolean): void;
184
+ }
185
+
146
186
  declare const now: () => number;
147
187
 
148
188
  /**
@@ -153,14 +193,252 @@ declare class Sequence {
153
193
  static nextId(): number;
154
194
  }
155
195
 
156
- declare const VERSION = "23.1.3";
196
+ declare const VERSION = "25.0.0";
157
197
 
158
198
  declare const nextId: typeof Sequence.nextId;
159
- declare const getAll: () => Tween<UnknownProps>[];
199
+ /**
200
+ * @deprecated The global TWEEN Group will be removed in a following major
201
+ * release. To migrate, create a `new Group()` instead of using `TWEEN` as a
202
+ * group.
203
+ *
204
+ * Old code:
205
+ *
206
+ * ```js
207
+ * import * as TWEEN from '@tweenjs/tween.js'
208
+ *
209
+ * //...
210
+ *
211
+ * const tween = new TWEEN.Tween(obj)
212
+ * const tween2 = new TWEEN.Tween(obj2)
213
+ *
214
+ * //...
215
+ *
216
+ * requestAnimationFrame(function loop(time) {
217
+ * TWEEN.update(time)
218
+ * requestAnimationFrame(loop)
219
+ * })
220
+ * ```
221
+ *
222
+ * New code:
223
+ *
224
+ * ```js
225
+ * import {Tween, Group} from '@tweenjs/tween.js'
226
+ *
227
+ * //...
228
+ *
229
+ * const tween = new Tween(obj)
230
+ * const tween2 = new TWEEN.Tween(obj2)
231
+ *
232
+ * //...
233
+ *
234
+ * const group = new Group()
235
+ * group.add(tween)
236
+ * group.add(tween2)
237
+ *
238
+ * //...
239
+ *
240
+ * requestAnimationFrame(function loop(time) {
241
+ * group.update(time)
242
+ * requestAnimationFrame(loop)
243
+ * })
244
+ * ```
245
+ */
246
+ declare const getAll: () => Tween<any>[];
247
+ /**
248
+ * @deprecated The global TWEEN Group will be removed in a following major
249
+ * release. To migrate, create a `new Group()` instead of using `TWEEN` as a
250
+ * group.
251
+ *
252
+ * Old code:
253
+ *
254
+ * ```js
255
+ * import * as TWEEN from '@tweenjs/tween.js'
256
+ *
257
+ * //...
258
+ *
259
+ * const tween = new TWEEN.Tween(obj)
260
+ * const tween2 = new TWEEN.Tween(obj2)
261
+ *
262
+ * //...
263
+ *
264
+ * requestAnimationFrame(function loop(time) {
265
+ * TWEEN.update(time)
266
+ * requestAnimationFrame(loop)
267
+ * })
268
+ * ```
269
+ *
270
+ * New code:
271
+ *
272
+ * ```js
273
+ * import {Tween, Group} from '@tweenjs/tween.js'
274
+ *
275
+ * //...
276
+ *
277
+ * const tween = new Tween(obj)
278
+ * const tween2 = new TWEEN.Tween(obj2)
279
+ *
280
+ * //...
281
+ *
282
+ * const group = new Group()
283
+ * group.add(tween)
284
+ * group.add(tween2)
285
+ *
286
+ * //...
287
+ *
288
+ * requestAnimationFrame(function loop(time) {
289
+ * group.update(time)
290
+ * requestAnimationFrame(loop)
291
+ * })
292
+ * ```
293
+ */
160
294
  declare const removeAll: () => void;
161
- declare const add: (tween: Tween<UnknownProps>) => void;
162
- declare const remove: (tween: Tween<UnknownProps>) => void;
163
- declare const update: (time?: number, preserve?: boolean) => boolean;
295
+ /**
296
+ * @deprecated The global TWEEN Group will be removed in a following major
297
+ * release. To migrate, create a `new Group()` instead of using `TWEEN` as a
298
+ * group.
299
+ *
300
+ * Old code:
301
+ *
302
+ * ```js
303
+ * import * as TWEEN from '@tweenjs/tween.js'
304
+ *
305
+ * //...
306
+ *
307
+ * const tween = new TWEEN.Tween(obj)
308
+ * const tween2 = new TWEEN.Tween(obj2)
309
+ *
310
+ * //...
311
+ *
312
+ * requestAnimationFrame(function loop(time) {
313
+ * TWEEN.update(time)
314
+ * requestAnimationFrame(loop)
315
+ * })
316
+ * ```
317
+ *
318
+ * New code:
319
+ *
320
+ * ```js
321
+ * import {Tween, Group} from '@tweenjs/tween.js'
322
+ *
323
+ * //...
324
+ *
325
+ * const tween = new Tween(obj)
326
+ * const tween2 = new TWEEN.Tween(obj2)
327
+ *
328
+ * //...
329
+ *
330
+ * const group = new Group()
331
+ * group.add(tween)
332
+ * group.add(tween2)
333
+ *
334
+ * //...
335
+ *
336
+ * requestAnimationFrame(function loop(time) {
337
+ * group.update(time)
338
+ * requestAnimationFrame(loop)
339
+ * })
340
+ * ```
341
+ */
342
+ declare const add: (...tweens: Tween<any>[]) => void;
343
+ /**
344
+ * @deprecated The global TWEEN Group will be removed in a following major
345
+ * release. To migrate, create a `new Group()` instead of using `TWEEN` as a
346
+ * group.
347
+ *
348
+ * Old code:
349
+ *
350
+ * ```js
351
+ * import * as TWEEN from '@tweenjs/tween.js'
352
+ *
353
+ * //...
354
+ *
355
+ * const tween = new TWEEN.Tween(obj)
356
+ * const tween2 = new TWEEN.Tween(obj2)
357
+ *
358
+ * //...
359
+ *
360
+ * requestAnimationFrame(function loop(time) {
361
+ * TWEEN.update(time)
362
+ * requestAnimationFrame(loop)
363
+ * })
364
+ * ```
365
+ *
366
+ * New code:
367
+ *
368
+ * ```js
369
+ * import {Tween, Group} from '@tweenjs/tween.js'
370
+ *
371
+ * //...
372
+ *
373
+ * const tween = new Tween(obj)
374
+ * const tween2 = new TWEEN.Tween(obj2)
375
+ *
376
+ * //...
377
+ *
378
+ * const group = new Group()
379
+ * group.add(tween)
380
+ * group.add(tween2)
381
+ *
382
+ * //...
383
+ *
384
+ * requestAnimationFrame(function loop(time) {
385
+ * group.update(time)
386
+ * requestAnimationFrame(loop)
387
+ * })
388
+ * ```
389
+ */
390
+ declare const remove: (...tweens: Tween<any>[]) => void;
391
+ /**
392
+ * @deprecated The global TWEEN Group will be removed in a following major
393
+ * release. To migrate, create a `new Group()` instead of using `TWEEN` as a
394
+ * group.
395
+ *
396
+ * Old code:
397
+ *
398
+ * ```js
399
+ * import * as TWEEN from '@tweenjs/tween.js'
400
+ *
401
+ * //...
402
+ *
403
+ * const tween = new TWEEN.Tween(obj)
404
+ * const tween2 = new TWEEN.Tween(obj2)
405
+ *
406
+ * //...
407
+ *
408
+ * requestAnimationFrame(function loop(time) {
409
+ * TWEEN.update(time)
410
+ * requestAnimationFrame(loop)
411
+ * })
412
+ * ```
413
+ *
414
+ * New code:
415
+ *
416
+ * ```js
417
+ * import {Tween, Group} from '@tweenjs/tween.js'
418
+ *
419
+ * //...
420
+ *
421
+ * const tween = new Tween(obj)
422
+ * const tween2 = new TWEEN.Tween(obj2)
423
+ *
424
+ * //...
425
+ *
426
+ * const group = new Group()
427
+ * group.add(tween)
428
+ * group.add(tween2)
429
+ *
430
+ * //...
431
+ *
432
+ * requestAnimationFrame(function loop(time) {
433
+ * group.update(time)
434
+ * requestAnimationFrame(loop)
435
+ * })
436
+ * ```
437
+ */
438
+ declare const update: {
439
+ (time?: number | undefined): void;
440
+ (time?: number | undefined, preserve?: boolean | undefined): void;
441
+ };
164
442
 
165
443
  declare const exports: {
166
444
  Easing: Readonly<{
@@ -196,11 +474,249 @@ declare const exports: {
196
474
  nextId: typeof Sequence.nextId;
197
475
  Tween: typeof Tween;
198
476
  VERSION: string;
199
- getAll: () => Tween<UnknownProps>[];
477
+ /**
478
+ * @deprecated The global TWEEN Group will be removed in a following major
479
+ * release. To migrate, create a `new Group()` instead of using `TWEEN` as a
480
+ * group.
481
+ *
482
+ * Old code:
483
+ *
484
+ * ```js
485
+ * import * as TWEEN from '@tweenjs/tween.js'
486
+ *
487
+ * //...
488
+ *
489
+ * const tween = new TWEEN.Tween(obj)
490
+ * const tween2 = new TWEEN.Tween(obj2)
491
+ *
492
+ * //...
493
+ *
494
+ * requestAnimationFrame(function loop(time) {
495
+ * TWEEN.update(time)
496
+ * requestAnimationFrame(loop)
497
+ * })
498
+ * ```
499
+ *
500
+ * New code:
501
+ *
502
+ * ```js
503
+ * import {Tween, Group} from '@tweenjs/tween.js'
504
+ *
505
+ * //...
506
+ *
507
+ * const tween = new Tween(obj)
508
+ * const tween2 = new TWEEN.Tween(obj2)
509
+ *
510
+ * //...
511
+ *
512
+ * const group = new Group()
513
+ * group.add(tween)
514
+ * group.add(tween2)
515
+ *
516
+ * //...
517
+ *
518
+ * requestAnimationFrame(function loop(time) {
519
+ * group.update(time)
520
+ * requestAnimationFrame(loop)
521
+ * })
522
+ * ```
523
+ */
524
+ getAll: () => Tween<any>[];
525
+ /**
526
+ * @deprecated The global TWEEN Group will be removed in a following major
527
+ * release. To migrate, create a `new Group()` instead of using `TWEEN` as a
528
+ * group.
529
+ *
530
+ * Old code:
531
+ *
532
+ * ```js
533
+ * import * as TWEEN from '@tweenjs/tween.js'
534
+ *
535
+ * //...
536
+ *
537
+ * const tween = new TWEEN.Tween(obj)
538
+ * const tween2 = new TWEEN.Tween(obj2)
539
+ *
540
+ * //...
541
+ *
542
+ * requestAnimationFrame(function loop(time) {
543
+ * TWEEN.update(time)
544
+ * requestAnimationFrame(loop)
545
+ * })
546
+ * ```
547
+ *
548
+ * New code:
549
+ *
550
+ * ```js
551
+ * import {Tween, Group} from '@tweenjs/tween.js'
552
+ *
553
+ * //...
554
+ *
555
+ * const tween = new Tween(obj)
556
+ * const tween2 = new TWEEN.Tween(obj2)
557
+ *
558
+ * //...
559
+ *
560
+ * const group = new Group()
561
+ * group.add(tween)
562
+ * group.add(tween2)
563
+ *
564
+ * //...
565
+ *
566
+ * requestAnimationFrame(function loop(time) {
567
+ * group.update(time)
568
+ * requestAnimationFrame(loop)
569
+ * })
570
+ * ```
571
+ */
200
572
  removeAll: () => void;
201
- add: (tween: Tween<UnknownProps>) => void;
202
- remove: (tween: Tween<UnknownProps>) => void;
203
- update: (time?: number, preserve?: boolean) => boolean;
573
+ /**
574
+ * @deprecated The global TWEEN Group will be removed in a following major
575
+ * release. To migrate, create a `new Group()` instead of using `TWEEN` as a
576
+ * group.
577
+ *
578
+ * Old code:
579
+ *
580
+ * ```js
581
+ * import * as TWEEN from '@tweenjs/tween.js'
582
+ *
583
+ * //...
584
+ *
585
+ * const tween = new TWEEN.Tween(obj)
586
+ * const tween2 = new TWEEN.Tween(obj2)
587
+ *
588
+ * //...
589
+ *
590
+ * requestAnimationFrame(function loop(time) {
591
+ * TWEEN.update(time)
592
+ * requestAnimationFrame(loop)
593
+ * })
594
+ * ```
595
+ *
596
+ * New code:
597
+ *
598
+ * ```js
599
+ * import {Tween, Group} from '@tweenjs/tween.js'
600
+ *
601
+ * //...
602
+ *
603
+ * const tween = new Tween(obj)
604
+ * const tween2 = new TWEEN.Tween(obj2)
605
+ *
606
+ * //...
607
+ *
608
+ * const group = new Group()
609
+ * group.add(tween)
610
+ * group.add(tween2)
611
+ *
612
+ * //...
613
+ *
614
+ * requestAnimationFrame(function loop(time) {
615
+ * group.update(time)
616
+ * requestAnimationFrame(loop)
617
+ * })
618
+ * ```
619
+ */
620
+ add: (...tweens: Tween<any>[]) => void;
621
+ /**
622
+ * @deprecated The global TWEEN Group will be removed in a following major
623
+ * release. To migrate, create a `new Group()` instead of using `TWEEN` as a
624
+ * group.
625
+ *
626
+ * Old code:
627
+ *
628
+ * ```js
629
+ * import * as TWEEN from '@tweenjs/tween.js'
630
+ *
631
+ * //...
632
+ *
633
+ * const tween = new TWEEN.Tween(obj)
634
+ * const tween2 = new TWEEN.Tween(obj2)
635
+ *
636
+ * //...
637
+ *
638
+ * requestAnimationFrame(function loop(time) {
639
+ * TWEEN.update(time)
640
+ * requestAnimationFrame(loop)
641
+ * })
642
+ * ```
643
+ *
644
+ * New code:
645
+ *
646
+ * ```js
647
+ * import {Tween, Group} from '@tweenjs/tween.js'
648
+ *
649
+ * //...
650
+ *
651
+ * const tween = new Tween(obj)
652
+ * const tween2 = new TWEEN.Tween(obj2)
653
+ *
654
+ * //...
655
+ *
656
+ * const group = new Group()
657
+ * group.add(tween)
658
+ * group.add(tween2)
659
+ *
660
+ * //...
661
+ *
662
+ * requestAnimationFrame(function loop(time) {
663
+ * group.update(time)
664
+ * requestAnimationFrame(loop)
665
+ * })
666
+ * ```
667
+ */
668
+ remove: (...tweens: Tween<any>[]) => void;
669
+ /**
670
+ * @deprecated The global TWEEN Group will be removed in a following major
671
+ * release. To migrate, create a `new Group()` instead of using `TWEEN` as a
672
+ * group.
673
+ *
674
+ * Old code:
675
+ *
676
+ * ```js
677
+ * import * as TWEEN from '@tweenjs/tween.js'
678
+ *
679
+ * //...
680
+ *
681
+ * const tween = new TWEEN.Tween(obj)
682
+ * const tween2 = new TWEEN.Tween(obj2)
683
+ *
684
+ * //...
685
+ *
686
+ * requestAnimationFrame(function loop(time) {
687
+ * TWEEN.update(time)
688
+ * requestAnimationFrame(loop)
689
+ * })
690
+ * ```
691
+ *
692
+ * New code:
693
+ *
694
+ * ```js
695
+ * import {Tween, Group} from '@tweenjs/tween.js'
696
+ *
697
+ * //...
698
+ *
699
+ * const tween = new Tween(obj)
700
+ * const tween2 = new TWEEN.Tween(obj2)
701
+ *
702
+ * //...
703
+ *
704
+ * const group = new Group()
705
+ * group.add(tween)
706
+ * group.add(tween2)
707
+ *
708
+ * //...
709
+ *
710
+ * requestAnimationFrame(function loop(time) {
711
+ * group.update(time)
712
+ * requestAnimationFrame(loop)
713
+ * })
714
+ * ```
715
+ */
716
+ update: {
717
+ (time?: number | undefined): void;
718
+ (time?: number | undefined, preserve?: boolean | undefined): void;
719
+ };
204
720
  };
205
721
 
206
722
  export { Easing, Group, Interpolation, Sequence, Tween, VERSION, add, exports as default, getAll, nextId, now, remove, removeAll, update };