Skip to content

Commit 4ee0caf

Browse files
authored
Merge pull request #579 from tweenjs/release-v18.6.3
v18.6.3
2 parents a15fbd8 + 60535f4 commit 4ee0caf

File tree

8 files changed

+128
-87
lines changed

8 files changed

+128
-87
lines changed

dist/tween.amd.js

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,12 @@ define(['exports'], function (exports) { 'use strict';
248248
delete this._tweensAddedDuringUpdate[tween.getId()];
249249
};
250250
Group.prototype.update = function (time, preserve) {
251+
if (time === void 0) { time = now$1(); }
252+
if (preserve === void 0) { preserve = false; }
251253
var tweenIds = Object.keys(this._tweens);
252254
if (tweenIds.length === 0) {
253255
return false;
254256
}
255-
time = time !== undefined ? time : now$1();
256257
// Tweens are updated in "batches". If you add a new tween during an
257258
// update, then the new tween will be updated in the next batch.
258259
// If you remove a tween during an update, it may or may not be updated.
@@ -262,7 +263,8 @@ define(['exports'], function (exports) { 'use strict';
262263
this._tweensAddedDuringUpdate = {};
263264
for (var i = 0; i < tweenIds.length; i++) {
264265
var tween = this._tweens[tweenIds[i]];
265-
if (tween && tween.update(time, preserve) === false && !preserve) {
266+
var autoStart = !preserve;
267+
if (tween && tween.update(time, autoStart) === false && !preserve) {
266268
delete this._tweens[tweenIds[i]];
267269
}
268270
}
@@ -412,9 +414,11 @@ define(['exports'], function (exports) { 'use strict';
412414
return this._isPaused;
413415
};
414416
Tween.prototype.to = function (properties, duration) {
415-
for (var prop in properties) {
416-
this._valuesEnd[prop] = properties[prop];
417-
}
417+
// TODO? restore this, then update the 07_dynamic_to example to set fox
418+
// tween's to on each update. That way the behavior is opt-in (there's
419+
// currently no opt-out).
420+
// for (const prop in properties) this._valuesEnd[prop] = properties[prop]
421+
this._valuesEnd = Object.create(properties);
418422
if (duration !== undefined) {
419423
this._duration = duration;
420424
}
@@ -429,8 +433,7 @@ define(['exports'], function (exports) { 'use strict';
429433
return this;
430434
}
431435
// eslint-disable-next-line
432-
// @ts-ignore FIXME?
433-
this._group.add(this);
436+
this._group && this._group.add(this);
434437
this._repeat = this._initialRepeat;
435438
if (this._reversed) {
436439
// If we were reversed (f.e. using the yoyo feature) then we need to
@@ -516,8 +519,7 @@ define(['exports'], function (exports) { 'use strict';
516519
return this;
517520
}
518521
// eslint-disable-next-line
519-
// @ts-ignore FIXME?
520-
this._group.remove(this);
522+
this._group && this._group.remove(this);
521523
this._isPlaying = false;
522524
this._isPaused = false;
523525
if (this._onStopCallback) {
@@ -531,26 +533,26 @@ define(['exports'], function (exports) { 'use strict';
531533
return this;
532534
};
533535
Tween.prototype.pause = function (time) {
536+
if (time === void 0) { time = now$1(); }
534537
if (this._isPaused || !this._isPlaying) {
535538
return this;
536539
}
537540
this._isPaused = true;
538-
this._pauseStart = time === undefined ? now$1() : time;
541+
this._pauseStart = time;
539542
// eslint-disable-next-line
540-
// @ts-ignore FIXME?
541-
this._group.remove(this);
543+
this._group && this._group.remove(this);
542544
return this;
543545
};
544546
Tween.prototype.resume = function (time) {
547+
if (time === void 0) { time = now$1(); }
545548
if (!this._isPaused || !this._isPlaying) {
546549
return this;
547550
}
548551
this._isPaused = false;
549-
this._startTime += (time === undefined ? now$1() : time) - this._pauseStart;
552+
this._startTime += time - this._pauseStart;
550553
this._pauseStart = 0;
551554
// eslint-disable-next-line
552-
// @ts-ignore FIXME?
553-
this._group.add(this);
555+
this._group && this._group.add(this);
554556
return this;
555557
};
556558
Tween.prototype.stopChainedTweens = function () {
@@ -616,16 +618,23 @@ define(['exports'], function (exports) { 'use strict';
616618
this._onStopCallback = callback;
617619
return this;
618620
};
619-
Tween.prototype.update = function (time, preserve) {
621+
/**
622+
* @returns true if the tween is still playing after the update, false
623+
* otherwise (calling update on a paused tween still returns true because
624+
* it is still playing, just paused).
625+
*/
626+
Tween.prototype.update = function (time, autoStart) {
620627
if (time === void 0) { time = now$1(); }
621-
if (preserve === void 0) { preserve = false; }
628+
if (autoStart === void 0) { autoStart = true; }
629+
if (this._isPaused)
630+
return true;
622631
var property;
623632
var elapsed;
624633
var endTime = this._startTime + this._duration;
625634
if (!this._goToEnd && !this._isPlaying) {
626635
if (time > endTime)
627636
return false;
628-
if (!preserve)
637+
if (autoStart)
629638
this.start(time);
630639
}
631640
this._goToEnd = false;
@@ -750,7 +759,7 @@ define(['exports'], function (exports) { 'use strict';
750759
return Tween;
751760
}());
752761

753-
var VERSION = '18.6.2';
762+
var VERSION = '18.6.3';
754763

755764
/**
756765
* Tween.js - Licensed under the MIT license

dist/tween.cjs.js

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,12 @@ var Group = /** @class */ (function () {
250250
delete this._tweensAddedDuringUpdate[tween.getId()];
251251
};
252252
Group.prototype.update = function (time, preserve) {
253+
if (time === void 0) { time = now$1(); }
254+
if (preserve === void 0) { preserve = false; }
253255
var tweenIds = Object.keys(this._tweens);
254256
if (tweenIds.length === 0) {
255257
return false;
256258
}
257-
time = time !== undefined ? time : now$1();
258259
// Tweens are updated in "batches". If you add a new tween during an
259260
// update, then the new tween will be updated in the next batch.
260261
// If you remove a tween during an update, it may or may not be updated.
@@ -264,7 +265,8 @@ var Group = /** @class */ (function () {
264265
this._tweensAddedDuringUpdate = {};
265266
for (var i = 0; i < tweenIds.length; i++) {
266267
var tween = this._tweens[tweenIds[i]];
267-
if (tween && tween.update(time, preserve) === false && !preserve) {
268+
var autoStart = !preserve;
269+
if (tween && tween.update(time, autoStart) === false && !preserve) {
268270
delete this._tweens[tweenIds[i]];
269271
}
270272
}
@@ -414,9 +416,11 @@ var Tween = /** @class */ (function () {
414416
return this._isPaused;
415417
};
416418
Tween.prototype.to = function (properties, duration) {
417-
for (var prop in properties) {
418-
this._valuesEnd[prop] = properties[prop];
419-
}
419+
// TODO? restore this, then update the 07_dynamic_to example to set fox
420+
// tween's to on each update. That way the behavior is opt-in (there's
421+
// currently no opt-out).
422+
// for (const prop in properties) this._valuesEnd[prop] = properties[prop]
423+
this._valuesEnd = Object.create(properties);
420424
if (duration !== undefined) {
421425
this._duration = duration;
422426
}
@@ -431,8 +435,7 @@ var Tween = /** @class */ (function () {
431435
return this;
432436
}
433437
// eslint-disable-next-line
434-
// @ts-ignore FIXME?
435-
this._group.add(this);
438+
this._group && this._group.add(this);
436439
this._repeat = this._initialRepeat;
437440
if (this._reversed) {
438441
// If we were reversed (f.e. using the yoyo feature) then we need to
@@ -518,8 +521,7 @@ var Tween = /** @class */ (function () {
518521
return this;
519522
}
520523
// eslint-disable-next-line
521-
// @ts-ignore FIXME?
522-
this._group.remove(this);
524+
this._group && this._group.remove(this);
523525
this._isPlaying = false;
524526
this._isPaused = false;
525527
if (this._onStopCallback) {
@@ -533,26 +535,26 @@ var Tween = /** @class */ (function () {
533535
return this;
534536
};
535537
Tween.prototype.pause = function (time) {
538+
if (time === void 0) { time = now$1(); }
536539
if (this._isPaused || !this._isPlaying) {
537540
return this;
538541
}
539542
this._isPaused = true;
540-
this._pauseStart = time === undefined ? now$1() : time;
543+
this._pauseStart = time;
541544
// eslint-disable-next-line
542-
// @ts-ignore FIXME?
543-
this._group.remove(this);
545+
this._group && this._group.remove(this);
544546
return this;
545547
};
546548
Tween.prototype.resume = function (time) {
549+
if (time === void 0) { time = now$1(); }
547550
if (!this._isPaused || !this._isPlaying) {
548551
return this;
549552
}
550553
this._isPaused = false;
551-
this._startTime += (time === undefined ? now$1() : time) - this._pauseStart;
554+
this._startTime += time - this._pauseStart;
552555
this._pauseStart = 0;
553556
// eslint-disable-next-line
554-
// @ts-ignore FIXME?
555-
this._group.add(this);
557+
this._group && this._group.add(this);
556558
return this;
557559
};
558560
Tween.prototype.stopChainedTweens = function () {
@@ -618,16 +620,23 @@ var Tween = /** @class */ (function () {
618620
this._onStopCallback = callback;
619621
return this;
620622
};
621-
Tween.prototype.update = function (time, preserve) {
623+
/**
624+
* @returns true if the tween is still playing after the update, false
625+
* otherwise (calling update on a paused tween still returns true because
626+
* it is still playing, just paused).
627+
*/
628+
Tween.prototype.update = function (time, autoStart) {
622629
if (time === void 0) { time = now$1(); }
623-
if (preserve === void 0) { preserve = false; }
630+
if (autoStart === void 0) { autoStart = true; }
631+
if (this._isPaused)
632+
return true;
624633
var property;
625634
var elapsed;
626635
var endTime = this._startTime + this._duration;
627636
if (!this._goToEnd && !this._isPlaying) {
628637
if (time > endTime)
629638
return false;
630-
if (!preserve)
639+
if (autoStart)
631640
this.start(time);
632641
}
633642
this._goToEnd = false;
@@ -752,7 +761,7 @@ var Tween = /** @class */ (function () {
752761
return Tween;
753762
}());
754763

755-
var VERSION = '18.6.2';
764+
var VERSION = '18.6.3';
756765

757766
/**
758767
* Tween.js - Licensed under the MIT license

dist/tween.d.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ declare class Tween<T extends UnknownProps> {
105105
private _onStopCallback?;
106106
private _id;
107107
private _isChainStopped;
108-
constructor(_object: T, _group?: Group);
108+
constructor(_object: T, _group?: Group | false);
109109
getId(): number;
110110
isPlaying(): boolean;
111111
isPaused(): boolean;
@@ -115,8 +115,8 @@ declare class Tween<T extends UnknownProps> {
115115
private _setupProperties;
116116
stop(): this;
117117
end(): this;
118-
pause(time: number): this;
119-
resume(time: number): this;
118+
pause(time?: number): this;
119+
resume(time?: number): this;
120120
stopChainedTweens(): this;
121121
group(group: Group): this;
122122
delay(amount: number): this;
@@ -132,7 +132,12 @@ declare class Tween<T extends UnknownProps> {
132132
onComplete(callback: (object: T) => void): this;
133133
onStop(callback: (object: T) => void): this;
134134
private _goToEnd;
135-
update(time?: number, preserve?: boolean): boolean;
135+
/**
136+
* @returns true if the tween is still playing after the update, false
137+
* otherwise (calling update on a paused tween still returns true because
138+
* it is still playing, just paused).
139+
*/
140+
update(time?: number, autoStart?: boolean): boolean;
136141
private _updateProperties;
137142
private _handleRelativeValue;
138143
private _swapEndStartRepeatValues;
@@ -152,7 +157,7 @@ declare class Group {
152157
removeAll(): void;
153158
add(tween: Tween<UnknownProps>): void;
154159
remove(tween: Tween<UnknownProps>): void;
155-
update(time: number, preserve?: boolean): boolean;
160+
update(time?: number, preserve?: boolean): boolean;
156161
}
157162

158163
declare let now: () => number;
@@ -165,14 +170,14 @@ declare class Sequence {
165170
static nextId(): number;
166171
}
167172

168-
declare const VERSION = "18.6.2";
173+
declare const VERSION = "18.6.3";
169174

170175
declare const nextId: typeof Sequence.nextId;
171176
declare const getAll: () => Tween<Record<string, unknown>>[];
172177
declare const removeAll: () => void;
173178
declare const add: (tween: Tween<Record<string, unknown>>) => void;
174179
declare const remove: (tween: Tween<Record<string, unknown>>) => void;
175-
declare const update: (time: number, preserve?: boolean | undefined) => boolean;
180+
declare const update: (time?: number, preserve?: boolean) => boolean;
176181
declare const exports: {
177182
Easing: {
178183
Linear: {
@@ -250,7 +255,7 @@ declare const exports: {
250255
removeAll: () => void;
251256
add: (tween: Tween<Record<string, unknown>>) => void;
252257
remove: (tween: Tween<Record<string, unknown>>) => void;
253-
update: (time: number, preserve?: boolean | undefined) => boolean;
258+
update: (time?: number, preserve?: boolean) => boolean;
254259
};
255260

256261
export default exports;

0 commit comments

Comments
 (0)