@tweenjs/tween.js 18.6.4 → 20.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
@@ -1,67 +1,33 @@
1
- declare type EasingFunction = (amount: number) => number;
1
+ type EasingFunction = (amount: number) => number;
2
+ type EasingFunctionGroup = {
3
+ In: EasingFunction;
4
+ Out: EasingFunction;
5
+ InOut: EasingFunction;
6
+ };
2
7
  /**
3
8
  * The Ease class provides a collection of easing functions for use with tween.js.
4
9
  */
5
- declare const Easing: {
6
- Linear: {
7
- None: (amount: number) => number;
8
- };
9
- Quadratic: {
10
- In: (amount: number) => number;
11
- Out: (amount: number) => number;
12
- InOut: (amount: number) => number;
13
- };
14
- Cubic: {
15
- In: (amount: number) => number;
16
- Out: (amount: number) => number;
17
- InOut: (amount: number) => number;
18
- };
19
- Quartic: {
20
- In: (amount: number) => number;
21
- Out: (amount: number) => number;
22
- InOut: (amount: number) => number;
23
- };
24
- Quintic: {
25
- In: (amount: number) => number;
26
- Out: (amount: number) => number;
27
- InOut: (amount: number) => number;
28
- };
29
- Sinusoidal: {
30
- In: (amount: number) => number;
31
- Out: (amount: number) => number;
32
- InOut: (amount: number) => number;
33
- };
34
- Exponential: {
35
- In: (amount: number) => number;
36
- Out: (amount: number) => number;
37
- InOut: (amount: number) => number;
38
- };
39
- Circular: {
40
- In: (amount: number) => number;
41
- Out: (amount: number) => number;
42
- InOut: (amount: number) => number;
43
- };
44
- Elastic: {
45
- In: (amount: number) => number;
46
- Out: (amount: number) => number;
47
- InOut: (amount: number) => number;
48
- };
49
- Back: {
50
- In: (amount: number) => number;
51
- Out: (amount: number) => number;
52
- InOut: (amount: number) => number;
53
- };
54
- Bounce: {
55
- In: (amount: number) => number;
56
- Out: (amount: number) => number;
57
- InOut: (amount: number) => number;
58
- };
59
- };
10
+ declare const Easing: Readonly<{
11
+ Linear: Readonly<EasingFunctionGroup & {
12
+ None: EasingFunction;
13
+ }>;
14
+ Quadratic: Readonly<EasingFunctionGroup>;
15
+ Cubic: Readonly<EasingFunctionGroup>;
16
+ Quartic: Readonly<EasingFunctionGroup>;
17
+ Quintic: Readonly<EasingFunctionGroup>;
18
+ Sinusoidal: Readonly<EasingFunctionGroup>;
19
+ Exponential: Readonly<EasingFunctionGroup>;
20
+ Circular: Readonly<EasingFunctionGroup>;
21
+ Elastic: Readonly<EasingFunctionGroup>;
22
+ Back: Readonly<EasingFunctionGroup>;
23
+ Bounce: Readonly<EasingFunctionGroup>;
24
+ generatePow(power?: number): EasingFunctionGroup;
25
+ }>;
60
26
 
61
27
  /**
62
28
  *
63
29
  */
64
- declare type InterpolationFunction = (v: number[], k: number) => number;
30
+ type InterpolationFunction = (v: number[], k: number) => number;
65
31
  /**
66
32
  *
67
33
  */
@@ -77,6 +43,31 @@ declare const Interpolation: {
77
43
  };
78
44
  };
79
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
+ /**
63
+ * Tween.js - Licensed under the MIT license
64
+ * https://github.com/tweenjs/tween.js
65
+ * ----------------------------------------------
66
+ *
67
+ * See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors.
68
+ * Thank you all, you're awesome!
69
+ */
70
+
80
71
  declare class Tween<T extends UnknownProps> {
81
72
  private _object;
82
73
  private _group;
@@ -86,6 +77,7 @@ declare class Tween<T extends UnknownProps> {
86
77
  private _valuesEnd;
87
78
  private _valuesStartRepeat;
88
79
  private _duration;
80
+ private _isDynamic;
89
81
  private _initialRepeat;
90
82
  private _repeat;
91
83
  private _repeatDelayTime?;
@@ -99,38 +91,44 @@ declare class Tween<T extends UnknownProps> {
99
91
  private _chainedTweens;
100
92
  private _onStartCallback?;
101
93
  private _onStartCallbackFired;
94
+ private _onEveryStartCallback?;
95
+ private _onEveryStartCallbackFired;
102
96
  private _onUpdateCallback?;
103
97
  private _onRepeatCallback?;
104
98
  private _onCompleteCallback?;
105
99
  private _onStopCallback?;
106
100
  private _id;
107
101
  private _isChainStopped;
102
+ private _propertiesAreSetUp;
108
103
  constructor(_object: T, _group?: Group | false);
109
104
  getId(): number;
110
105
  isPlaying(): boolean;
111
106
  isPaused(): boolean;
112
- to(properties: UnknownProps, duration?: number): this;
113
- duration(d: number): this;
114
- start(time?: number): this;
107
+ to(target: UnknownProps, duration?: number): this;
108
+ duration(duration?: number): this;
109
+ dynamic(dynamic?: boolean): this;
110
+ start(time?: number, overrideStartingValues?: boolean): this;
111
+ startFromCurrentValues(time?: number): this;
115
112
  private _setupProperties;
116
113
  stop(): this;
117
114
  end(): this;
118
115
  pause(time?: number): this;
119
116
  resume(time?: number): this;
120
117
  stopChainedTweens(): this;
121
- group(group: Group): this;
122
- delay(amount: number): this;
123
- repeat(times: number): this;
124
- repeatDelay(amount: number): this;
125
- yoyo(yoyo: boolean): this;
126
- easing(easingFunction: EasingFunction): this;
127
- interpolation(interpolationFunction: InterpolationFunction): this;
128
- chain(...tweens: Array<Tween<UnknownProps>>): this;
129
- onStart(callback: (object: T) => void): this;
130
- onUpdate(callback: (object: T, elapsed: number) => void): this;
131
- onRepeat(callback: (object: T) => void): this;
132
- onComplete(callback: (object: T) => void): this;
133
- onStop(callback: (object: T) => void): this;
118
+ group(group?: Group): this;
119
+ delay(amount?: number): this;
120
+ repeat(times?: number): this;
121
+ repeatDelay(amount?: number): this;
122
+ yoyo(yoyo?: boolean): this;
123
+ easing(easingFunction?: EasingFunction): this;
124
+ interpolation(interpolationFunction?: InterpolationFunction): this;
125
+ chain(...tweens: Array<Tween<any>>): this;
126
+ onStart(callback?: (object: T) => void): this;
127
+ onEveryStart(callback?: (object: T) => void): this;
128
+ onUpdate(callback?: (object: T, elapsed: number) => void): this;
129
+ onRepeat(callback?: (object: T) => void): this;
130
+ onComplete(callback?: (object: T) => void): this;
131
+ onStop(callback?: (object: T) => void): this;
134
132
  private _goToEnd;
135
133
  /**
136
134
  * @returns true if the tween is still playing after the update, false
@@ -142,25 +140,9 @@ declare class Tween<T extends UnknownProps> {
142
140
  private _handleRelativeValue;
143
141
  private _swapEndStartRepeatValues;
144
142
  }
145
- declare type UnknownProps = Record<string, any>;
143
+ type UnknownProps = Record<string, any>;
146
144
 
147
- /**
148
- * Controlling groups of tweens
149
- *
150
- * Using the TWEEN singleton to manage your tweens can cause issues in large apps with many components.
151
- * In these cases, you may want to create your own smaller groups of tween
152
- */
153
- declare class Group {
154
- private _tweens;
155
- private _tweensAddedDuringUpdate;
156
- getAll(): Array<Tween<UnknownProps>>;
157
- removeAll(): void;
158
- add(tween: Tween<UnknownProps>): void;
159
- remove(tween: Tween<UnknownProps>): void;
160
- update(time?: number, preserve?: boolean): boolean;
161
- }
162
-
163
- declare let now: () => number;
145
+ declare const now: () => number;
164
146
 
165
147
  /**
166
148
  * Utils
@@ -170,70 +152,32 @@ declare class Sequence {
170
152
  static nextId(): number;
171
153
  }
172
154
 
173
- declare const VERSION = "18.6.4";
155
+ declare const VERSION = "20.0.0";
174
156
 
175
157
  declare const nextId: typeof Sequence.nextId;
176
- declare const getAll: () => Tween<Record<string, any>>[];
158
+ declare const getAll: () => Tween<UnknownProps>[];
177
159
  declare const removeAll: () => void;
178
- declare const add: (tween: Tween<Record<string, any>>) => void;
179
- declare const remove: (tween: Tween<Record<string, any>>) => void;
160
+ declare const add: (tween: Tween<UnknownProps>) => void;
161
+ declare const remove: (tween: Tween<UnknownProps>) => void;
180
162
  declare const update: (time?: number, preserve?: boolean) => boolean;
163
+
181
164
  declare const exports: {
182
- Easing: {
183
- Linear: {
184
- None: (amount: number) => number;
185
- };
186
- Quadratic: {
187
- In: (amount: number) => number;
188
- Out: (amount: number) => number;
189
- InOut: (amount: number) => number;
190
- };
191
- Cubic: {
192
- In: (amount: number) => number;
193
- Out: (amount: number) => number;
194
- InOut: (amount: number) => number;
195
- };
196
- Quartic: {
197
- In: (amount: number) => number;
198
- Out: (amount: number) => number;
199
- InOut: (amount: number) => number;
200
- };
201
- Quintic: {
202
- In: (amount: number) => number;
203
- Out: (amount: number) => number;
204
- InOut: (amount: number) => number;
205
- };
206
- Sinusoidal: {
207
- In: (amount: number) => number;
208
- Out: (amount: number) => number;
209
- InOut: (amount: number) => number;
210
- };
211
- Exponential: {
212
- In: (amount: number) => number;
213
- Out: (amount: number) => number;
214
- InOut: (amount: number) => number;
215
- };
216
- Circular: {
217
- In: (amount: number) => number;
218
- Out: (amount: number) => number;
219
- InOut: (amount: number) => number;
220
- };
221
- Elastic: {
222
- In: (amount: number) => number;
223
- Out: (amount: number) => number;
224
- InOut: (amount: number) => number;
225
- };
226
- Back: {
227
- In: (amount: number) => number;
228
- Out: (amount: number) => number;
229
- InOut: (amount: number) => number;
230
- };
231
- Bounce: {
232
- In: (amount: number) => number;
233
- Out: (amount: number) => number;
234
- InOut: (amount: number) => number;
235
- };
236
- };
165
+ Easing: Readonly<{
166
+ Linear: Readonly<EasingFunctionGroup & {
167
+ None: EasingFunction;
168
+ }>;
169
+ Quadratic: Readonly<EasingFunctionGroup>;
170
+ Cubic: Readonly<EasingFunctionGroup>;
171
+ Quartic: Readonly<EasingFunctionGroup>;
172
+ Quintic: Readonly<EasingFunctionGroup>;
173
+ Sinusoidal: Readonly<EasingFunctionGroup>;
174
+ Exponential: Readonly<EasingFunctionGroup>;
175
+ Circular: Readonly<EasingFunctionGroup>;
176
+ Elastic: Readonly<EasingFunctionGroup>;
177
+ Back: Readonly<EasingFunctionGroup>;
178
+ Bounce: Readonly<EasingFunctionGroup>;
179
+ generatePow(power?: number): EasingFunctionGroup;
180
+ }>;
237
181
  Group: typeof Group;
238
182
  Interpolation: {
239
183
  Linear: (v: number[], k: number) => number;
@@ -251,12 +195,11 @@ declare const exports: {
251
195
  nextId: typeof Sequence.nextId;
252
196
  Tween: typeof Tween;
253
197
  VERSION: string;
254
- getAll: () => Tween<Record<string, any>>[];
198
+ getAll: () => Tween<UnknownProps>[];
255
199
  removeAll: () => void;
256
- add: (tween: Tween<Record<string, any>>) => void;
257
- remove: (tween: Tween<Record<string, any>>) => void;
200
+ add: (tween: Tween<UnknownProps>) => void;
201
+ remove: (tween: Tween<UnknownProps>) => void;
258
202
  update: (time?: number, preserve?: boolean) => boolean;
259
203
  };
260
204
 
261
- export default exports;
262
- export { Easing, Group, Interpolation, Sequence, Tween, VERSION, add, getAll, nextId, now, remove, removeAll, update };
205
+ export { Easing, Group, Interpolation, Sequence, Tween, VERSION, add, exports as default, getAll, nextId, now, remove, removeAll, update };