Skip to content

Commit c977cdf

Browse files
authored
Merge pull request phaserjs#4573 from samme/types/timeline-config
Add types for Timeline config
2 parents 77626d8 + d9ecd70 commit c977cdf

10 files changed

Lines changed: 92 additions & 43 deletions

src/tweens/Timeline.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ var Timeline = new Class({
264264
},
265265

266266
/**
267-
* Gets the value of the time scale applied to this Timeline. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on.
267+
* Gets the value of the time scale applied to this Timeline. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on.
268268
*
269269
* @method Phaser.Tweens.Timeline#getTimeScale
270270
* @since 3.0.0
@@ -290,12 +290,12 @@ var Timeline = new Class({
290290
},
291291

292292
/**
293-
* [description]
293+
* Creates a new Tween and adds it to this Timeline.
294294
*
295295
* @method Phaser.Tweens.Timeline#add
296296
* @since 3.0.0
297297
*
298-
* @param {object} config - [description]
298+
* @param {(Phaser.Types.Tweens.TweenBuilderConfig|object)} config - The configuration object for the Tween.
299299
*
300300
* @return {Phaser.Tweens.Timeline} This Timeline object.
301301
*/
@@ -305,12 +305,12 @@ var Timeline = new Class({
305305
},
306306

307307
/**
308-
* [description]
308+
* Adds a Tween to this Timeline.
309309
*
310310
* @method Phaser.Tweens.Timeline#queue
311311
* @since 3.0.0
312312
*
313-
* @param {Phaser.Tweens.Tween} tween - [description]
313+
* @param {Phaser.Tweens.Tween} tween - The tween
314314
*
315315
* @return {Phaser.Tweens.Timeline} This Timeline object.
316316
*/
@@ -330,14 +330,14 @@ var Timeline = new Class({
330330
},
331331

332332
/**
333-
* [description]
333+
* Checks whether a tween has an offset value.
334334
*
335335
* @method Phaser.Tweens.Timeline#hasOffset
336336
* @since 3.0.0
337337
*
338-
* @param {Phaser.Tweens.Tween} tween - [description]
338+
* @param {Phaser.Tweens.Tween} tween - The tween
339339
*
340-
* @return {boolean} [description]
340+
* @return {boolean} True if the tween has a non-null offset.
341341
*/
342342
hasOffset: function (tween)
343343
{
@@ -604,12 +604,14 @@ var Timeline = new Class({
604604
},
605605

606606
/**
607-
* [description]
607+
* Updates the Timeline's `state` and fires callbacks and events.
608608
*
609609
* @method Phaser.Tweens.Timeline#nextState
610610
* @fires Phaser.Tweens.Events#TIMELINE_COMPLETE
611611
* @fires Phaser.Tweens.Events#TIMELINE_LOOP
612612
* @since 3.0.0
613+
*
614+
* @see Phaser.Tweens.Timeline#update
613615
*/
614616
nextState: function ()
615617
{
@@ -674,7 +676,7 @@ var Timeline = new Class({
674676
* @fires Phaser.Tweens.Events#TIMELINE_UPDATE
675677
* @since 3.0.0
676678
*
677-
* @param {number} timestamp - [description]
679+
* @param {number} timestamp - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout.
678680
* @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate.
679681
*
680682
* @return {boolean} Returns `true` if this Timeline has finished and should be removed from the Tween Manager.

src/tweens/TweenManager.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ var TweenManager = new Class({
154154
* @method Phaser.Tweens.TweenManager#createTimeline
155155
* @since 3.0.0
156156
*
157-
* @param {object} config - The configuration object for the Timeline and its Tweens.
157+
* @param {Phaser.Types.Tweens.TimelineBuilderConfig} config - The configuration object for the Timeline and its Tweens.
158158
*
159159
* @return {Phaser.Tweens.Timeline} The created Timeline object.
160160
*/
@@ -169,7 +169,7 @@ var TweenManager = new Class({
169169
* @method Phaser.Tweens.TweenManager#timeline
170170
* @since 3.0.0
171171
*
172-
* @param {object} config - The configuration object for the Timeline and its Tweens.
172+
* @param {Phaser.Types.Tweens.TimelineBuilderConfig} config - The configuration object for the Timeline and its Tweens.
173173
*
174174
* @return {Phaser.Tweens.Timeline} The created Timeline object.
175175
*/

src/tweens/builders/TimelineBuilder.js

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,40 +19,11 @@ var TweenBuilder = require('./TweenBuilder');
1919
/**
2020
* Builds a Timeline of Tweens based on a configuration object.
2121
*
22-
* The configuration object (`config`) can have the following properties:
23-
*
24-
* `tweens` - an array of tween configuration objects to create and add into the new Timeline, as described by `TweenBuilder`. If this doesn't exist or is empty, the Timeline will start off paused and none of the other configuration settings will be read. If it's a function, it will be called and its return value will be used as the array.
25-
* `targets` - an array (or function which returns one) of default targets to which to apply the Timeline. Each individual Tween configuration can override this value.
26-
* `totalDuration` - if specified, each Tween in the Timeline will get an equal portion of this duration, usually in milliseconds, by default. Each individual Tween configuration can override the Tween's duration.
27-
* `duration` - if `totalDuration` is not specified, the default duration, usually in milliseconds, of each Tween which will be created. Each individual Tween configuration can override the Tween's duration.
28-
* `delay`, `easeParams`, `ease`, `hold`, `repeat`, `repeatDelay`, `yoyo`, `flipX`, `flipY` - the default settings for each Tween which will be created, as specified by `TweenBuilder`. Each individual Tween configuration can override any of these values.
29-
* `completeDelay` - if specified, the time to wait, usually in milliseconds, before the Timeline completes.
30-
* `loop` - how many times the Timeline should loop, or -1 to loop indefinitely.
31-
* `loopDelay` - the time, usually in milliseconds, between each loop
32-
* `paused` - if `true`, the Timeline will start paused
33-
* `useFrames` - if `true`, all duration in the Timeline will be in frames instead of milliseconds
34-
* `callbackScope` - the default scope (`this` value) to use for each callback registered by the Timeline Builder. If not specified, the Timeline itself will be used.
35-
* `onStart` - if specified, the `onStart` callback for the Timeline, called every time it starts playing
36-
* `onStartScope` - the scope (`this` value) to use for the `onStart` callback. If not specified, the `callbackScope` will be used.
37-
* `onStartParams` - additional arguments to pass to the `onStart` callback. The Timeline will always be the first argument.
38-
* `onUpdate` - if specified, the `onUpdate` callback for the Timeline, called every frame it's active, regardless of its Tweens
39-
* `onUpdateScope` - the scope (`this` value) to use for the `onUpdate` callback. If not specified, the `callbackScope` will be used.
40-
* `onUpdateParams` - additional arguments to pass to the `onUpdate` callback. The Timeline will always be the first argument.
41-
* `onLoop` - if specified, the `onLoop` callback for the Timeline, called every time it loops
42-
* `onLoopScope` - the scope (`this` value) to use for the `onLoop` callback. If not specified, the `callbackScope` will be used.
43-
* `onLoopParams` - additional arguments to pass to the `onLoop` callback. The Timeline will always be the first argument.
44-
* `onYoyo` - if specified, the `onYoyo` callback for the Timeline, called every time it yoyos
45-
* `onYoyoScope` - the scope (`this` value) to use for the `onYoyo` callback. If not specified, the `callbackScope` will be used.
46-
* `onYoyoParams` - additional arguments to pass to the `onYoyo` callback. The first argument will always be `null`, while the Timeline will always be the second argument.
47-
* `onComplete` - if specified, the `onComplete` callback for the Timeline, called after it completes
48-
* `onCompleteScope` - the scope (`this` value) to use for the `onComplete` callback. If not specified, the `callbackScope` will be used.
49-
* `onCompleteParams` - additional arguments to pass to the `onComplete` callback. The Timeline will always be the first argument.
50-
*
5122
* @function Phaser.Tweens.Builders.TimelineBuilder
5223
* @since 3.0.0
5324
*
5425
* @param {Phaser.Tweens.TweenManager} manager - The Tween Manager to which the Timeline will belong.
55-
* @param {object} config - The configuration object for the Timeline, as described above.
26+
* @param {Phaser.Types.Tweens.TimelineBuilderConfig} config - The configuration object for the Timeline.
5627
*
5728
* @return {Phaser.Tweens.Timeline} The created Timeline.
5829
*/

src/tweens/tween/Tween.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1261,7 +1261,7 @@ var Tween = new Class({
12611261
* @param {Phaser.Types.Tweens.TweenDataConfig} tweenData - The TweenData property to update.
12621262
* @param {number} delta - Either a value in ms, or 1 if Tween.useFrames is true
12631263
*
1264-
* @return {boolean} [description]
1264+
* @return {boolean} True if the tween is not complete (e.g., playing), or false if the tween is complete.
12651265
*/
12661266
updateTweenData: function (tween, tweenData, delta)
12671267
{

src/tweens/typedefs/TimelineBuilderConfig.js

Lines changed: 41 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* @callback Phaser.Types.Tweens.TimelineOnCompleteCallback
3+
* @since 3.18.0
4+
*
5+
* @param {Phaser.Tweens.Timeline} timeline - The timeline.
6+
* @param {...any} param - Any value passed in `onCompleteParams`.
7+
*/
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* @callback Phaser.Types.Tweens.TimelineOnLoopCallback
3+
* @since 3.18.0
4+
*
5+
* @param {Phaser.Tweens.Timeline} timeline - The timeline.
6+
* @param {...any} param - Any value passed in `onLoopParams`.
7+
*/
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* @callback Phaser.Types.Tweens.TimelineOnStartCallback
3+
* @since 3.18.0
4+
*
5+
* @param {Phaser.Tweens.Timeline} timeline - The timeline.
6+
* @param {...any} param - Any value passed in `onStartParams`.
7+
*/
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* @callback Phaser.Types.Tweens.TimelineOnUpdateCallback
3+
* @since 3.18.0
4+
*
5+
* @param {Phaser.Tweens.Timeline} timeline - The timeline.
6+
* @param {...any} param - Any value passed in `onUpdateParams`.
7+
*/
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* @callback Phaser.Types.Tweens.TimelineOnYoyoCallback
3+
* @since 3.18.0
4+
*
5+
* @param {Phaser.Tweens.Timeline} timeline - The timeline.
6+
* @param {...any} param - Any value passed in `onYoyoParams`.
7+
*/

0 commit comments

Comments
 (0)