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 18.6.0 to 18.6.1

dist/tween.d.ts

268

dist/tween.amd.js

@@ -1,90 +0,4 @@

define(function () { 'use strict';
define(['exports'], function (exports) { 'use strict';
var NOW;
// Include a performance.now polyfill.
// In node.js, use process.hrtime.
// eslint-disable-next-line
// @ts-ignore
if (typeof self === 'undefined' && typeof process !== 'undefined' && process.hrtime) {
NOW = function () {
// eslint-disable-next-line
// @ts-ignore
var time = process.hrtime();
// Convert [seconds, nanoseconds] to milliseconds.
return time[0] * 1000 + time[1] / 1000000;
};
}
// In a browser, use self.performance.now if it is available.
else if (typeof self !== 'undefined' && self.performance !== undefined && self.performance.now !== undefined) {
// This must be bound, because directly assigning this function
// leads to an invocation exception in Chrome.
NOW = self.performance.now.bind(self.performance);
}
// Use Date.now if it is available.
else if (Date.now !== undefined) {
NOW = Date.now;
}
// Otherwise, use 'new Date().getTime()'.
else {
NOW = function () {
return new Date().getTime();
};
}
var NOW$1 = NOW;
/**
* 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
*/
var Group = /** @class */ (function () {
function Group() {
this._tweens = {};
this._tweensAddedDuringUpdate = {};
}
Group.prototype.getAll = function () {
var _this = this;
return Object.keys(this._tweens).map(function (tweenId) {
return _this._tweens[tweenId];
});
};
Group.prototype.removeAll = function () {
this._tweens = {};
};
Group.prototype.add = function (tween) {
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.update = function (time, preserve) {
var tweenIds = Object.keys(this._tweens);
if (tweenIds.length === 0) {
return false;
}
time = time !== undefined ? time : NOW$1();
// Tweens are updated in "batches". If you add a new tween during an
// update, then the new tween will be updated in the next batch.
// If you remove a tween during an update, it may or may not be updated.
// However, if the removed tween was added during the current batch,
// then it will not be updated.
while (tweenIds.length > 0) {
this._tweensAddedDuringUpdate = {};
for (var i = 0; i < tweenIds.length; i++) {
var tween = this._tweens[tweenIds[i]];
if (tween && tween.update(time) === false && !preserve) {
delete this._tweens[tweenIds[i]];
}
}
tweenIds = Object.keys(this._tweensAddedDuringUpdate);
}
return true;
};
return Group;
}());
/**
* The Ease class provides a collection of easing functions for use with tween.js.

@@ -276,5 +190,91 @@ */

var now;
// Include a performance.now polyfill.
// In node.js, use process.hrtime.
// eslint-disable-next-line
// @ts-ignore
if (typeof self === 'undefined' && typeof process !== 'undefined' && process.hrtime) {
now = function () {
// eslint-disable-next-line
// @ts-ignore
var time = process.hrtime();
// Convert [seconds, nanoseconds] to milliseconds.
return time[0] * 1000 + time[1] / 1000000;
};
}
// In a browser, use self.performance.now if it is available.
else if (typeof self !== 'undefined' && self.performance !== undefined && self.performance.now !== undefined) {
// This must be bound, because directly assigning this function
// leads to an invocation exception in Chrome.
now = self.performance.now.bind(self.performance);
}
// Use Date.now if it is available.
else if (Date.now !== undefined) {
now = Date.now;
}
// Otherwise, use 'new Date().getTime()'.
else {
now = function () {
return new Date().getTime();
};
}
var now$1 = now;
/**
* 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
*/
var Group = /** @class */ (function () {
function Group() {
this._tweens = {};
this._tweensAddedDuringUpdate = {};
}
Group.prototype.getAll = function () {
var _this = this;
return Object.keys(this._tweens).map(function (tweenId) {
return _this._tweens[tweenId];
});
};
Group.prototype.removeAll = function () {
this._tweens = {};
};
Group.prototype.add = function (tween) {
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.update = function (time, preserve) {
var tweenIds = Object.keys(this._tweens);
if (tweenIds.length === 0) {
return false;
}
time = time !== undefined ? time : now$1();
// Tweens are updated in "batches". If you add a new tween during an
// update, then the new tween will be updated in the next batch.
// If you remove a tween during an update, it may or may not be updated.
// However, if the removed tween was added during the current batch,
// then it will not be updated.
while (tweenIds.length > 0) {
this._tweensAddedDuringUpdate = {};
for (var i = 0; i < tweenIds.length; i++) {
var tween = this._tweens[tweenIds[i]];
if (tween && tween.update(time) === false && !preserve) {
delete this._tweens[tweenIds[i]];
}
}
tweenIds = Object.keys(this._tweensAddedDuringUpdate);
}
return true;
};
return Group;
}());
/**
*
*/
var Interpolation = {

@@ -370,2 +370,4 @@ Linear: function (v, k) {

var mainGroup = new Group();
/**

@@ -381,3 +383,3 @@ * Tween.js - Licensed under the MIT license

function Tween(_object, _group) {
if (_group === void 0) { _group = TWEEN; }
if (_group === void 0) { _group = mainGroup; }
this._object = _object;

@@ -398,7 +400,7 @@ this._group = _group;

this._startTime = 0;
this._easingFunction = TWEEN.Easing.Linear.None;
this._interpolationFunction = TWEEN.Interpolation.Linear;
this._easingFunction = Easing.Linear.None;
this._interpolationFunction = Interpolation.Linear;
this._chainedTweens = [];
this._onStartCallbackFired = false;
this._id = TWEEN.nextId();
this._id = Sequence.nextId();
this._isChainStopped = false;

@@ -449,4 +451,3 @@ }

this._isChainStopped = false;
this._startTime =
time !== undefined ? (typeof time === 'string' ? TWEEN.now() + parseFloat(time) : time) : TWEEN.now();
this._startTime = time !== undefined ? (typeof time === 'string' ? now$1() + parseFloat(time) : time) : now$1();
this._startTime += this._delayTime;

@@ -540,3 +541,3 @@ this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat);

this._isPaused = true;
this._pauseStart = time === undefined ? TWEEN.now() : time;
this._pauseStart = time === undefined ? now$1() : time;
// eslint-disable-next-line

@@ -552,3 +553,3 @@ // @ts-ignore FIXME?

this._isPaused = false;
this._startTime += (time === undefined ? TWEEN.now() : time) - this._pauseStart;
this._startTime += (time === undefined ? now$1() : time) - this._pauseStart;
this._pauseStart = 0;

@@ -626,2 +627,3 @@ // eslint-disable-next-line

var elapsed;
time = time !== undefined ? time : now$1();
var endTime = this._startTime + this._duration;

@@ -756,3 +758,3 @@ if (time > endTime && !this._isPlaying) {

var VERSION = '18.6.0';
var VERSION = '18.6.1';

@@ -767,15 +769,3 @@ /**

*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var nextId = Sequence.nextId;
/**

@@ -785,23 +775,47 @@ * 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
* In these cases, you may want to create your own smaller groups of tweens.
*/
var Main = /** @class */ (function (_super) {
__extends(Main, _super);
function Main() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.version = VERSION;
_this.now = NOW$1;
_this.Group = Group;
_this.Easing = Easing;
_this.Interpolation = Interpolation;
_this.nextId = Sequence.nextId;
_this.Tween = Tween;
return _this;
}
return Main;
}(Group));
var TWEEN = new Main();
var TWEEN = mainGroup;
// This is the best way to export things in a way that's compatible with both ES
// Modules and CommonJS, without build hacks, and so as not to break the
// existing API.
// https://github.com/rollup/rollup/issues/1961#issuecomment-423037881
var getAll = TWEEN.getAll.bind(TWEEN);
var removeAll = TWEEN.removeAll.bind(TWEEN);
var add = TWEEN.add.bind(TWEEN);
var remove = TWEEN.remove.bind(TWEEN);
var update = TWEEN.update.bind(TWEEN);
var exports$1 = {
Easing: Easing,
Group: Group,
Interpolation: Interpolation,
now: now$1,
Sequence: Sequence,
nextId: nextId,
Tween: Tween,
VERSION: VERSION,
getAll: getAll,
removeAll: removeAll,
add: add,
remove: remove,
update: update,
};
return TWEEN;
exports.Easing = Easing;
exports.Group = Group;
exports.Interpolation = Interpolation;
exports.Sequence = Sequence;
exports.Tween = Tween;
exports.VERSION = VERSION;
exports.add = add;
exports.default = exports$1;
exports.getAll = getAll;
exports.nextId = nextId;
exports.now = now$1;
exports.remove = remove;
exports.removeAll = removeAll;
exports.update = update;
Object.defineProperty(exports, '__esModule', { value: true });
});
'use strict';
var NOW;
// Include a performance.now polyfill.
// In node.js, use process.hrtime.
// eslint-disable-next-line
// @ts-ignore
if (typeof self === 'undefined' && typeof process !== 'undefined' && process.hrtime) {
NOW = function () {
// eslint-disable-next-line
// @ts-ignore
var time = process.hrtime();
// Convert [seconds, nanoseconds] to milliseconds.
return time[0] * 1000 + time[1] / 1000000;
};
}
// In a browser, use self.performance.now if it is available.
else if (typeof self !== 'undefined' && self.performance !== undefined && self.performance.now !== undefined) {
// This must be bound, because directly assigning this function
// leads to an invocation exception in Chrome.
NOW = self.performance.now.bind(self.performance);
}
// Use Date.now if it is available.
else if (Date.now !== undefined) {
NOW = Date.now;
}
// Otherwise, use 'new Date().getTime()'.
else {
NOW = function () {
return new Date().getTime();
};
}
var NOW$1 = NOW;
Object.defineProperty(exports, '__esModule', { value: true });
/**
* 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
*/
var Group = /** @class */ (function () {
function Group() {
this._tweens = {};
this._tweensAddedDuringUpdate = {};
}
Group.prototype.getAll = function () {
var _this = this;
return Object.keys(this._tweens).map(function (tweenId) {
return _this._tweens[tweenId];
});
};
Group.prototype.removeAll = function () {
this._tweens = {};
};
Group.prototype.add = function (tween) {
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.update = function (time, preserve) {
var tweenIds = Object.keys(this._tweens);
if (tweenIds.length === 0) {
return false;
}
time = time !== undefined ? time : NOW$1();
// Tweens are updated in "batches". If you add a new tween during an
// update, then the new tween will be updated in the next batch.
// If you remove a tween during an update, it may or may not be updated.
// However, if the removed tween was added during the current batch,
// then it will not be updated.
while (tweenIds.length > 0) {
this._tweensAddedDuringUpdate = {};
for (var i = 0; i < tweenIds.length; i++) {
var tween = this._tweens[tweenIds[i]];
if (tween && tween.update(time) === false && !preserve) {
delete this._tweens[tweenIds[i]];
}
}
tweenIds = Object.keys(this._tweensAddedDuringUpdate);
}
return true;
};
return Group;
}());
/**
* The Ease class provides a collection of easing functions for use with tween.js.

@@ -276,5 +192,91 @@ */

var now;
// Include a performance.now polyfill.
// In node.js, use process.hrtime.
// eslint-disable-next-line
// @ts-ignore
if (typeof self === 'undefined' && typeof process !== 'undefined' && process.hrtime) {
now = function () {
// eslint-disable-next-line
// @ts-ignore
var time = process.hrtime();
// Convert [seconds, nanoseconds] to milliseconds.
return time[0] * 1000 + time[1] / 1000000;
};
}
// In a browser, use self.performance.now if it is available.
else if (typeof self !== 'undefined' && self.performance !== undefined && self.performance.now !== undefined) {
// This must be bound, because directly assigning this function
// leads to an invocation exception in Chrome.
now = self.performance.now.bind(self.performance);
}
// Use Date.now if it is available.
else if (Date.now !== undefined) {
now = Date.now;
}
// Otherwise, use 'new Date().getTime()'.
else {
now = function () {
return new Date().getTime();
};
}
var now$1 = now;
/**
* 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
*/
var Group = /** @class */ (function () {
function Group() {
this._tweens = {};
this._tweensAddedDuringUpdate = {};
}
Group.prototype.getAll = function () {
var _this = this;
return Object.keys(this._tweens).map(function (tweenId) {
return _this._tweens[tweenId];
});
};
Group.prototype.removeAll = function () {
this._tweens = {};
};
Group.prototype.add = function (tween) {
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.update = function (time, preserve) {
var tweenIds = Object.keys(this._tweens);
if (tweenIds.length === 0) {
return false;
}
time = time !== undefined ? time : now$1();
// Tweens are updated in "batches". If you add a new tween during an
// update, then the new tween will be updated in the next batch.
// If you remove a tween during an update, it may or may not be updated.
// However, if the removed tween was added during the current batch,
// then it will not be updated.
while (tweenIds.length > 0) {
this._tweensAddedDuringUpdate = {};
for (var i = 0; i < tweenIds.length; i++) {
var tween = this._tweens[tweenIds[i]];
if (tween && tween.update(time) === false && !preserve) {
delete this._tweens[tweenIds[i]];
}
}
tweenIds = Object.keys(this._tweensAddedDuringUpdate);
}
return true;
};
return Group;
}());
/**
*
*/
var Interpolation = {

@@ -370,2 +372,4 @@ Linear: function (v, k) {

var mainGroup = new Group();
/**

@@ -381,3 +385,3 @@ * Tween.js - Licensed under the MIT license

function Tween(_object, _group) {
if (_group === void 0) { _group = TWEEN; }
if (_group === void 0) { _group = mainGroup; }
this._object = _object;

@@ -398,7 +402,7 @@ this._group = _group;

this._startTime = 0;
this._easingFunction = TWEEN.Easing.Linear.None;
this._interpolationFunction = TWEEN.Interpolation.Linear;
this._easingFunction = Easing.Linear.None;
this._interpolationFunction = Interpolation.Linear;
this._chainedTweens = [];
this._onStartCallbackFired = false;
this._id = TWEEN.nextId();
this._id = Sequence.nextId();
this._isChainStopped = false;

@@ -449,4 +453,3 @@ }

this._isChainStopped = false;
this._startTime =
time !== undefined ? (typeof time === 'string' ? TWEEN.now() + parseFloat(time) : time) : TWEEN.now();
this._startTime = time !== undefined ? (typeof time === 'string' ? now$1() + parseFloat(time) : time) : now$1();
this._startTime += this._delayTime;

@@ -540,3 +543,3 @@ this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat);

this._isPaused = true;
this._pauseStart = time === undefined ? TWEEN.now() : time;
this._pauseStart = time === undefined ? now$1() : time;
// eslint-disable-next-line

@@ -552,3 +555,3 @@ // @ts-ignore FIXME?

this._isPaused = false;
this._startTime += (time === undefined ? TWEEN.now() : time) - this._pauseStart;
this._startTime += (time === undefined ? now$1() : time) - this._pauseStart;
this._pauseStart = 0;

@@ -626,2 +629,3 @@ // eslint-disable-next-line

var elapsed;
time = time !== undefined ? time : now$1();
var endTime = this._startTime + this._duration;

@@ -756,3 +760,3 @@ if (time > endTime && !this._isPlaying) {

var VERSION = '18.6.0';
var VERSION = '18.6.1';

@@ -767,15 +771,3 @@ /**

*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var nextId = Sequence.nextId;
/**

@@ -785,21 +777,43 @@ * 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
* In these cases, you may want to create your own smaller groups of tweens.
*/
var Main = /** @class */ (function (_super) {
__extends(Main, _super);
function Main() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.version = VERSION;
_this.now = NOW$1;
_this.Group = Group;
_this.Easing = Easing;
_this.Interpolation = Interpolation;
_this.nextId = Sequence.nextId;
_this.Tween = Tween;
return _this;
}
return Main;
}(Group));
var TWEEN = new Main();
var TWEEN = mainGroup;
// This is the best way to export things in a way that's compatible with both ES
// Modules and CommonJS, without build hacks, and so as not to break the
// existing API.
// https://github.com/rollup/rollup/issues/1961#issuecomment-423037881
var getAll = TWEEN.getAll.bind(TWEEN);
var removeAll = TWEEN.removeAll.bind(TWEEN);
var add = TWEEN.add.bind(TWEEN);
var remove = TWEEN.remove.bind(TWEEN);
var update = TWEEN.update.bind(TWEEN);
var exports$1 = {
Easing: Easing,
Group: Group,
Interpolation: Interpolation,
now: now$1,
Sequence: Sequence,
nextId: nextId,
Tween: Tween,
VERSION: VERSION,
getAll: getAll,
removeAll: removeAll,
add: add,
remove: remove,
update: update,
};
module.exports = TWEEN;
exports.Easing = Easing;
exports.Group = Group;
exports.Interpolation = Interpolation;
exports.Sequence = Sequence;
exports.Tween = Tween;
exports.VERSION = VERSION;
exports.add = add;
exports.default = exports$1;
exports.getAll = getAll;
exports.nextId = nextId;
exports.now = now$1;
exports.remove = remove;
exports.removeAll = removeAll;
exports.update = update;

@@ -1,88 +0,2 @@

var NOW;
// Include a performance.now polyfill.
// In node.js, use process.hrtime.
// eslint-disable-next-line
// @ts-ignore
if (typeof self === 'undefined' && typeof process !== 'undefined' && process.hrtime) {
NOW = function () {
// eslint-disable-next-line
// @ts-ignore
var time = process.hrtime();
// Convert [seconds, nanoseconds] to milliseconds.
return time[0] * 1000 + time[1] / 1000000;
};
}
// In a browser, use self.performance.now if it is available.
else if (typeof self !== 'undefined' && self.performance !== undefined && self.performance.now !== undefined) {
// This must be bound, because directly assigning this function
// leads to an invocation exception in Chrome.
NOW = self.performance.now.bind(self.performance);
}
// Use Date.now if it is available.
else if (Date.now !== undefined) {
NOW = Date.now;
}
// Otherwise, use 'new Date().getTime()'.
else {
NOW = function () {
return new Date().getTime();
};
}
var NOW$1 = NOW;
/**
* 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
*/
var Group = /** @class */ (function () {
function Group() {
this._tweens = {};
this._tweensAddedDuringUpdate = {};
}
Group.prototype.getAll = function () {
var _this = this;
return Object.keys(this._tweens).map(function (tweenId) {
return _this._tweens[tweenId];
});
};
Group.prototype.removeAll = function () {
this._tweens = {};
};
Group.prototype.add = function (tween) {
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.update = function (time, preserve) {
var tweenIds = Object.keys(this._tweens);
if (tweenIds.length === 0) {
return false;
}
time = time !== undefined ? time : NOW$1();
// Tweens are updated in "batches". If you add a new tween during an
// update, then the new tween will be updated in the next batch.
// If you remove a tween during an update, it may or may not be updated.
// However, if the removed tween was added during the current batch,
// then it will not be updated.
while (tweenIds.length > 0) {
this._tweensAddedDuringUpdate = {};
for (var i = 0; i < tweenIds.length; i++) {
var tween = this._tweens[tweenIds[i]];
if (tween && tween.update(time) === false && !preserve) {
delete this._tweens[tweenIds[i]];
}
}
tweenIds = Object.keys(this._tweensAddedDuringUpdate);
}
return true;
};
return Group;
}());
/**
* The Ease class provides a collection of easing functions for use with tween.js.

@@ -274,5 +188,91 @@ */

var now;
// Include a performance.now polyfill.
// In node.js, use process.hrtime.
// eslint-disable-next-line
// @ts-ignore
if (typeof self === 'undefined' && typeof process !== 'undefined' && process.hrtime) {
now = function () {
// eslint-disable-next-line
// @ts-ignore
var time = process.hrtime();
// Convert [seconds, nanoseconds] to milliseconds.
return time[0] * 1000 + time[1] / 1000000;
};
}
// In a browser, use self.performance.now if it is available.
else if (typeof self !== 'undefined' && self.performance !== undefined && self.performance.now !== undefined) {
// This must be bound, because directly assigning this function
// leads to an invocation exception in Chrome.
now = self.performance.now.bind(self.performance);
}
// Use Date.now if it is available.
else if (Date.now !== undefined) {
now = Date.now;
}
// Otherwise, use 'new Date().getTime()'.
else {
now = function () {
return new Date().getTime();
};
}
var now$1 = now;
/**
* 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
*/
var Group = /** @class */ (function () {
function Group() {
this._tweens = {};
this._tweensAddedDuringUpdate = {};
}
Group.prototype.getAll = function () {
var _this = this;
return Object.keys(this._tweens).map(function (tweenId) {
return _this._tweens[tweenId];
});
};
Group.prototype.removeAll = function () {
this._tweens = {};
};
Group.prototype.add = function (tween) {
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.update = function (time, preserve) {
var tweenIds = Object.keys(this._tweens);
if (tweenIds.length === 0) {
return false;
}
time = time !== undefined ? time : now$1();
// Tweens are updated in "batches". If you add a new tween during an
// update, then the new tween will be updated in the next batch.
// If you remove a tween during an update, it may or may not be updated.
// However, if the removed tween was added during the current batch,
// then it will not be updated.
while (tweenIds.length > 0) {
this._tweensAddedDuringUpdate = {};
for (var i = 0; i < tweenIds.length; i++) {
var tween = this._tweens[tweenIds[i]];
if (tween && tween.update(time) === false && !preserve) {
delete this._tweens[tweenIds[i]];
}
}
tweenIds = Object.keys(this._tweensAddedDuringUpdate);
}
return true;
};
return Group;
}());
/**
*
*/
var Interpolation = {

@@ -368,2 +368,4 @@ Linear: function (v, k) {

var mainGroup = new Group();
/**

@@ -379,3 +381,3 @@ * Tween.js - Licensed under the MIT license

function Tween(_object, _group) {
if (_group === void 0) { _group = TWEEN; }
if (_group === void 0) { _group = mainGroup; }
this._object = _object;

@@ -396,7 +398,7 @@ this._group = _group;

this._startTime = 0;
this._easingFunction = TWEEN.Easing.Linear.None;
this._interpolationFunction = TWEEN.Interpolation.Linear;
this._easingFunction = Easing.Linear.None;
this._interpolationFunction = Interpolation.Linear;
this._chainedTweens = [];
this._onStartCallbackFired = false;
this._id = TWEEN.nextId();
this._id = Sequence.nextId();
this._isChainStopped = false;

@@ -447,4 +449,3 @@ }

this._isChainStopped = false;
this._startTime =
time !== undefined ? (typeof time === 'string' ? TWEEN.now() + parseFloat(time) : time) : TWEEN.now();
this._startTime = time !== undefined ? (typeof time === 'string' ? now$1() + parseFloat(time) : time) : now$1();
this._startTime += this._delayTime;

@@ -538,3 +539,3 @@ this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat);

this._isPaused = true;
this._pauseStart = time === undefined ? TWEEN.now() : time;
this._pauseStart = time === undefined ? now$1() : time;
// eslint-disable-next-line

@@ -550,3 +551,3 @@ // @ts-ignore FIXME?

this._isPaused = false;
this._startTime += (time === undefined ? TWEEN.now() : time) - this._pauseStart;
this._startTime += (time === undefined ? now$1() : time) - this._pauseStart;
this._pauseStart = 0;

@@ -624,2 +625,3 @@ // eslint-disable-next-line

var elapsed;
time = time !== undefined ? time : now$1();
var endTime = this._startTime + this._duration;

@@ -754,3 +756,3 @@ if (time > endTime && !this._isPlaying) {

var VERSION = '18.6.0';
var VERSION = '18.6.1';

@@ -765,15 +767,3 @@ /**

*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var nextId = Sequence.nextId;
/**

@@ -783,21 +773,31 @@ * 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
* In these cases, you may want to create your own smaller groups of tweens.
*/
var Main = /** @class */ (function (_super) {
__extends(Main, _super);
function Main() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.version = VERSION;
_this.now = NOW$1;
_this.Group = Group;
_this.Easing = Easing;
_this.Interpolation = Interpolation;
_this.nextId = Sequence.nextId;
_this.Tween = Tween;
return _this;
}
return Main;
}(Group));
var TWEEN = new Main();
var TWEEN = mainGroup;
// This is the best way to export things in a way that's compatible with both ES
// Modules and CommonJS, without build hacks, and so as not to break the
// existing API.
// https://github.com/rollup/rollup/issues/1961#issuecomment-423037881
var getAll = TWEEN.getAll.bind(TWEEN);
var removeAll = TWEEN.removeAll.bind(TWEEN);
var add = TWEEN.add.bind(TWEEN);
var remove = TWEEN.remove.bind(TWEEN);
var update = TWEEN.update.bind(TWEEN);
var exports = {
Easing: Easing,
Group: Group,
Interpolation: Interpolation,
now: now$1,
Sequence: Sequence,
nextId: nextId,
Tween: Tween,
VERSION: VERSION,
getAll: getAll,
removeAll: removeAll,
add: add,
remove: remove,
update: update,
};
export default TWEEN;
export default exports;
export { Easing, Group, Interpolation, Sequence, Tween, VERSION, add, getAll, nextId, now$1 as now, remove, removeAll, update };
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.TWEEN = factory());
}(this, (function () { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TWEEN = {}));
}(this, (function (exports) { 'use strict';
var NOW;
// Include a performance.now polyfill.
// In node.js, use process.hrtime.
// eslint-disable-next-line
// @ts-ignore
if (typeof self === 'undefined' && typeof process !== 'undefined' && process.hrtime) {
NOW = function () {
// eslint-disable-next-line
// @ts-ignore
var time = process.hrtime();
// Convert [seconds, nanoseconds] to milliseconds.
return time[0] * 1000 + time[1] / 1000000;
};
}
// In a browser, use self.performance.now if it is available.
else if (typeof self !== 'undefined' && self.performance !== undefined && self.performance.now !== undefined) {
// This must be bound, because directly assigning this function
// leads to an invocation exception in Chrome.
NOW = self.performance.now.bind(self.performance);
}
// Use Date.now if it is available.
else if (Date.now !== undefined) {
NOW = Date.now;
}
// Otherwise, use 'new Date().getTime()'.
else {
NOW = function () {
return new Date().getTime();
};
}
var NOW$1 = NOW;
/**
* 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
*/
var Group = /** @class */ (function () {
function Group() {
this._tweens = {};
this._tweensAddedDuringUpdate = {};
}
Group.prototype.getAll = function () {
var _this = this;
return Object.keys(this._tweens).map(function (tweenId) {
return _this._tweens[tweenId];
});
};
Group.prototype.removeAll = function () {
this._tweens = {};
};
Group.prototype.add = function (tween) {
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.update = function (time, preserve) {
var tweenIds = Object.keys(this._tweens);
if (tweenIds.length === 0) {
return false;
}
time = time !== undefined ? time : NOW$1();
// Tweens are updated in "batches". If you add a new tween during an
// update, then the new tween will be updated in the next batch.
// If you remove a tween during an update, it may or may not be updated.
// However, if the removed tween was added during the current batch,
// then it will not be updated.
while (tweenIds.length > 0) {
this._tweensAddedDuringUpdate = {};
for (var i = 0; i < tweenIds.length; i++) {
var tween = this._tweens[tweenIds[i]];
if (tween && tween.update(time) === false && !preserve) {
delete this._tweens[tweenIds[i]];
}
}
tweenIds = Object.keys(this._tweensAddedDuringUpdate);
}
return true;
};
return Group;
}());
/**
* The Ease class provides a collection of easing functions for use with tween.js.

@@ -280,5 +194,91 @@ */

var now;
// Include a performance.now polyfill.
// In node.js, use process.hrtime.
// eslint-disable-next-line
// @ts-ignore
if (typeof self === 'undefined' && typeof process !== 'undefined' && process.hrtime) {
now = function () {
// eslint-disable-next-line
// @ts-ignore
var time = process.hrtime();
// Convert [seconds, nanoseconds] to milliseconds.
return time[0] * 1000 + time[1] / 1000000;
};
}
// In a browser, use self.performance.now if it is available.
else if (typeof self !== 'undefined' && self.performance !== undefined && self.performance.now !== undefined) {
// This must be bound, because directly assigning this function
// leads to an invocation exception in Chrome.
now = self.performance.now.bind(self.performance);
}
// Use Date.now if it is available.
else if (Date.now !== undefined) {
now = Date.now;
}
// Otherwise, use 'new Date().getTime()'.
else {
now = function () {
return new Date().getTime();
};
}
var now$1 = now;
/**
* 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
*/
var Group = /** @class */ (function () {
function Group() {
this._tweens = {};
this._tweensAddedDuringUpdate = {};
}
Group.prototype.getAll = function () {
var _this = this;
return Object.keys(this._tweens).map(function (tweenId) {
return _this._tweens[tweenId];
});
};
Group.prototype.removeAll = function () {
this._tweens = {};
};
Group.prototype.add = function (tween) {
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.update = function (time, preserve) {
var tweenIds = Object.keys(this._tweens);
if (tweenIds.length === 0) {
return false;
}
time = time !== undefined ? time : now$1();
// Tweens are updated in "batches". If you add a new tween during an
// update, then the new tween will be updated in the next batch.
// If you remove a tween during an update, it may or may not be updated.
// However, if the removed tween was added during the current batch,
// then it will not be updated.
while (tweenIds.length > 0) {
this._tweensAddedDuringUpdate = {};
for (var i = 0; i < tweenIds.length; i++) {
var tween = this._tweens[tweenIds[i]];
if (tween && tween.update(time) === false && !preserve) {
delete this._tweens[tweenIds[i]];
}
}
tweenIds = Object.keys(this._tweensAddedDuringUpdate);
}
return true;
};
return Group;
}());
/**
*
*/
var Interpolation = {

@@ -374,2 +374,4 @@ Linear: function (v, k) {

var mainGroup = new Group();
/**

@@ -385,3 +387,3 @@ * Tween.js - Licensed under the MIT license

function Tween(_object, _group) {
if (_group === void 0) { _group = TWEEN; }
if (_group === void 0) { _group = mainGroup; }
this._object = _object;

@@ -402,7 +404,7 @@ this._group = _group;

this._startTime = 0;
this._easingFunction = TWEEN.Easing.Linear.None;
this._interpolationFunction = TWEEN.Interpolation.Linear;
this._easingFunction = Easing.Linear.None;
this._interpolationFunction = Interpolation.Linear;
this._chainedTweens = [];
this._onStartCallbackFired = false;
this._id = TWEEN.nextId();
this._id = Sequence.nextId();
this._isChainStopped = false;

@@ -453,4 +455,3 @@ }

this._isChainStopped = false;
this._startTime =
time !== undefined ? (typeof time === 'string' ? TWEEN.now() + parseFloat(time) : time) : TWEEN.now();
this._startTime = time !== undefined ? (typeof time === 'string' ? now$1() + parseFloat(time) : time) : now$1();
this._startTime += this._delayTime;

@@ -544,3 +545,3 @@ this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat);

this._isPaused = true;
this._pauseStart = time === undefined ? TWEEN.now() : time;
this._pauseStart = time === undefined ? now$1() : time;
// eslint-disable-next-line

@@ -556,3 +557,3 @@ // @ts-ignore FIXME?

this._isPaused = false;
this._startTime += (time === undefined ? TWEEN.now() : time) - this._pauseStart;
this._startTime += (time === undefined ? now$1() : time) - this._pauseStart;
this._pauseStart = 0;

@@ -630,2 +631,3 @@ // eslint-disable-next-line

var elapsed;
time = time !== undefined ? time : now$1();
var endTime = this._startTime + this._duration;

@@ -760,3 +762,3 @@ if (time > endTime && !this._isPlaying) {

var VERSION = '18.6.0';
var VERSION = '18.6.1';

@@ -771,15 +773,3 @@ /**

*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var nextId = Sequence.nextId;
/**

@@ -789,23 +779,47 @@ * 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
* In these cases, you may want to create your own smaller groups of tweens.
*/
var Main = /** @class */ (function (_super) {
__extends(Main, _super);
function Main() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.version = VERSION;
_this.now = NOW$1;
_this.Group = Group;
_this.Easing = Easing;
_this.Interpolation = Interpolation;
_this.nextId = Sequence.nextId;
_this.Tween = Tween;
return _this;
}
return Main;
}(Group));
var TWEEN = new Main();
var TWEEN = mainGroup;
// This is the best way to export things in a way that's compatible with both ES
// Modules and CommonJS, without build hacks, and so as not to break the
// existing API.
// https://github.com/rollup/rollup/issues/1961#issuecomment-423037881
var getAll = TWEEN.getAll.bind(TWEEN);
var removeAll = TWEEN.removeAll.bind(TWEEN);
var add = TWEEN.add.bind(TWEEN);
var remove = TWEEN.remove.bind(TWEEN);
var update = TWEEN.update.bind(TWEEN);
var exports$1 = {
Easing: Easing,
Group: Group,
Interpolation: Interpolation,
now: now$1,
Sequence: Sequence,
nextId: nextId,
Tween: Tween,
VERSION: VERSION,
getAll: getAll,
removeAll: removeAll,
add: add,
remove: remove,
update: update,
};
return TWEEN;
exports.Easing = Easing;
exports.Group = Group;
exports.Interpolation = Interpolation;
exports.Sequence = Sequence;
exports.Tween = Tween;
exports.VERSION = VERSION;
exports.add = add;
exports.default = exports$1;
exports.getAll = getAll;
exports.nextId = nextId;
exports.now = now$1;
exports.remove = remove;
exports.removeAll = removeAll;
exports.update = update;
Object.defineProperty(exports, '__esModule', { value: true });
})));
{
"name": "@tweenjs/tween.js",
"description": "Super simple, fast and easy to use tweening engine which incorporates optimised Robert Penner's equations.",
"version": "18.6.0",
"version": "18.6.1",
"main": "dist/tween.cjs.js",
"types": "dist/index.d.ts",
"types": "dist/tween.d.ts",
"module": "dist/tween.esm.js",

@@ -28,8 +28,6 @@ "files": [

"scripts": {
"build": "rimraf dist && node scripts/write-version.js && npm run tsc && npm run rollup-build && npm run tsc-d.ts && npm run adjust-d.ts",
"build": "rimraf dist .tmp && node scripts/write-version.js && npm run tsc && npm run rollup-build",
"rollup-build": "rollup -c ./rollup.config.js",
"tsc": "tsc",
"tsc-watch": "tsc --watch",
"tsc-d.ts": "tsc --declaration --emitDeclarationOnly --esModuleInterop --outFile dist/index.d.ts",
"adjust-d.ts": "node scripts/adjust-d.ts.js",
"test": "npm run build && npm run test-unit && npm run test-lint",

@@ -40,3 +38,7 @@ "test-unit": "nodeunit test/unit/nodeunitheadless.js",

"prettier": "prettier './**/*.{js,ts,md,json,html,css}'",
"prepare": "npm run build"
"prepare": "npm run build",
"version": "npm test && git add .",
"release:patch": "npm version patch --message 'v%s' && npm publish && git push --follow-tags",
"release:minor": "npm version minor --message 'v%s' && npm publish && git push --follow-tags",
"release:major": "npm version major --message 'v%s' && npm publish && git push --follow-tags"
},

@@ -53,7 +55,7 @@ "author": "tween.js contributors (https://github.com/tweenjs/tween.js/graphs/contributors)",

"rimraf": "^3.0.0",
"rollup": "^0.57.1",
"rollup-plugin-typescript": "^1.0.1",
"rollup": "^2.0.0",
"rollup-plugin-dts": "1.4.10",
"tslib": "^1.10.0",
"typescript": "^3.9.0"
"typescript": "^4.0.0"
}
}

@@ -6,11 +6,8 @@ # tween.js

[![NPM Version][npm-image]][npm-url]
[![CDNJS][cdnjs-image]][cdnjs-url]
[![NPM Downloads][downloads-image]][downloads-url]
[![Travis tests][travis-image]][travis-url]
[![Flattr this][flattr-image]][flattr-url]
[![CDNJS][cdnjs-image]][cdnjs-url]
[![Build and Tests][ci-image]][ci-url]
Do you use tween.js? If you have some time, please fill out [this short survey](https://docs.google.com/forms/d/e/1FAIpQLScJ0xnsS1m4mdXGRmGFPVd_CYi0Ah224lLYc4UP-fmakQjNHw/viewform?usp=sf_link).
**Update Note** In v18 the script you should include has moved from `src/Tween.js` to `dist/tween.umd.js`. See the [installation section](#Installation) below.
**Update Note** In v18 the script you should include has moved from `src/Tween.js` to `dist/tween.umd.js`. See the [installation section](#Installation) below. v18 is not yet available on CDNJS.
---

@@ -258,3 +255,3 @@

Maintainers: [mikebolt](https://github.com/mikebolt), [sole](https://github.com/sole).
Maintainers: [mikebolt](https://github.com/mikebolt), [sole](https://github.com/sole), [Joe Pea (@trusktr)](https://github.com/trusktr).

@@ -280,7 +277,5 @@ [All contributors](http://github.com/tweenjs/tween.js/contributors).

[downloads-url]: https://npmjs.org/package/@tweenjs/tween.js
[travis-image]: https://travis-ci.org/tweenjs/tween.js.svg?branch=master
[travis-url]: https://travis-ci.org/tweenjs/tween.js
[flattr-image]: https://api.flattr.com/button/flattr-badge-large.png
[flattr-url]: https://flattr.com/thing/45014/tween-js
[ci-image]: https://github.com/tweenjs/tween.js/workflows/build%20and%20tests/badge.svg?branch=master
[ci-url]: https://github.com/tweenjs/tween.js/actions
[cdnjs-image]: https://img.shields.io/cdnjs/v/tween.js.svg
[cdnjs-url]: https://cdnjs.com/libraries/tween.js
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