Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tweenjs/tween.js

Package Overview
Dependencies
Maintainers
4
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tweenjs/tween.js - npm Package Compare versions

Comparing version 23.1.3 to 24.0.0

575

dist/tween.amd.js

@@ -228,10 +228,13 @@ define(['exports'], (function (exports) { 'use strict';

function Group() {
var tweens = [];
for (var _i = 0; _i < arguments.length; _i++) {
tweens[_i] = arguments[_i];
}
this._tweens = {};
this._tweensAddedDuringUpdate = {};
this.add.apply(this, tweens);
}
Group.prototype.getAll = function () {
var _this = this;
return Object.keys(this._tweens).map(function (tweenId) {
return _this._tweens[tweenId];
});
return Object.keys(this._tweens).map(function (tweenId) { return _this._tweens[tweenId]; });
};

@@ -241,17 +244,42 @@ Group.prototype.removeAll = function () {

};
Group.prototype.add = function (tween) {
this._tweens[tween.getId()] = tween;
this._tweensAddedDuringUpdate[tween.getId()] = tween;
Group.prototype.add = function () {
var _a;
var tweens = [];
for (var _i = 0; _i < arguments.length; _i++) {
tweens[_i] = arguments[_i];
}
for (var _b = 0, tweens_1 = tweens; _b < tweens_1.length; _b++) {
var tween = tweens_1[_b];
// Remove from any other group first, a tween can only be in one group at a time.
// @ts-expect-error library internal access
(_a = tween._group) === null || _a === void 0 ? void 0 : _a.remove(tween);
// @ts-expect-error library internal access
tween._group = this;
this._tweens[tween.getId()] = tween;
this._tweensAddedDuringUpdate[tween.getId()] = tween;
}
};
Group.prototype.remove = function (tween) {
delete this._tweens[tween.getId()];
delete this._tweensAddedDuringUpdate[tween.getId()];
Group.prototype.remove = function () {
var tweens = [];
for (var _i = 0; _i < arguments.length; _i++) {
tweens[_i] = arguments[_i];
}
for (var _a = 0, tweens_2 = tweens; _a < tweens_2.length; _a++) {
var tween = tweens_2[_a];
// @ts-expect-error library internal access
tween._group = undefined;
delete this._tweens[tween.getId()];
delete this._tweensAddedDuringUpdate[tween.getId()];
}
};
/** Return true if all tweens in the group are not paused or playing. */
Group.prototype.allStopped = function () {
return this.getAll().every(function (tween) { return !tween.isPlaying(); });
};
Group.prototype.update = function (time, preserve) {
if (time === void 0) { time = now(); }
if (preserve === void 0) { preserve = false; }
if (preserve === void 0) { preserve = true; }
var tweenIds = Object.keys(this._tweens);
if (tweenIds.length === 0) {
return false;
}
if (tweenIds.length === 0)
return;
// Tweens are updated in "batches". If you add a new tween during an

@@ -267,9 +295,7 @@ // update, then the new tween will be updated in the next batch.

var autoStart = !preserve;
if (tween && tween.update(time, autoStart) === false && !preserve) {
delete this._tweens[tweenIds[i]];
}
if (tween && tween.update(time, autoStart) === false && !preserve)
this.remove(tween);
}
tweenIds = Object.keys(this._tweensAddedDuringUpdate);
}
return true;
};

@@ -383,6 +409,3 @@ return Group;

var Tween = /** @class */ (function () {
function Tween(_object, _group) {
if (_group === void 0) { _group = mainGroup; }
this._object = _object;
this._group = _group;
function Tween(object, group) {
this._isPaused = false;

@@ -412,2 +435,12 @@ this._pauseStart = 0;

this._goToEnd = false;
this._object = object;
if (typeof group === 'object') {
this._group = group;
group.add(this);
}
// Use "true" to restore old behavior (will be removed in future release).
else if (group === true) {
this._group = mainGroup;
mainGroup.add(this);
}
}

@@ -451,4 +484,2 @@ Tween.prototype.getId = function () {

}
// eslint-disable-next-line
this._group && this._group.add(this);
this._repeat = this._initialRepeat;

@@ -570,4 +601,2 @@ if (this._reversed) {

}
// eslint-disable-next-line
this._group && this._group.remove(this);
this._isPlaying = false;

@@ -592,4 +621,2 @@ this._isPaused = false;

this._pauseStart = time;
// eslint-disable-next-line
this._group && this._group.remove(this);
return this;

@@ -605,4 +632,2 @@ };

this._pauseStart = 0;
// eslint-disable-next-line
this._group && this._group.add(this);
return this;

@@ -617,6 +642,17 @@ };

Tween.prototype.group = function (group) {
if (group === void 0) { group = mainGroup; }
this._group = group;
if (!group) {
console.warn('tween.group() without args has been removed, use group.add(tween) instead.');
return this;
}
group.add(this);
return this;
};
/**
* Removes the tween from whichever group it is in.
*/
Tween.prototype.remove = function () {
var _a;
(_a = this._group) === null || _a === void 0 ? void 0 : _a.remove(this);
return this;
};
Tween.prototype.delay = function (amount) {

@@ -698,8 +734,7 @@ if (amount === void 0) { amount = 0; }

var property;
var endTime = this._startTime + this._duration;
if (!this._goToEnd && !this._isPlaying) {
if (time > endTime)
return false;
if (autoStart)
this.start(time, true);
else
return false;
}

@@ -846,3 +881,3 @@ this._goToEnd = false;

var VERSION = '23.1.3';
var VERSION = '24.0.0';

@@ -869,6 +904,241 @@ /**

// https://github.com/rollup/rollup/issues/1961#issuecomment-423037881
/**
* @deprecated The global TWEEN Group will be removed in a following major
* release. To migrate, create a `new Group()` instead of using `TWEEN` as a
* group.
*
* Old code:
*
* ```js
* import * as TWEEN from '@tweenjs/tween.js'
*
* //...
*
* const tween = new TWEEN.Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* TWEEN.update(time)
* requestAnimationFrame(loop)
* })
* ```
*
* New code:
*
* ```js
* import {Tween, Group} from '@tweenjs/tween.js'
*
* //...
*
* const tween = new Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* const group = new Group()
* group.add(tween)
* group.add(tween2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* group.update(time)
* requestAnimationFrame(loop)
* })
* ```
*/
var getAll = TWEEN.getAll.bind(TWEEN);
/**
* @deprecated The global TWEEN Group will be removed in a following major
* release. To migrate, create a `new Group()` instead of using `TWEEN` as a
* group.
*
* Old code:
*
* ```js
* import * as TWEEN from '@tweenjs/tween.js'
*
* //...
*
* const tween = new TWEEN.Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* TWEEN.update(time)
* requestAnimationFrame(loop)
* })
* ```
*
* New code:
*
* ```js
* import {Tween, Group} from '@tweenjs/tween.js'
*
* //...
*
* const tween = new Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* const group = new Group()
* group.add(tween)
* group.add(tween2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* group.update(time)
* requestAnimationFrame(loop)
* })
* ```
*/
var removeAll = TWEEN.removeAll.bind(TWEEN);
/**
* @deprecated The global TWEEN Group will be removed in a following major
* release. To migrate, create a `new Group()` instead of using `TWEEN` as a
* group.
*
* Old code:
*
* ```js
* import * as TWEEN from '@tweenjs/tween.js'
*
* //...
*
* const tween = new TWEEN.Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* TWEEN.update(time)
* requestAnimationFrame(loop)
* })
* ```
*
* New code:
*
* ```js
* import {Tween, Group} from '@tweenjs/tween.js'
*
* //...
*
* const tween = new Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* const group = new Group()
* group.add(tween)
* group.add(tween2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* group.update(time)
* requestAnimationFrame(loop)
* })
* ```
*/
var add = TWEEN.add.bind(TWEEN);
/**
* @deprecated The global TWEEN Group will be removed in a following major
* release. To migrate, create a `new Group()` instead of using `TWEEN` as a
* group.
*
* Old code:
*
* ```js
* import * as TWEEN from '@tweenjs/tween.js'
*
* //...
*
* const tween = new TWEEN.Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* TWEEN.update(time)
* requestAnimationFrame(loop)
* })
* ```
*
* New code:
*
* ```js
* import {Tween, Group} from '@tweenjs/tween.js'
*
* //...
*
* const tween = new Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* const group = new Group()
* group.add(tween)
* group.add(tween2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* group.update(time)
* requestAnimationFrame(loop)
* })
* ```
*/
var remove = TWEEN.remove.bind(TWEEN);
/**
* @deprecated The global TWEEN Group will be removed in a following major
* release. To migrate, create a `new Group()` instead of using `TWEEN` as a
* group.
*
* Old code:
*
* ```js
* import * as TWEEN from '@tweenjs/tween.js'
*
* //...
*
* const tween = new TWEEN.Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* TWEEN.update(time)
* requestAnimationFrame(loop)
* })
* ```
*
* New code:
*
* ```js
* import {Tween, Group} from '@tweenjs/tween.js'
*
* //...
*
* const tween = new Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* const group = new Group()
* group.add(tween)
* group.add(tween2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* group.update(time)
* requestAnimationFrame(loop)
* })
* ```
*/
var update = TWEEN.update.bind(TWEEN);

@@ -884,6 +1154,241 @@ var exports$1 = {

VERSION: VERSION,
/**
* @deprecated The global TWEEN Group will be removed in a following major
* release. To migrate, create a `new Group()` instead of using `TWEEN` as a
* group.
*
* Old code:
*
* ```js
* import * as TWEEN from '@tweenjs/tween.js'
*
* //...
*
* const tween = new TWEEN.Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* TWEEN.update(time)
* requestAnimationFrame(loop)
* })
* ```
*
* New code:
*
* ```js
* import {Tween, Group} from '@tweenjs/tween.js'
*
* //...
*
* const tween = new Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* const group = new Group()
* group.add(tween)
* group.add(tween2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* group.update(time)
* requestAnimationFrame(loop)
* })
* ```
*/
getAll: getAll,
/**
* @deprecated The global TWEEN Group will be removed in a following major
* release. To migrate, create a `new Group()` instead of using `TWEEN` as a
* group.
*
* Old code:
*
* ```js
* import * as TWEEN from '@tweenjs/tween.js'
*
* //...
*
* const tween = new TWEEN.Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* TWEEN.update(time)
* requestAnimationFrame(loop)
* })
* ```
*
* New code:
*
* ```js
* import {Tween, Group} from '@tweenjs/tween.js'
*
* //...
*
* const tween = new Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* const group = new Group()
* group.add(tween)
* group.add(tween2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* group.update(time)
* requestAnimationFrame(loop)
* })
* ```
*/
removeAll: removeAll,
/**
* @deprecated The global TWEEN Group will be removed in a following major
* release. To migrate, create a `new Group()` instead of using `TWEEN` as a
* group.
*
* Old code:
*
* ```js
* import * as TWEEN from '@tweenjs/tween.js'
*
* //...
*
* const tween = new TWEEN.Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* TWEEN.update(time)
* requestAnimationFrame(loop)
* })
* ```
*
* New code:
*
* ```js
* import {Tween, Group} from '@tweenjs/tween.js'
*
* //...
*
* const tween = new Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* const group = new Group()
* group.add(tween)
* group.add(tween2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* group.update(time)
* requestAnimationFrame(loop)
* })
* ```
*/
add: add,
/**
* @deprecated The global TWEEN Group will be removed in a following major
* release. To migrate, create a `new Group()` instead of using `TWEEN` as a
* group.
*
* Old code:
*
* ```js
* import * as TWEEN from '@tweenjs/tween.js'
*
* //...
*
* const tween = new TWEEN.Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* TWEEN.update(time)
* requestAnimationFrame(loop)
* })
* ```
*
* New code:
*
* ```js
* import {Tween, Group} from '@tweenjs/tween.js'
*
* //...
*
* const tween = new Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* const group = new Group()
* group.add(tween)
* group.add(tween2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* group.update(time)
* requestAnimationFrame(loop)
* })
* ```
*/
remove: remove,
/**
* @deprecated The global TWEEN Group will be removed in a following major
* release. To migrate, create a `new Group()` instead of using `TWEEN` as a
* group.
*
* Old code:
*
* ```js
* import * as TWEEN from '@tweenjs/tween.js'
*
* //...
*
* const tween = new TWEEN.Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* TWEEN.update(time)
* requestAnimationFrame(loop)
* })
* ```
*
* New code:
*
* ```js
* import {Tween, Group} from '@tweenjs/tween.js'
*
* //...
*
* const tween = new Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* const group = new Group()
* group.add(tween)
* group.add(tween2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* group.update(time)
* requestAnimationFrame(loop)
* })
* ```
*/
update: update,

@@ -890,0 +1395,0 @@ };

@@ -47,18 +47,2 @@ type EasingFunction = (amount: number) => number;

/**
* Controlling groups of tweens
*
* Using the TWEEN singleton to manage your tweens can cause issues in large apps with many components.
* In these cases, you may want to create your own smaller groups of tween
*/
declare class Group {
private _tweens;
private _tweensAddedDuringUpdate;
getAll(): Array<Tween<UnknownProps>>;
removeAll(): void;
add(tween: Tween<UnknownProps>): void;
remove(tween: Tween<UnknownProps>): void;
update(time?: number, preserve?: boolean): boolean;
}
/**
* Tween.js - Licensed under the MIT license

@@ -72,5 +56,3 @@ * https://github.com/tweenjs/tween.js

declare class Tween<T extends UnknownProps> {
private _object;
private _group;
declare class Tween<T extends UnknownProps = any> {
private _isPaused;

@@ -105,3 +87,16 @@ private _pauseStart;

private _propertiesAreSetUp;
constructor(_object: T, _group?: Group | false);
private _object;
private _group?;
/**
* @param object - The object whose properties this Tween will animate.
* @param group - The object whose properties this Tween will animate.
*/
constructor(object: T, group?: Group);
/**
* @deprecated The group parameter is now deprecated, instead use `new
* Tween(object)` then `group.add(tween)` to add a tween to a group. Use
* `new Tween(object, true)` to restore the old behavior for now, but this
* will be removed in the future.
*/
constructor(object: T, group: true);
getId(): number;

@@ -122,3 +117,16 @@ isPlaying(): boolean;

stopChainedTweens(): this;
group(group?: Group): this;
/**
* Removes the tween from the current group it is in, if any, then adds the
* tween to the specified `group`.
*/
group(group: Group): this;
/**
* @deprecated The argless call signature has been removed. Use
* `tween.group(group)` or `group.add(tween)`, instead.
*/
group(): this;
/**
* Removes the tween from whichever group it is in.
*/
remove(): this;
delay(amount?: number): this;

@@ -150,2 +158,29 @@ repeat(times?: number): this;

/**
* Controlling groups of tweens
*
* Using the TWEEN singleton to manage your tweens can cause issues in large apps with many components.
* In these cases, you may want to create your own smaller groups of tween
*/
declare class Group {
private _tweens;
private _tweensAddedDuringUpdate;
constructor(...tweens: Tween[]);
getAll(): Array<Tween>;
removeAll(): void;
add(...tweens: Tween[]): void;
remove(...tweens: Tween[]): void;
/** Return true if all tweens in the group are not paused or playing. */
allStopped(): boolean;
update(time?: number): void;
/**
* @deprecated The `preserve` parameter is now defaulted to `true` and will
* be removed in a future major release, at which point all tweens of a
* group will always be preserved when calling update. To migrate, always
* use `group.add(tween)` or `group.remove(tween)` to manually add or remove
* tweens, and do not rely on tweens being automatically added or removed.
*/
update(time?: number, preserve?: boolean): void;
}
declare const now: () => number;

@@ -161,10 +196,248 @@

declare const VERSION = "23.1.3";
declare const VERSION = "24.0.0";
declare const nextId: typeof Sequence.nextId;
declare const getAll: () => Tween<UnknownProps>[];
/**
* @deprecated The global TWEEN Group will be removed in a following major
* release. To migrate, create a `new Group()` instead of using `TWEEN` as a
* group.
*
* Old code:
*
* ```js
* import * as TWEEN from '@tweenjs/tween.js'
*
* //...
*
* const tween = new TWEEN.Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* TWEEN.update(time)
* requestAnimationFrame(loop)
* })
* ```
*
* New code:
*
* ```js
* import {Tween, Group} from '@tweenjs/tween.js'
*
* //...
*
* const tween = new Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* const group = new Group()
* group.add(tween)
* group.add(tween2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* group.update(time)
* requestAnimationFrame(loop)
* })
* ```
*/
declare const getAll: () => Tween<any>[];
/**
* @deprecated The global TWEEN Group will be removed in a following major
* release. To migrate, create a `new Group()` instead of using `TWEEN` as a
* group.
*
* Old code:
*
* ```js
* import * as TWEEN from '@tweenjs/tween.js'
*
* //...
*
* const tween = new TWEEN.Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* TWEEN.update(time)
* requestAnimationFrame(loop)
* })
* ```
*
* New code:
*
* ```js
* import {Tween, Group} from '@tweenjs/tween.js'
*
* //...
*
* const tween = new Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* const group = new Group()
* group.add(tween)
* group.add(tween2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* group.update(time)
* requestAnimationFrame(loop)
* })
* ```
*/
declare const removeAll: () => void;
declare const add: (tween: Tween<UnknownProps>) => void;
declare const remove: (tween: Tween<UnknownProps>) => void;
declare const update: (time?: number, preserve?: boolean) => boolean;
/**
* @deprecated The global TWEEN Group will be removed in a following major
* release. To migrate, create a `new Group()` instead of using `TWEEN` as a
* group.
*
* Old code:
*
* ```js
* import * as TWEEN from '@tweenjs/tween.js'
*
* //...
*
* const tween = new TWEEN.Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* TWEEN.update(time)
* requestAnimationFrame(loop)
* })
* ```
*
* New code:
*
* ```js
* import {Tween, Group} from '@tweenjs/tween.js'
*
* //...
*
* const tween = new Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* const group = new Group()
* group.add(tween)
* group.add(tween2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* group.update(time)
* requestAnimationFrame(loop)
* })
* ```
*/
declare const add: (...tweens: Tween<any>[]) => void;
/**
* @deprecated The global TWEEN Group will be removed in a following major
* release. To migrate, create a `new Group()` instead of using `TWEEN` as a
* group.
*
* Old code:
*
* ```js
* import * as TWEEN from '@tweenjs/tween.js'
*
* //...
*
* const tween = new TWEEN.Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* TWEEN.update(time)
* requestAnimationFrame(loop)
* })
* ```
*
* New code:
*
* ```js
* import {Tween, Group} from '@tweenjs/tween.js'
*
* //...
*
* const tween = new Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* const group = new Group()
* group.add(tween)
* group.add(tween2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* group.update(time)
* requestAnimationFrame(loop)
* })
* ```
*/
declare const remove: (...tweens: Tween<any>[]) => void;
/**
* @deprecated The global TWEEN Group will be removed in a following major
* release. To migrate, create a `new Group()` instead of using `TWEEN` as a
* group.
*
* Old code:
*
* ```js
* import * as TWEEN from '@tweenjs/tween.js'
*
* //...
*
* const tween = new TWEEN.Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* TWEEN.update(time)
* requestAnimationFrame(loop)
* })
* ```
*
* New code:
*
* ```js
* import {Tween, Group} from '@tweenjs/tween.js'
*
* //...
*
* const tween = new Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* const group = new Group()
* group.add(tween)
* group.add(tween2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* group.update(time)
* requestAnimationFrame(loop)
* })
* ```
*/
declare const update: {
(time?: number | undefined): void;
(time?: number | undefined, preserve?: boolean | undefined): void;
};

@@ -205,9 +478,247 @@ declare const exports: {

VERSION: string;
getAll: () => Tween<UnknownProps>[];
/**
* @deprecated The global TWEEN Group will be removed in a following major
* release. To migrate, create a `new Group()` instead of using `TWEEN` as a
* group.
*
* Old code:
*
* ```js
* import * as TWEEN from '@tweenjs/tween.js'
*
* //...
*
* const tween = new TWEEN.Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* TWEEN.update(time)
* requestAnimationFrame(loop)
* })
* ```
*
* New code:
*
* ```js
* import {Tween, Group} from '@tweenjs/tween.js'
*
* //...
*
* const tween = new Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* const group = new Group()
* group.add(tween)
* group.add(tween2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* group.update(time)
* requestAnimationFrame(loop)
* })
* ```
*/
getAll: () => Tween<any>[];
/**
* @deprecated The global TWEEN Group will be removed in a following major
* release. To migrate, create a `new Group()` instead of using `TWEEN` as a
* group.
*
* Old code:
*
* ```js
* import * as TWEEN from '@tweenjs/tween.js'
*
* //...
*
* const tween = new TWEEN.Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* TWEEN.update(time)
* requestAnimationFrame(loop)
* })
* ```
*
* New code:
*
* ```js
* import {Tween, Group} from '@tweenjs/tween.js'
*
* //...
*
* const tween = new Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* const group = new Group()
* group.add(tween)
* group.add(tween2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* group.update(time)
* requestAnimationFrame(loop)
* })
* ```
*/
removeAll: () => void;
add: (tween: Tween<UnknownProps>) => void;
remove: (tween: Tween<UnknownProps>) => void;
update: (time?: number, preserve?: boolean) => boolean;
/**
* @deprecated The global TWEEN Group will be removed in a following major
* release. To migrate, create a `new Group()` instead of using `TWEEN` as a
* group.
*
* Old code:
*
* ```js
* import * as TWEEN from '@tweenjs/tween.js'
*
* //...
*
* const tween = new TWEEN.Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* TWEEN.update(time)
* requestAnimationFrame(loop)
* })
* ```
*
* New code:
*
* ```js
* import {Tween, Group} from '@tweenjs/tween.js'
*
* //...
*
* const tween = new Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* const group = new Group()
* group.add(tween)
* group.add(tween2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* group.update(time)
* requestAnimationFrame(loop)
* })
* ```
*/
add: (...tweens: Tween<any>[]) => void;
/**
* @deprecated The global TWEEN Group will be removed in a following major
* release. To migrate, create a `new Group()` instead of using `TWEEN` as a
* group.
*
* Old code:
*
* ```js
* import * as TWEEN from '@tweenjs/tween.js'
*
* //...
*
* const tween = new TWEEN.Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* TWEEN.update(time)
* requestAnimationFrame(loop)
* })
* ```
*
* New code:
*
* ```js
* import {Tween, Group} from '@tweenjs/tween.js'
*
* //...
*
* const tween = new Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* const group = new Group()
* group.add(tween)
* group.add(tween2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* group.update(time)
* requestAnimationFrame(loop)
* })
* ```
*/
remove: (...tweens: Tween<any>[]) => void;
/**
* @deprecated The global TWEEN Group will be removed in a following major
* release. To migrate, create a `new Group()` instead of using `TWEEN` as a
* group.
*
* Old code:
*
* ```js
* import * as TWEEN from '@tweenjs/tween.js'
*
* //...
*
* const tween = new TWEEN.Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* TWEEN.update(time)
* requestAnimationFrame(loop)
* })
* ```
*
* New code:
*
* ```js
* import {Tween, Group} from '@tweenjs/tween.js'
*
* //...
*
* const tween = new Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* const group = new Group()
* group.add(tween)
* group.add(tween2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* group.update(time)
* requestAnimationFrame(loop)
* })
* ```
*/
update: {
(time?: number | undefined): void;
(time?: number | undefined, preserve?: boolean | undefined): void;
};
};
export { Easing, Group, Interpolation, Sequence, Tween, VERSION, add, exports as default, getAll, nextId, now, remove, removeAll, update };

@@ -226,10 +226,13 @@ /**

function Group() {
var tweens = [];
for (var _i = 0; _i < arguments.length; _i++) {
tweens[_i] = arguments[_i];
}
this._tweens = {};
this._tweensAddedDuringUpdate = {};
this.add.apply(this, tweens);
}
Group.prototype.getAll = function () {
var _this = this;
return Object.keys(this._tweens).map(function (tweenId) {
return _this._tweens[tweenId];
});
return Object.keys(this._tweens).map(function (tweenId) { return _this._tweens[tweenId]; });
};

@@ -239,17 +242,42 @@ Group.prototype.removeAll = function () {

};
Group.prototype.add = function (tween) {
this._tweens[tween.getId()] = tween;
this._tweensAddedDuringUpdate[tween.getId()] = tween;
Group.prototype.add = function () {
var _a;
var tweens = [];
for (var _i = 0; _i < arguments.length; _i++) {
tweens[_i] = arguments[_i];
}
for (var _b = 0, tweens_1 = tweens; _b < tweens_1.length; _b++) {
var tween = tweens_1[_b];
// Remove from any other group first, a tween can only be in one group at a time.
// @ts-expect-error library internal access
(_a = tween._group) === null || _a === void 0 ? void 0 : _a.remove(tween);
// @ts-expect-error library internal access
tween._group = this;
this._tweens[tween.getId()] = tween;
this._tweensAddedDuringUpdate[tween.getId()] = tween;
}
};
Group.prototype.remove = function (tween) {
delete this._tweens[tween.getId()];
delete this._tweensAddedDuringUpdate[tween.getId()];
Group.prototype.remove = function () {
var tweens = [];
for (var _i = 0; _i < arguments.length; _i++) {
tweens[_i] = arguments[_i];
}
for (var _a = 0, tweens_2 = tweens; _a < tweens_2.length; _a++) {
var tween = tweens_2[_a];
// @ts-expect-error library internal access
tween._group = undefined;
delete this._tweens[tween.getId()];
delete this._tweensAddedDuringUpdate[tween.getId()];
}
};
/** Return true if all tweens in the group are not paused or playing. */
Group.prototype.allStopped = function () {
return this.getAll().every(function (tween) { return !tween.isPlaying(); });
};
Group.prototype.update = function (time, preserve) {
if (time === void 0) { time = now(); }
if (preserve === void 0) { preserve = false; }
if (preserve === void 0) { preserve = true; }
var tweenIds = Object.keys(this._tweens);
if (tweenIds.length === 0) {
return false;
}
if (tweenIds.length === 0)
return;
// Tweens are updated in "batches". If you add a new tween during an

@@ -265,9 +293,7 @@ // update, then the new tween will be updated in the next batch.

var autoStart = !preserve;
if (tween && tween.update(time, autoStart) === false && !preserve) {
delete this._tweens[tweenIds[i]];
}
if (tween && tween.update(time, autoStart) === false && !preserve)
this.remove(tween);
}
tweenIds = Object.keys(this._tweensAddedDuringUpdate);
}
return true;
};

@@ -381,6 +407,3 @@ return Group;

var Tween = /** @class */ (function () {
function Tween(_object, _group) {
if (_group === void 0) { _group = mainGroup; }
this._object = _object;
this._group = _group;
function Tween(object, group) {
this._isPaused = false;

@@ -410,2 +433,12 @@ this._pauseStart = 0;

this._goToEnd = false;
this._object = object;
if (typeof group === 'object') {
this._group = group;
group.add(this);
}
// Use "true" to restore old behavior (will be removed in future release).
else if (group === true) {
this._group = mainGroup;
mainGroup.add(this);
}
}

@@ -449,4 +482,2 @@ Tween.prototype.getId = function () {

}
// eslint-disable-next-line
this._group && this._group.add(this);
this._repeat = this._initialRepeat;

@@ -568,4 +599,2 @@ if (this._reversed) {

}
// eslint-disable-next-line
this._group && this._group.remove(this);
this._isPlaying = false;

@@ -590,4 +619,2 @@ this._isPaused = false;

this._pauseStart = time;
// eslint-disable-next-line
this._group && this._group.remove(this);
return this;

@@ -603,4 +630,2 @@ };

this._pauseStart = 0;
// eslint-disable-next-line
this._group && this._group.add(this);
return this;

@@ -615,6 +640,17 @@ };

Tween.prototype.group = function (group) {
if (group === void 0) { group = mainGroup; }
this._group = group;
if (!group) {
console.warn('tween.group() without args has been removed, use group.add(tween) instead.');
return this;
}
group.add(this);
return this;
};
/**
* Removes the tween from whichever group it is in.
*/
Tween.prototype.remove = function () {
var _a;
(_a = this._group) === null || _a === void 0 ? void 0 : _a.remove(this);
return this;
};
Tween.prototype.delay = function (amount) {

@@ -696,8 +732,7 @@ if (amount === void 0) { amount = 0; }

var property;
var endTime = this._startTime + this._duration;
if (!this._goToEnd && !this._isPlaying) {
if (time > endTime)
return false;
if (autoStart)
this.start(time, true);
else
return false;
}

@@ -844,3 +879,3 @@ this._goToEnd = false;

var VERSION = '23.1.3';
var VERSION = '24.0.0';

@@ -867,6 +902,241 @@ /**

// https://github.com/rollup/rollup/issues/1961#issuecomment-423037881
/**
* @deprecated The global TWEEN Group will be removed in a following major
* release. To migrate, create a `new Group()` instead of using `TWEEN` as a
* group.
*
* Old code:
*
* ```js
* import * as TWEEN from '@tweenjs/tween.js'
*
* //...
*
* const tween = new TWEEN.Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* TWEEN.update(time)
* requestAnimationFrame(loop)
* })
* ```
*
* New code:
*
* ```js
* import {Tween, Group} from '@tweenjs/tween.js'
*
* //...
*
* const tween = new Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* const group = new Group()
* group.add(tween)
* group.add(tween2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* group.update(time)
* requestAnimationFrame(loop)
* })
* ```
*/
var getAll = TWEEN.getAll.bind(TWEEN);
/**
* @deprecated The global TWEEN Group will be removed in a following major
* release. To migrate, create a `new Group()` instead of using `TWEEN` as a
* group.
*
* Old code:
*
* ```js
* import * as TWEEN from '@tweenjs/tween.js'
*
* //...
*
* const tween = new TWEEN.Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* TWEEN.update(time)
* requestAnimationFrame(loop)
* })
* ```
*
* New code:
*
* ```js
* import {Tween, Group} from '@tweenjs/tween.js'
*
* //...
*
* const tween = new Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* const group = new Group()
* group.add(tween)
* group.add(tween2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* group.update(time)
* requestAnimationFrame(loop)
* })
* ```
*/
var removeAll = TWEEN.removeAll.bind(TWEEN);
/**
* @deprecated The global TWEEN Group will be removed in a following major
* release. To migrate, create a `new Group()` instead of using `TWEEN` as a
* group.
*
* Old code:
*
* ```js
* import * as TWEEN from '@tweenjs/tween.js'
*
* //...
*
* const tween = new TWEEN.Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* TWEEN.update(time)
* requestAnimationFrame(loop)
* })
* ```
*
* New code:
*
* ```js
* import {Tween, Group} from '@tweenjs/tween.js'
*
* //...
*
* const tween = new Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* const group = new Group()
* group.add(tween)
* group.add(tween2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* group.update(time)
* requestAnimationFrame(loop)
* })
* ```
*/
var add = TWEEN.add.bind(TWEEN);
/**
* @deprecated The global TWEEN Group will be removed in a following major
* release. To migrate, create a `new Group()` instead of using `TWEEN` as a
* group.
*
* Old code:
*
* ```js
* import * as TWEEN from '@tweenjs/tween.js'
*
* //...
*
* const tween = new TWEEN.Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* TWEEN.update(time)
* requestAnimationFrame(loop)
* })
* ```
*
* New code:
*
* ```js
* import {Tween, Group} from '@tweenjs/tween.js'
*
* //...
*
* const tween = new Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* const group = new Group()
* group.add(tween)
* group.add(tween2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* group.update(time)
* requestAnimationFrame(loop)
* })
* ```
*/
var remove = TWEEN.remove.bind(TWEEN);
/**
* @deprecated The global TWEEN Group will be removed in a following major
* release. To migrate, create a `new Group()` instead of using `TWEEN` as a
* group.
*
* Old code:
*
* ```js
* import * as TWEEN from '@tweenjs/tween.js'
*
* //...
*
* const tween = new TWEEN.Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* TWEEN.update(time)
* requestAnimationFrame(loop)
* })
* ```
*
* New code:
*
* ```js
* import {Tween, Group} from '@tweenjs/tween.js'
*
* //...
*
* const tween = new Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* const group = new Group()
* group.add(tween)
* group.add(tween2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* group.update(time)
* requestAnimationFrame(loop)
* })
* ```
*/
var update = TWEEN.update.bind(TWEEN);

@@ -882,6 +1152,241 @@ var exports = {

VERSION: VERSION,
/**
* @deprecated The global TWEEN Group will be removed in a following major
* release. To migrate, create a `new Group()` instead of using `TWEEN` as a
* group.
*
* Old code:
*
* ```js
* import * as TWEEN from '@tweenjs/tween.js'
*
* //...
*
* const tween = new TWEEN.Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* TWEEN.update(time)
* requestAnimationFrame(loop)
* })
* ```
*
* New code:
*
* ```js
* import {Tween, Group} from '@tweenjs/tween.js'
*
* //...
*
* const tween = new Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* const group = new Group()
* group.add(tween)
* group.add(tween2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* group.update(time)
* requestAnimationFrame(loop)
* })
* ```
*/
getAll: getAll,
/**
* @deprecated The global TWEEN Group will be removed in a following major
* release. To migrate, create a `new Group()` instead of using `TWEEN` as a
* group.
*
* Old code:
*
* ```js
* import * as TWEEN from '@tweenjs/tween.js'
*
* //...
*
* const tween = new TWEEN.Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* TWEEN.update(time)
* requestAnimationFrame(loop)
* })
* ```
*
* New code:
*
* ```js
* import {Tween, Group} from '@tweenjs/tween.js'
*
* //...
*
* const tween = new Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* const group = new Group()
* group.add(tween)
* group.add(tween2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* group.update(time)
* requestAnimationFrame(loop)
* })
* ```
*/
removeAll: removeAll,
/**
* @deprecated The global TWEEN Group will be removed in a following major
* release. To migrate, create a `new Group()` instead of using `TWEEN` as a
* group.
*
* Old code:
*
* ```js
* import * as TWEEN from '@tweenjs/tween.js'
*
* //...
*
* const tween = new TWEEN.Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* TWEEN.update(time)
* requestAnimationFrame(loop)
* })
* ```
*
* New code:
*
* ```js
* import {Tween, Group} from '@tweenjs/tween.js'
*
* //...
*
* const tween = new Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* const group = new Group()
* group.add(tween)
* group.add(tween2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* group.update(time)
* requestAnimationFrame(loop)
* })
* ```
*/
add: add,
/**
* @deprecated The global TWEEN Group will be removed in a following major
* release. To migrate, create a `new Group()` instead of using `TWEEN` as a
* group.
*
* Old code:
*
* ```js
* import * as TWEEN from '@tweenjs/tween.js'
*
* //...
*
* const tween = new TWEEN.Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* TWEEN.update(time)
* requestAnimationFrame(loop)
* })
* ```
*
* New code:
*
* ```js
* import {Tween, Group} from '@tweenjs/tween.js'
*
* //...
*
* const tween = new Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* const group = new Group()
* group.add(tween)
* group.add(tween2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* group.update(time)
* requestAnimationFrame(loop)
* })
* ```
*/
remove: remove,
/**
* @deprecated The global TWEEN Group will be removed in a following major
* release. To migrate, create a `new Group()` instead of using `TWEEN` as a
* group.
*
* Old code:
*
* ```js
* import * as TWEEN from '@tweenjs/tween.js'
*
* //...
*
* const tween = new TWEEN.Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* TWEEN.update(time)
* requestAnimationFrame(loop)
* })
* ```
*
* New code:
*
* ```js
* import {Tween, Group} from '@tweenjs/tween.js'
*
* //...
*
* const tween = new Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* const group = new Group()
* group.add(tween)
* group.add(tween2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* group.update(time)
* requestAnimationFrame(loop)
* })
* ```
*/
update: update,

@@ -888,0 +1393,0 @@ };

@@ -232,10 +232,13 @@ (function (global, factory) {

function Group() {
var tweens = [];
for (var _i = 0; _i < arguments.length; _i++) {
tweens[_i] = arguments[_i];
}
this._tweens = {};
this._tweensAddedDuringUpdate = {};
this.add.apply(this, tweens);
}
Group.prototype.getAll = function () {
var _this = this;
return Object.keys(this._tweens).map(function (tweenId) {
return _this._tweens[tweenId];
});
return Object.keys(this._tweens).map(function (tweenId) { return _this._tweens[tweenId]; });
};

@@ -245,17 +248,42 @@ Group.prototype.removeAll = function () {

};
Group.prototype.add = function (tween) {
this._tweens[tween.getId()] = tween;
this._tweensAddedDuringUpdate[tween.getId()] = tween;
Group.prototype.add = function () {
var _a;
var tweens = [];
for (var _i = 0; _i < arguments.length; _i++) {
tweens[_i] = arguments[_i];
}
for (var _b = 0, tweens_1 = tweens; _b < tweens_1.length; _b++) {
var tween = tweens_1[_b];
// Remove from any other group first, a tween can only be in one group at a time.
// @ts-expect-error library internal access
(_a = tween._group) === null || _a === void 0 ? void 0 : _a.remove(tween);
// @ts-expect-error library internal access
tween._group = this;
this._tweens[tween.getId()] = tween;
this._tweensAddedDuringUpdate[tween.getId()] = tween;
}
};
Group.prototype.remove = function (tween) {
delete this._tweens[tween.getId()];
delete this._tweensAddedDuringUpdate[tween.getId()];
Group.prototype.remove = function () {
var tweens = [];
for (var _i = 0; _i < arguments.length; _i++) {
tweens[_i] = arguments[_i];
}
for (var _a = 0, tweens_2 = tweens; _a < tweens_2.length; _a++) {
var tween = tweens_2[_a];
// @ts-expect-error library internal access
tween._group = undefined;
delete this._tweens[tween.getId()];
delete this._tweensAddedDuringUpdate[tween.getId()];
}
};
/** Return true if all tweens in the group are not paused or playing. */
Group.prototype.allStopped = function () {
return this.getAll().every(function (tween) { return !tween.isPlaying(); });
};
Group.prototype.update = function (time, preserve) {
if (time === void 0) { time = now(); }
if (preserve === void 0) { preserve = false; }
if (preserve === void 0) { preserve = true; }
var tweenIds = Object.keys(this._tweens);
if (tweenIds.length === 0) {
return false;
}
if (tweenIds.length === 0)
return;
// Tweens are updated in "batches". If you add a new tween during an

@@ -271,9 +299,7 @@ // update, then the new tween will be updated in the next batch.

var autoStart = !preserve;
if (tween && tween.update(time, autoStart) === false && !preserve) {
delete this._tweens[tweenIds[i]];
}
if (tween && tween.update(time, autoStart) === false && !preserve)
this.remove(tween);
}
tweenIds = Object.keys(this._tweensAddedDuringUpdate);
}
return true;
};

@@ -387,6 +413,3 @@ return Group;

var Tween = /** @class */ (function () {
function Tween(_object, _group) {
if (_group === void 0) { _group = mainGroup; }
this._object = _object;
this._group = _group;
function Tween(object, group) {
this._isPaused = false;

@@ -416,2 +439,12 @@ this._pauseStart = 0;

this._goToEnd = false;
this._object = object;
if (typeof group === 'object') {
this._group = group;
group.add(this);
}
// Use "true" to restore old behavior (will be removed in future release).
else if (group === true) {
this._group = mainGroup;
mainGroup.add(this);
}
}

@@ -455,4 +488,2 @@ Tween.prototype.getId = function () {

}
// eslint-disable-next-line
this._group && this._group.add(this);
this._repeat = this._initialRepeat;

@@ -574,4 +605,2 @@ if (this._reversed) {

}
// eslint-disable-next-line
this._group && this._group.remove(this);
this._isPlaying = false;

@@ -596,4 +625,2 @@ this._isPaused = false;

this._pauseStart = time;
// eslint-disable-next-line
this._group && this._group.remove(this);
return this;

@@ -609,4 +636,2 @@ };

this._pauseStart = 0;
// eslint-disable-next-line
this._group && this._group.add(this);
return this;

@@ -621,6 +646,17 @@ };

Tween.prototype.group = function (group) {
if (group === void 0) { group = mainGroup; }
this._group = group;
if (!group) {
console.warn('tween.group() without args has been removed, use group.add(tween) instead.');
return this;
}
group.add(this);
return this;
};
/**
* Removes the tween from whichever group it is in.
*/
Tween.prototype.remove = function () {
var _a;
(_a = this._group) === null || _a === void 0 ? void 0 : _a.remove(this);
return this;
};
Tween.prototype.delay = function (amount) {

@@ -702,8 +738,7 @@ if (amount === void 0) { amount = 0; }

var property;
var endTime = this._startTime + this._duration;
if (!this._goToEnd && !this._isPlaying) {
if (time > endTime)
return false;
if (autoStart)
this.start(time, true);
else
return false;
}

@@ -850,3 +885,3 @@ this._goToEnd = false;

var VERSION = '23.1.3';
var VERSION = '24.0.0';

@@ -873,6 +908,241 @@ /**

// https://github.com/rollup/rollup/issues/1961#issuecomment-423037881
/**
* @deprecated The global TWEEN Group will be removed in a following major
* release. To migrate, create a `new Group()` instead of using `TWEEN` as a
* group.
*
* Old code:
*
* ```js
* import * as TWEEN from '@tweenjs/tween.js'
*
* //...
*
* const tween = new TWEEN.Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* TWEEN.update(time)
* requestAnimationFrame(loop)
* })
* ```
*
* New code:
*
* ```js
* import {Tween, Group} from '@tweenjs/tween.js'
*
* //...
*
* const tween = new Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* const group = new Group()
* group.add(tween)
* group.add(tween2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* group.update(time)
* requestAnimationFrame(loop)
* })
* ```
*/
var getAll = TWEEN.getAll.bind(TWEEN);
/**
* @deprecated The global TWEEN Group will be removed in a following major
* release. To migrate, create a `new Group()` instead of using `TWEEN` as a
* group.
*
* Old code:
*
* ```js
* import * as TWEEN from '@tweenjs/tween.js'
*
* //...
*
* const tween = new TWEEN.Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* TWEEN.update(time)
* requestAnimationFrame(loop)
* })
* ```
*
* New code:
*
* ```js
* import {Tween, Group} from '@tweenjs/tween.js'
*
* //...
*
* const tween = new Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* const group = new Group()
* group.add(tween)
* group.add(tween2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* group.update(time)
* requestAnimationFrame(loop)
* })
* ```
*/
var removeAll = TWEEN.removeAll.bind(TWEEN);
/**
* @deprecated The global TWEEN Group will be removed in a following major
* release. To migrate, create a `new Group()` instead of using `TWEEN` as a
* group.
*
* Old code:
*
* ```js
* import * as TWEEN from '@tweenjs/tween.js'
*
* //...
*
* const tween = new TWEEN.Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* TWEEN.update(time)
* requestAnimationFrame(loop)
* })
* ```
*
* New code:
*
* ```js
* import {Tween, Group} from '@tweenjs/tween.js'
*
* //...
*
* const tween = new Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* const group = new Group()
* group.add(tween)
* group.add(tween2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* group.update(time)
* requestAnimationFrame(loop)
* })
* ```
*/
var add = TWEEN.add.bind(TWEEN);
/**
* @deprecated The global TWEEN Group will be removed in a following major
* release. To migrate, create a `new Group()` instead of using `TWEEN` as a
* group.
*
* Old code:
*
* ```js
* import * as TWEEN from '@tweenjs/tween.js'
*
* //...
*
* const tween = new TWEEN.Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* TWEEN.update(time)
* requestAnimationFrame(loop)
* })
* ```
*
* New code:
*
* ```js
* import {Tween, Group} from '@tweenjs/tween.js'
*
* //...
*
* const tween = new Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* const group = new Group()
* group.add(tween)
* group.add(tween2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* group.update(time)
* requestAnimationFrame(loop)
* })
* ```
*/
var remove = TWEEN.remove.bind(TWEEN);
/**
* @deprecated The global TWEEN Group will be removed in a following major
* release. To migrate, create a `new Group()` instead of using `TWEEN` as a
* group.
*
* Old code:
*
* ```js
* import * as TWEEN from '@tweenjs/tween.js'
*
* //...
*
* const tween = new TWEEN.Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* TWEEN.update(time)
* requestAnimationFrame(loop)
* })
* ```
*
* New code:
*
* ```js
* import {Tween, Group} from '@tweenjs/tween.js'
*
* //...
*
* const tween = new Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* const group = new Group()
* group.add(tween)
* group.add(tween2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* group.update(time)
* requestAnimationFrame(loop)
* })
* ```
*/
var update = TWEEN.update.bind(TWEEN);

@@ -888,6 +1158,241 @@ var exports$1 = {

VERSION: VERSION,
/**
* @deprecated The global TWEEN Group will be removed in a following major
* release. To migrate, create a `new Group()` instead of using `TWEEN` as a
* group.
*
* Old code:
*
* ```js
* import * as TWEEN from '@tweenjs/tween.js'
*
* //...
*
* const tween = new TWEEN.Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* TWEEN.update(time)
* requestAnimationFrame(loop)
* })
* ```
*
* New code:
*
* ```js
* import {Tween, Group} from '@tweenjs/tween.js'
*
* //...
*
* const tween = new Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* const group = new Group()
* group.add(tween)
* group.add(tween2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* group.update(time)
* requestAnimationFrame(loop)
* })
* ```
*/
getAll: getAll,
/**
* @deprecated The global TWEEN Group will be removed in a following major
* release. To migrate, create a `new Group()` instead of using `TWEEN` as a
* group.
*
* Old code:
*
* ```js
* import * as TWEEN from '@tweenjs/tween.js'
*
* //...
*
* const tween = new TWEEN.Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* TWEEN.update(time)
* requestAnimationFrame(loop)
* })
* ```
*
* New code:
*
* ```js
* import {Tween, Group} from '@tweenjs/tween.js'
*
* //...
*
* const tween = new Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* const group = new Group()
* group.add(tween)
* group.add(tween2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* group.update(time)
* requestAnimationFrame(loop)
* })
* ```
*/
removeAll: removeAll,
/**
* @deprecated The global TWEEN Group will be removed in a following major
* release. To migrate, create a `new Group()` instead of using `TWEEN` as a
* group.
*
* Old code:
*
* ```js
* import * as TWEEN from '@tweenjs/tween.js'
*
* //...
*
* const tween = new TWEEN.Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* TWEEN.update(time)
* requestAnimationFrame(loop)
* })
* ```
*
* New code:
*
* ```js
* import {Tween, Group} from '@tweenjs/tween.js'
*
* //...
*
* const tween = new Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* const group = new Group()
* group.add(tween)
* group.add(tween2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* group.update(time)
* requestAnimationFrame(loop)
* })
* ```
*/
add: add,
/**
* @deprecated The global TWEEN Group will be removed in a following major
* release. To migrate, create a `new Group()` instead of using `TWEEN` as a
* group.
*
* Old code:
*
* ```js
* import * as TWEEN from '@tweenjs/tween.js'
*
* //...
*
* const tween = new TWEEN.Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* TWEEN.update(time)
* requestAnimationFrame(loop)
* })
* ```
*
* New code:
*
* ```js
* import {Tween, Group} from '@tweenjs/tween.js'
*
* //...
*
* const tween = new Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* const group = new Group()
* group.add(tween)
* group.add(tween2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* group.update(time)
* requestAnimationFrame(loop)
* })
* ```
*/
remove: remove,
/**
* @deprecated The global TWEEN Group will be removed in a following major
* release. To migrate, create a `new Group()` instead of using `TWEEN` as a
* group.
*
* Old code:
*
* ```js
* import * as TWEEN from '@tweenjs/tween.js'
*
* //...
*
* const tween = new TWEEN.Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* TWEEN.update(time)
* requestAnimationFrame(loop)
* })
* ```
*
* New code:
*
* ```js
* import {Tween, Group} from '@tweenjs/tween.js'
*
* //...
*
* const tween = new Tween(obj)
* const tween2 = new TWEEN.Tween(obj2)
*
* //...
*
* const group = new Group()
* group.add(tween)
* group.add(tween2)
*
* //...
*
* requestAnimationFrame(function loop(time) {
* group.update(time)
* requestAnimationFrame(loop)
* })
* ```
*/
update: update,

@@ -894,0 +1399,0 @@ };

2

package.json
{
"name": "@tweenjs/tween.js",
"description": "Simple and fast tweening engine with optimised Robert Penner's equations.",
"version": "23.1.3",
"version": "24.0.0",
"type": "module",

@@ -6,0 +6,0 @@ "main": "dist/tween.cjs",

@@ -15,4 +15,2 @@ # tween.js

```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/tween.js/20.0.0/tween.umd.js"></script>
<div id="box"></div>

@@ -28,3 +26,5 @@

<script>
<script type="module">
import {Tween, Easing} from 'https://unpkg.com/@tweenjs/tween.js@23.1.3/dist/tween.esm.js'
const box = document.getElementById('box') // Get the element we want to animate.

@@ -34,5 +34,5 @@

const tween = new TWEEN.Tween(coords, false) // Create a new tween that modifies 'coords'.
const tween = new Tween(coords, false) // Create a new tween that modifies 'coords'.
.to({x: 300, y: 200}, 1000) // Move to (300, 200) in 1 second.
.easing(TWEEN.Easing.Quadratic.InOut) // Use an easing function to make the animation smooth.
.easing(Easing.Quadratic.InOut) // Use an easing function to make the animation smooth.
.onUpdate(() => {

@@ -56,94 +56,5 @@ // Called after tween.js updates 'coords'.

# Installation
## From CDN
Install from a content-delivery network (CDN) like in the above example.
From cdnjs:
```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/tween.js/20.0.0/tween.umd.js"></script>
```
Or from unpkg.com:
```html
<script src="https://unpkg.com/@tweenjs/tween.js@^20.0.0/dist/tween.umd.js"></script>
```
Note that unpkg.com supports a semver version in the URL, where the `^` in the URL tells unpkg to give you the latest version 20.x.x.
## Build and include in your project with script tag
Currently npm is required to build the project.
```bash
git clone https://github.com/tweenjs/tween.js
cd tween.js
npm install
npm run build
```
This will create some builds in the `dist` directory. There are currently two different builds of the library:
- UMD : `tween.umd.js`
- ES6 Module : `tween.es.js`
You are now able to copy tween.umd.js into your project, then include it with
a script tag, which will add TWEEN to the global scope,
```html
<script src="path/to/tween.umd.js"></script>
```
or import TWEEN as a JavaScript module,
```html
<script type="module">
import * as TWEEN from 'path/to/tween.es.js'
</script>
```
where `path/to` is replaced with the location where you placed the file.
## With `npm install` and `import` from `node_modules`
You can add tween.js as an npm dependency:
```bash
npm install @tweenjs/tween.js
```
### With a build tool
If you are using [Node.js](https://nodejs.org/), [Parcel](https://parceljs.org/), [Webpack](https://webpack.js.org/), [Rollup](https://rollupjs.org/), [Vite](https://vitejs.dev/), or another build tool, then you can now use the following to include tween.js:
```javascript
import * as TWEEN from '@tweenjs/tween.js'
```
### Without a build tool
You can import from `node_modules` if you serve node_modules as part of your website, using an `importmap` script tag. First, assuming `node_modules` is at the root of your website, you can write an import map:
```html
<script type="importmap">
{
"imports": {
"@tweenjs/tween.js": "/node_modules/@tweenjs/tween.js/dist/tween.es.js"
}
}
</script>
```
Now in any of your module scripts you can import it by its package name:
```javascript
import * as TWEEN from '@tweenjs/tween.js'
```
# Features
- Does one thing and one thing only: tween properties
- Does one thing only and does it well: tweens properties of an object
- Doesn't take care of CSS units (e.g. appending `px`)

@@ -153,10 +64,5 @@ - Doesn't interpolate colors

- Can also use custom easing functions
- Doesn't make its own animation loop, making it flexible for integration into
any animation loop.
# Documentation
- [User guide](./docs/user_guide.md)
- [Contributor guide](./docs/contributor_guide.md)
- [Tutorial](https://web.archive.org/web/20220601192930/http://learningthreejs.com/blog/2011/08/17/tweenjs-for-smooth-animation/) using tween.js with three.js
- Also: [libtween](https://github.com/jsm174/libtween), a port of tween.js to C by [jsm174](https://github.com/jsm174)
# Examples

@@ -358,2 +264,180 @@

# Installation
The recommended method is to use `import` syntax. Here we've listed various
install methods starting roughly with the most recommended first and least
desirable last. Evaluate all of the following methods to pick what is most
suitable for your project.
## With `npm install` and `import` from `node_modules`
You can add tween.js as an npm dependency:
```bash
npm install @tweenjs/tween.js
```
### Without a build tool
#### Installed locally
You can import from `node_modules` if you serve `node_modules` as part of your
website, using a standard `importmap` script tag. First, assuming `node_modules`
is at the root of your website, you can write an import map like so in your HTML
file:
```html
<script type="importmap">
{
"imports": {
"@tweenjs/tween.js": "/node_modules/@tweenjs/tween.js/dist/tween.esm.js"
}
}
</script>
```
Now in any of your module scripts you can import Tween.js by its package name:
```html
<script type="module">
import {Tween} from '@tweenjs/tween.js'
</script>
```
#### Import from CDN
Note that, without the `importmap`, you can import directly from a CDN as with the first example above, like so:
```html
<script type="module">
import {Tween} from 'https://unpkg.com/browse/@tweenjs/tween.js@23.1.3/dist/tween.esm.js'
</script>
```
You can also link your `importmap` to the CDN instead of a local `node_modules` folder, if you prefer that:
```html
<script type="importmap">
{
"imports": {
"@tweenjs/tween.js": "https://unpkg.com/browse/@tweenjs/tween.js@23.1.3/dist/tween.esm.js"
}
}
</script>
<script type="module">
import {Tween} from '@tweenjs/tween.js'
</script>
```
### With a build tool
If you are using [Node.js](https://nodejs.org/),
[Parcel](https://parceljs.org/), [Webpack](https://webpack.js.org/),
[Rollup](https://rollupjs.org/), [Vite](https://vitejs.dev/), or another build
tool, then you can install `@tweenjs/tween.js` with `npm install
@tweenjs/tween.js`, and `import` the library into your JavaScript (or
TypeScript) file, and the build tool will know how to find the source code from
`node_modules` without needing to create an `importmap` script:
```javascript
import * as TWEEN from '@tweenjs/tween.js'
```
However, note that this approach requires always running a build tool for your
app to work, while the `importmap` approach will simply work without any build
tools as a simple static HTML site.
## Manual build
Another approach is to download the source code with git, manually build the
library, then place the output in your project. Node.js is required for this.
```bash
git clone https://github.com/tweenjs/tween.js
cd tween.js
npm install
npm run build
```
This will create some builds in the `dist` directory. There are currently two different builds of the library:
- ES6 Module in `/dist/tween.esm.js` (recommended)
- UMD in `/dist/tween.umd.js` (deprecated, will be removed in a future major version)
You are now able to copy one of those two files into your project, and use like this (recommended):
```html
<script type="module">
import {Tween} from 'path/to/tween.esm.js'
</script>
```
or (deprecated, to be removed in future major):
```html
<script src="path/to/tween.umd.js"></script>
<script>
const {Tween} = TWEEN
</script>
```
where `path/to` is replaced with the location where you placed the file.
> [!Note]
> You can also download these files from unpkg, for example here:
> https://unpkg.com/browse/@tweenjs/tween.js@23.1.3/dist/
## Global variable from CDN (deprecated)
> [!Note]
> This method is deprecated and will be removed in a future major version!
Install a global `TWEEN` variable from a content-delivery network (CDN) using the UMD file.
From cdnjs:
```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/tween.js/23.1.3/tween.umd.js"></script>
```
Or from unpkg.com:
```html
<script src="https://unpkg.com/@tweenjs/tween.js@^23.1.3/dist/tween.umd.js"></script>
```
Then use the `TWEEN` variable in any script:
```html
<script>
const {Tween, Easing, Group /*, ...*/} = TWEEN
const tween = new Tween(someObject)
// ...
</script>
```
> [!Note]
> unpkg.com supports a semver version in the URL, where the `^` in the
> URL tells unpkg to give you the latest version 20.x.x.
## CommonJS (deprecated)
Skip this section if you don't know what CommonJS is!
> [!Note]
> This method is deprecated and will be removed in a future major version!
Any of the above methods work in older systems that still use CommonJS. Repeat
any of the above methods but using `dist/tween.cjs` instead of
`dist/tween.esm.js` or `dist/tween.umd.js`.
# Documentation
- [User guide](./docs/user_guide.md)
- [Contributor guide](./docs/contributor_guide.md)
- [Tutorial](https://web.archive.org/web/20220601192930/http://learningthreejs.com/blog/2011/08/17/tweenjs-for-smooth-animation/) using tween.js with three.js
- Also: [libtween](https://github.com/jsm174/libtween), a port of tween.js to C by [jsm174](https://github.com/jsm174)
# Tests

@@ -373,3 +457,7 @@

If you want to add any feature or change existing features, you _must_ run the tests to make sure you didn't break anything else. Any pull request (PR) needs to have updated passing tests for feature changes (or new passing tests for new features or fixes) in `src/tests.ts` a PR to be accepted. See [contributing](CONTRIBUTING.md) for more information.
If you want to add any feature or change existing features, you _must_ run the
tests to make sure you didn't break anything else. Any pull request (PR) needs
to have updated passing tests for feature changes (or new passing tests for new
features or fixes) in `src/tests.ts` to be accepted. See
[contributing](CONTRIBUTING.md) for more information.

@@ -376,0 +464,0 @@ # People

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc