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