Socket
Socket
Sign inDemoInstall

@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 19.0.0 to 20.0.0

141

dist/tween.amd.js

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

define(['exports'], function (exports) { 'use strict';
define(['exports'], (function (exports) { 'use strict';

@@ -218,33 +218,3 @@ /**

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;
var now = function () { return performance.now(); };

@@ -280,3 +250,3 @@ /**

Group.prototype.update = function (time, preserve) {
if (time === void 0) { time = now$1(); }
if (time === void 0) { time = now(); }
if (preserve === void 0) { preserve = false; }

@@ -422,2 +392,3 @@ var tweenIds = Object.keys(this._tweens);

this._duration = 1000;
this._isDynamic = false;
this._initialRepeat = 0;

@@ -438,2 +409,3 @@ this._repeat = 0;

this._isChainStopped = false;
this._propertiesAreSetUp = false;
this._goToEnd = false;

@@ -450,20 +422,23 @@ }

};
Tween.prototype.to = function (properties, duration) {
// TODO? restore this, then update the 07_dynamic_to example to set fox
// tween's to on each update. That way the behavior is opt-in (there's
// currently no opt-out).
// for (const prop in properties) this._valuesEnd[prop] = properties[prop]
this._valuesEnd = Object.create(properties);
if (duration !== undefined) {
this._duration = duration;
}
Tween.prototype.to = function (target, duration) {
if (duration === void 0) { duration = 1000; }
if (this._isPlaying)
throw new Error('Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.');
this._valuesEnd = target;
this._propertiesAreSetUp = false;
this._duration = duration;
return this;
};
Tween.prototype.duration = function (d) {
if (d === void 0) { d = 1000; }
this._duration = d;
Tween.prototype.duration = function (duration) {
if (duration === void 0) { duration = 1000; }
this._duration = duration;
return this;
};
Tween.prototype.dynamic = function (dynamic) {
if (dynamic === void 0) { dynamic = false; }
this._isDynamic = dynamic;
return this;
};
Tween.prototype.start = function (time, overrideStartingValues) {
if (time === void 0) { time = now$1(); }
if (time === void 0) { time = now(); }
if (overrideStartingValues === void 0) { overrideStartingValues = false; }

@@ -492,3 +467,13 @@ if (this._isPlaying) {

this._startTime += this._delayTime;
this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat, overrideStartingValues);
if (!this._propertiesAreSetUp || overrideStartingValues) {
this._propertiesAreSetUp = true;
// If dynamic is not enabled, clone the end values instead of using the passed-in end values.
if (!this._isDynamic) {
var tmp = {};
for (var prop in this._valuesEnd)
tmp[prop] = this._valuesEnd[prop];
this._valuesEnd = tmp;
}
this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat, overrideStartingValues);
}
return this;

@@ -516,8 +501,19 @@ };

}
// handle an array of relative values
endValues = endValues.map(this._handleRelativeValue.bind(this, startValue));
// Create a local copy of the Array with the start value at the front
if (_valuesStart[property] === undefined) {
_valuesEnd[property] = [startValue].concat(endValues);
// Handle an array of relative values.
// Creates a local copy of the Array with the start value at the front
var temp = [startValue];
for (var i = 0, l = endValues.length; i < l; i += 1) {
var value = this._handleRelativeValue(startValue, endValues[i]);
if (isNaN(value)) {
isInterpolationList = false;
console.warn('Found invalid interpolation list. Skipping.');
break;
}
temp.push(value);
}
if (isInterpolationList) {
// if (_valuesStart[property] === undefined) { // handle end values only the first time. NOT NEEDED? setupProperties is now guarded by _propertiesAreSetUp.
_valuesEnd[property] = temp;
// }
}
}

@@ -527,12 +523,17 @@ // handle the deepness of the values

_valuesStart[property] = startValueIsArray ? [] : {};
// eslint-disable-next-line
for (var prop in startValue) {
// eslint-disable-next-line
// @ts-ignore FIXME?
_valuesStart[property][prop] = startValue[prop];
var nestedObject = startValue;
for (var prop in nestedObject) {
_valuesStart[property][prop] = nestedObject[prop];
}
_valuesStartRepeat[property] = startValueIsArray ? [] : {}; // TODO? repeat nested values? And yoyo? And array values?
// eslint-disable-next-line
// @ts-ignore FIXME?
this._setupProperties(startValue, _valuesStart[property], _valuesEnd[property], _valuesStartRepeat[property], overrideStartingValues);
// TODO? repeat nested values? And yoyo? And array values?
_valuesStartRepeat[property] = startValueIsArray ? [] : {};
var endValues = _valuesEnd[property];
// If dynamic is not enabled, clone the end values instead of using the passed-in end values.
if (!this._isDynamic) {
var tmp = {};
for (var prop in endValues)
tmp[prop] = endValues[prop];
_valuesEnd[property] = endValues = tmp;
}
this._setupProperties(nestedObject, _valuesStart[property], endValues, _valuesStartRepeat[property], overrideStartingValues);
}

@@ -583,3 +584,3 @@ else {

Tween.prototype.pause = function (time) {
if (time === void 0) { time = now$1(); }
if (time === void 0) { time = now(); }
if (this._isPaused || !this._isPlaying) {

@@ -595,3 +596,3 @@ return this;

Tween.prototype.resume = function (time) {
if (time === void 0) { time = now$1(); }
if (time === void 0) { time = now(); }
if (!this._isPaused || !this._isPlaying) {

@@ -687,3 +688,3 @@ return this;

Tween.prototype.update = function (time, autoStart) {
if (time === void 0) { time = now$1(); }
if (time === void 0) { time = now(); }
if (autoStart === void 0) { autoStart = true; }

@@ -811,5 +812,3 @@ if (this._isPaused)

}
else {
return parseFloat(end);
}
return parseFloat(end);
};

@@ -830,3 +829,3 @@ Tween.prototype._swapEndStartRepeatValues = function (property) {

var VERSION = '19.0.0';
var VERSION = '20.0.0';

@@ -862,3 +861,3 @@ /**

Interpolation: Interpolation,
now: now$1,
now: now,
Sequence: Sequence,

@@ -885,3 +884,3 @@ nextId: nextId,

exports.nextId = nextId;
exports.now = now$1;
exports.now = now;
exports.remove = remove;

@@ -893,2 +892,2 @@ exports.removeAll = removeAll;

});
}));

@@ -220,33 +220,3 @@ '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;
var now = function () { return performance.now(); };

@@ -282,3 +252,3 @@ /**

Group.prototype.update = function (time, preserve) {
if (time === void 0) { time = now$1(); }
if (time === void 0) { time = now(); }
if (preserve === void 0) { preserve = false; }

@@ -424,2 +394,3 @@ var tweenIds = Object.keys(this._tweens);

this._duration = 1000;
this._isDynamic = false;
this._initialRepeat = 0;

@@ -440,2 +411,3 @@ this._repeat = 0;

this._isChainStopped = false;
this._propertiesAreSetUp = false;
this._goToEnd = false;

@@ -452,20 +424,23 @@ }

};
Tween.prototype.to = function (properties, duration) {
// TODO? restore this, then update the 07_dynamic_to example to set fox
// tween's to on each update. That way the behavior is opt-in (there's
// currently no opt-out).
// for (const prop in properties) this._valuesEnd[prop] = properties[prop]
this._valuesEnd = Object.create(properties);
if (duration !== undefined) {
this._duration = duration;
}
Tween.prototype.to = function (target, duration) {
if (duration === void 0) { duration = 1000; }
if (this._isPlaying)
throw new Error('Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.');
this._valuesEnd = target;
this._propertiesAreSetUp = false;
this._duration = duration;
return this;
};
Tween.prototype.duration = function (d) {
if (d === void 0) { d = 1000; }
this._duration = d;
Tween.prototype.duration = function (duration) {
if (duration === void 0) { duration = 1000; }
this._duration = duration;
return this;
};
Tween.prototype.dynamic = function (dynamic) {
if (dynamic === void 0) { dynamic = false; }
this._isDynamic = dynamic;
return this;
};
Tween.prototype.start = function (time, overrideStartingValues) {
if (time === void 0) { time = now$1(); }
if (time === void 0) { time = now(); }
if (overrideStartingValues === void 0) { overrideStartingValues = false; }

@@ -494,3 +469,13 @@ if (this._isPlaying) {

this._startTime += this._delayTime;
this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat, overrideStartingValues);
if (!this._propertiesAreSetUp || overrideStartingValues) {
this._propertiesAreSetUp = true;
// If dynamic is not enabled, clone the end values instead of using the passed-in end values.
if (!this._isDynamic) {
var tmp = {};
for (var prop in this._valuesEnd)
tmp[prop] = this._valuesEnd[prop];
this._valuesEnd = tmp;
}
this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat, overrideStartingValues);
}
return this;

@@ -518,8 +503,19 @@ };

}
// handle an array of relative values
endValues = endValues.map(this._handleRelativeValue.bind(this, startValue));
// Create a local copy of the Array with the start value at the front
if (_valuesStart[property] === undefined) {
_valuesEnd[property] = [startValue].concat(endValues);
// Handle an array of relative values.
// Creates a local copy of the Array with the start value at the front
var temp = [startValue];
for (var i = 0, l = endValues.length; i < l; i += 1) {
var value = this._handleRelativeValue(startValue, endValues[i]);
if (isNaN(value)) {
isInterpolationList = false;
console.warn('Found invalid interpolation list. Skipping.');
break;
}
temp.push(value);
}
if (isInterpolationList) {
// if (_valuesStart[property] === undefined) { // handle end values only the first time. NOT NEEDED? setupProperties is now guarded by _propertiesAreSetUp.
_valuesEnd[property] = temp;
// }
}
}

@@ -529,12 +525,17 @@ // handle the deepness of the values

_valuesStart[property] = startValueIsArray ? [] : {};
// eslint-disable-next-line
for (var prop in startValue) {
// eslint-disable-next-line
// @ts-ignore FIXME?
_valuesStart[property][prop] = startValue[prop];
var nestedObject = startValue;
for (var prop in nestedObject) {
_valuesStart[property][prop] = nestedObject[prop];
}
_valuesStartRepeat[property] = startValueIsArray ? [] : {}; // TODO? repeat nested values? And yoyo? And array values?
// eslint-disable-next-line
// @ts-ignore FIXME?
this._setupProperties(startValue, _valuesStart[property], _valuesEnd[property], _valuesStartRepeat[property], overrideStartingValues);
// TODO? repeat nested values? And yoyo? And array values?
_valuesStartRepeat[property] = startValueIsArray ? [] : {};
var endValues = _valuesEnd[property];
// If dynamic is not enabled, clone the end values instead of using the passed-in end values.
if (!this._isDynamic) {
var tmp = {};
for (var prop in endValues)
tmp[prop] = endValues[prop];
_valuesEnd[property] = endValues = tmp;
}
this._setupProperties(nestedObject, _valuesStart[property], endValues, _valuesStartRepeat[property], overrideStartingValues);
}

@@ -585,3 +586,3 @@ else {

Tween.prototype.pause = function (time) {
if (time === void 0) { time = now$1(); }
if (time === void 0) { time = now(); }
if (this._isPaused || !this._isPlaying) {

@@ -597,3 +598,3 @@ return this;

Tween.prototype.resume = function (time) {
if (time === void 0) { time = now$1(); }
if (time === void 0) { time = now(); }
if (!this._isPaused || !this._isPlaying) {

@@ -689,3 +690,3 @@ return this;

Tween.prototype.update = function (time, autoStart) {
if (time === void 0) { time = now$1(); }
if (time === void 0) { time = now(); }
if (autoStart === void 0) { autoStart = true; }

@@ -813,5 +814,3 @@ if (this._isPaused)

}
else {
return parseFloat(end);
}
return parseFloat(end);
};

@@ -832,3 +831,3 @@ Tween.prototype._swapEndStartRepeatValues = function (property) {

var VERSION = '19.0.0';
var VERSION = '20.0.0';

@@ -864,3 +863,3 @@ /**

Interpolation: Interpolation,
now: now$1,
now: now,
Sequence: Sequence,

@@ -887,5 +886,5 @@ nextId: nextId,

exports.nextId = nextId;
exports.now = now$1;
exports.now = now;
exports.remove = remove;
exports.removeAll = removeAll;
exports.update = update;

@@ -1,3 +0,3 @@

declare type EasingFunction = (amount: number) => number;
declare type EasingFunctionGroup = {
type EasingFunction = (amount: number) => number;
type EasingFunctionGroup = {
In: EasingFunction;

@@ -30,3 +30,3 @@ Out: EasingFunction;

*/
declare type InterpolationFunction = (v: number[], k: number) => number;
type InterpolationFunction = (v: number[], k: number) => number;
/**

@@ -47,2 +47,27 @@ *

/**
* 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
* https://github.com/tweenjs/tween.js
* ----------------------------------------------
*
* See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors.
* Thank you all, you're awesome!
*/
declare class Tween<T extends UnknownProps> {

@@ -57,2 +82,3 @@ private _object;

private _duration;
private _isDynamic;
private _initialRepeat;

@@ -79,2 +105,3 @@ private _repeat;

private _isChainStopped;
private _propertiesAreSetUp;
constructor(_object: T, _group?: Group | false);

@@ -84,4 +111,5 @@ getId(): number;

isPaused(): boolean;
to(properties: UnknownProps, duration?: number): this;
duration(d?: number): this;
to(target: UnknownProps, duration?: number): this;
duration(duration?: number): this;
dynamic(dynamic?: boolean): this;
start(time?: number, overrideStartingValues?: boolean): this;

@@ -120,22 +148,6 @@ startFromCurrentValues(time?: number): this;

}
declare type UnknownProps = Record<string, any>;
type UnknownProps = Record<string, any>;
/**
* 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;
}
declare const now: () => number;
declare let now: () => number;
/**

@@ -149,10 +161,11 @@ * Utils

declare const VERSION = "19.0.0";
declare const VERSION = "20.0.0";
declare const nextId: typeof Sequence.nextId;
declare const getAll: () => Tween<Record<string, any>>[];
declare const getAll: () => Tween<UnknownProps>[];
declare const removeAll: () => void;
declare const add: (tween: Tween<Record<string, any>>) => void;
declare const remove: (tween: Tween<Record<string, any>>) => void;
declare const add: (tween: Tween<UnknownProps>) => void;
declare const remove: (tween: Tween<UnknownProps>) => void;
declare const update: (time?: number, preserve?: boolean) => boolean;
declare const exports: {

@@ -192,10 +205,9 @@ Easing: Readonly<{

VERSION: string;
getAll: () => Tween<Record<string, any>>[];
getAll: () => Tween<UnknownProps>[];
removeAll: () => void;
add: (tween: Tween<Record<string, any>>) => void;
remove: (tween: Tween<Record<string, any>>) => void;
add: (tween: Tween<UnknownProps>) => void;
remove: (tween: Tween<UnknownProps>) => void;
update: (time?: number, preserve?: boolean) => boolean;
};
export default exports;
export { Easing, Group, Interpolation, Sequence, Tween, VERSION, add, getAll, nextId, now, remove, removeAll, update };
export { Easing, Group, Interpolation, Sequence, Tween, VERSION, add, exports as default, getAll, nextId, now, remove, removeAll, update };

@@ -216,33 +216,3 @@ /**

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;
var now = function () { return performance.now(); };

@@ -278,3 +248,3 @@ /**

Group.prototype.update = function (time, preserve) {
if (time === void 0) { time = now$1(); }
if (time === void 0) { time = now(); }
if (preserve === void 0) { preserve = false; }

@@ -420,2 +390,3 @@ var tweenIds = Object.keys(this._tweens);

this._duration = 1000;
this._isDynamic = false;
this._initialRepeat = 0;

@@ -436,2 +407,3 @@ this._repeat = 0;

this._isChainStopped = false;
this._propertiesAreSetUp = false;
this._goToEnd = false;

@@ -448,20 +420,23 @@ }

};
Tween.prototype.to = function (properties, duration) {
// TODO? restore this, then update the 07_dynamic_to example to set fox
// tween's to on each update. That way the behavior is opt-in (there's
// currently no opt-out).
// for (const prop in properties) this._valuesEnd[prop] = properties[prop]
this._valuesEnd = Object.create(properties);
if (duration !== undefined) {
this._duration = duration;
}
Tween.prototype.to = function (target, duration) {
if (duration === void 0) { duration = 1000; }
if (this._isPlaying)
throw new Error('Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.');
this._valuesEnd = target;
this._propertiesAreSetUp = false;
this._duration = duration;
return this;
};
Tween.prototype.duration = function (d) {
if (d === void 0) { d = 1000; }
this._duration = d;
Tween.prototype.duration = function (duration) {
if (duration === void 0) { duration = 1000; }
this._duration = duration;
return this;
};
Tween.prototype.dynamic = function (dynamic) {
if (dynamic === void 0) { dynamic = false; }
this._isDynamic = dynamic;
return this;
};
Tween.prototype.start = function (time, overrideStartingValues) {
if (time === void 0) { time = now$1(); }
if (time === void 0) { time = now(); }
if (overrideStartingValues === void 0) { overrideStartingValues = false; }

@@ -490,3 +465,13 @@ if (this._isPlaying) {

this._startTime += this._delayTime;
this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat, overrideStartingValues);
if (!this._propertiesAreSetUp || overrideStartingValues) {
this._propertiesAreSetUp = true;
// If dynamic is not enabled, clone the end values instead of using the passed-in end values.
if (!this._isDynamic) {
var tmp = {};
for (var prop in this._valuesEnd)
tmp[prop] = this._valuesEnd[prop];
this._valuesEnd = tmp;
}
this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat, overrideStartingValues);
}
return this;

@@ -514,8 +499,19 @@ };

}
// handle an array of relative values
endValues = endValues.map(this._handleRelativeValue.bind(this, startValue));
// Create a local copy of the Array with the start value at the front
if (_valuesStart[property] === undefined) {
_valuesEnd[property] = [startValue].concat(endValues);
// Handle an array of relative values.
// Creates a local copy of the Array with the start value at the front
var temp = [startValue];
for (var i = 0, l = endValues.length; i < l; i += 1) {
var value = this._handleRelativeValue(startValue, endValues[i]);
if (isNaN(value)) {
isInterpolationList = false;
console.warn('Found invalid interpolation list. Skipping.');
break;
}
temp.push(value);
}
if (isInterpolationList) {
// if (_valuesStart[property] === undefined) { // handle end values only the first time. NOT NEEDED? setupProperties is now guarded by _propertiesAreSetUp.
_valuesEnd[property] = temp;
// }
}
}

@@ -525,12 +521,17 @@ // handle the deepness of the values

_valuesStart[property] = startValueIsArray ? [] : {};
// eslint-disable-next-line
for (var prop in startValue) {
// eslint-disable-next-line
// @ts-ignore FIXME?
_valuesStart[property][prop] = startValue[prop];
var nestedObject = startValue;
for (var prop in nestedObject) {
_valuesStart[property][prop] = nestedObject[prop];
}
_valuesStartRepeat[property] = startValueIsArray ? [] : {}; // TODO? repeat nested values? And yoyo? And array values?
// eslint-disable-next-line
// @ts-ignore FIXME?
this._setupProperties(startValue, _valuesStart[property], _valuesEnd[property], _valuesStartRepeat[property], overrideStartingValues);
// TODO? repeat nested values? And yoyo? And array values?
_valuesStartRepeat[property] = startValueIsArray ? [] : {};
var endValues = _valuesEnd[property];
// If dynamic is not enabled, clone the end values instead of using the passed-in end values.
if (!this._isDynamic) {
var tmp = {};
for (var prop in endValues)
tmp[prop] = endValues[prop];
_valuesEnd[property] = endValues = tmp;
}
this._setupProperties(nestedObject, _valuesStart[property], endValues, _valuesStartRepeat[property], overrideStartingValues);
}

@@ -581,3 +582,3 @@ else {

Tween.prototype.pause = function (time) {
if (time === void 0) { time = now$1(); }
if (time === void 0) { time = now(); }
if (this._isPaused || !this._isPlaying) {

@@ -593,3 +594,3 @@ return this;

Tween.prototype.resume = function (time) {
if (time === void 0) { time = now$1(); }
if (time === void 0) { time = now(); }
if (!this._isPaused || !this._isPlaying) {

@@ -685,3 +686,3 @@ return this;

Tween.prototype.update = function (time, autoStart) {
if (time === void 0) { time = now$1(); }
if (time === void 0) { time = now(); }
if (autoStart === void 0) { autoStart = true; }

@@ -809,5 +810,3 @@ if (this._isPaused)

}
else {
return parseFloat(end);
}
return parseFloat(end);
};

@@ -828,3 +827,3 @@ Tween.prototype._swapEndStartRepeatValues = function (property) {

var VERSION = '19.0.0';
var VERSION = '20.0.0';

@@ -860,3 +859,3 @@ /**

Interpolation: Interpolation,
now: now$1,
now: now,
Sequence: Sequence,

@@ -873,3 +872,2 @@ nextId: nextId,

export default exports;
export { Easing, Group, Interpolation, Sequence, Tween, VERSION, add, getAll, nextId, now$1 as now, remove, removeAll, update };
export { Easing, Group, Interpolation, Sequence, Tween, VERSION, add, exports as default, getAll, nextId, now, remove, removeAll, update };

@@ -5,3 +5,3 @@ (function (global, factory) {

(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TWEEN = {}));
}(this, (function (exports) { 'use strict';
})(this, (function (exports) { 'use strict';

@@ -223,33 +223,3 @@ /**

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;
var now = function () { return performance.now(); };

@@ -285,3 +255,3 @@ /**

Group.prototype.update = function (time, preserve) {
if (time === void 0) { time = now$1(); }
if (time === void 0) { time = now(); }
if (preserve === void 0) { preserve = false; }

@@ -427,2 +397,3 @@ var tweenIds = Object.keys(this._tweens);

this._duration = 1000;
this._isDynamic = false;
this._initialRepeat = 0;

@@ -443,2 +414,3 @@ this._repeat = 0;

this._isChainStopped = false;
this._propertiesAreSetUp = false;
this._goToEnd = false;

@@ -455,20 +427,23 @@ }

};
Tween.prototype.to = function (properties, duration) {
// TODO? restore this, then update the 07_dynamic_to example to set fox
// tween's to on each update. That way the behavior is opt-in (there's
// currently no opt-out).
// for (const prop in properties) this._valuesEnd[prop] = properties[prop]
this._valuesEnd = Object.create(properties);
if (duration !== undefined) {
this._duration = duration;
}
Tween.prototype.to = function (target, duration) {
if (duration === void 0) { duration = 1000; }
if (this._isPlaying)
throw new Error('Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.');
this._valuesEnd = target;
this._propertiesAreSetUp = false;
this._duration = duration;
return this;
};
Tween.prototype.duration = function (d) {
if (d === void 0) { d = 1000; }
this._duration = d;
Tween.prototype.duration = function (duration) {
if (duration === void 0) { duration = 1000; }
this._duration = duration;
return this;
};
Tween.prototype.dynamic = function (dynamic) {
if (dynamic === void 0) { dynamic = false; }
this._isDynamic = dynamic;
return this;
};
Tween.prototype.start = function (time, overrideStartingValues) {
if (time === void 0) { time = now$1(); }
if (time === void 0) { time = now(); }
if (overrideStartingValues === void 0) { overrideStartingValues = false; }

@@ -497,3 +472,13 @@ if (this._isPlaying) {

this._startTime += this._delayTime;
this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat, overrideStartingValues);
if (!this._propertiesAreSetUp || overrideStartingValues) {
this._propertiesAreSetUp = true;
// If dynamic is not enabled, clone the end values instead of using the passed-in end values.
if (!this._isDynamic) {
var tmp = {};
for (var prop in this._valuesEnd)
tmp[prop] = this._valuesEnd[prop];
this._valuesEnd = tmp;
}
this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat, overrideStartingValues);
}
return this;

@@ -521,8 +506,19 @@ };

}
// handle an array of relative values
endValues = endValues.map(this._handleRelativeValue.bind(this, startValue));
// Create a local copy of the Array with the start value at the front
if (_valuesStart[property] === undefined) {
_valuesEnd[property] = [startValue].concat(endValues);
// Handle an array of relative values.
// Creates a local copy of the Array with the start value at the front
var temp = [startValue];
for (var i = 0, l = endValues.length; i < l; i += 1) {
var value = this._handleRelativeValue(startValue, endValues[i]);
if (isNaN(value)) {
isInterpolationList = false;
console.warn('Found invalid interpolation list. Skipping.');
break;
}
temp.push(value);
}
if (isInterpolationList) {
// if (_valuesStart[property] === undefined) { // handle end values only the first time. NOT NEEDED? setupProperties is now guarded by _propertiesAreSetUp.
_valuesEnd[property] = temp;
// }
}
}

@@ -532,12 +528,17 @@ // handle the deepness of the values

_valuesStart[property] = startValueIsArray ? [] : {};
// eslint-disable-next-line
for (var prop in startValue) {
// eslint-disable-next-line
// @ts-ignore FIXME?
_valuesStart[property][prop] = startValue[prop];
var nestedObject = startValue;
for (var prop in nestedObject) {
_valuesStart[property][prop] = nestedObject[prop];
}
_valuesStartRepeat[property] = startValueIsArray ? [] : {}; // TODO? repeat nested values? And yoyo? And array values?
// eslint-disable-next-line
// @ts-ignore FIXME?
this._setupProperties(startValue, _valuesStart[property], _valuesEnd[property], _valuesStartRepeat[property], overrideStartingValues);
// TODO? repeat nested values? And yoyo? And array values?
_valuesStartRepeat[property] = startValueIsArray ? [] : {};
var endValues = _valuesEnd[property];
// If dynamic is not enabled, clone the end values instead of using the passed-in end values.
if (!this._isDynamic) {
var tmp = {};
for (var prop in endValues)
tmp[prop] = endValues[prop];
_valuesEnd[property] = endValues = tmp;
}
this._setupProperties(nestedObject, _valuesStart[property], endValues, _valuesStartRepeat[property], overrideStartingValues);
}

@@ -588,3 +589,3 @@ else {

Tween.prototype.pause = function (time) {
if (time === void 0) { time = now$1(); }
if (time === void 0) { time = now(); }
if (this._isPaused || !this._isPlaying) {

@@ -600,3 +601,3 @@ return this;

Tween.prototype.resume = function (time) {
if (time === void 0) { time = now$1(); }
if (time === void 0) { time = now(); }
if (!this._isPaused || !this._isPlaying) {

@@ -692,3 +693,3 @@ return this;

Tween.prototype.update = function (time, autoStart) {
if (time === void 0) { time = now$1(); }
if (time === void 0) { time = now(); }
if (autoStart === void 0) { autoStart = true; }

@@ -816,5 +817,3 @@ if (this._isPaused)

}
else {
return parseFloat(end);
}
return parseFloat(end);
};

@@ -835,3 +834,3 @@ Tween.prototype._swapEndStartRepeatValues = function (property) {

var VERSION = '19.0.0';
var VERSION = '20.0.0';

@@ -867,3 +866,3 @@ /**

Interpolation: Interpolation,
now: now$1,
now: now,
Sequence: Sequence,

@@ -890,3 +889,3 @@ nextId: nextId,

exports.nextId = nextId;
exports.now = now$1;
exports.now = now;
exports.remove = remove;

@@ -898,2 +897,2 @@ exports.removeAll = removeAll;

})));
}));
{
"name": "@tweenjs/tween.js",
"description": "Super simple, fast and easy to use tweening engine which incorporates optimised Robert Penner's equations.",
"version": "19.0.0",
"version": "20.0.0",
"type": "module",
"main": "dist/tween.cjs.js",

@@ -35,3 +36,3 @@ "types": "dist/tween.d.ts",

"test": "npm run build && npm run test-lint && npm run test-unit",
"test-unit": "nodeunit test/unit/nodeunitheadless.js",
"test-unit": "nodeunit test/unit/nodeunitheadless.cjs",
"test-lint": "npm run prettier -- --check && eslint 'src/**/*.ts'",

@@ -49,4 +50,2 @@ "lint": "npm run prettier -- --write && eslint 'src/**/*.ts' --fix",

"devDependencies": {
"@sinonjs/fake-timers": "^6.0.1",
"@types/sinonjs__fake-timers": "^6.0.2",
"@typescript-eslint/eslint-plugin": "^3.1.0",

@@ -58,9 +57,9 @@ "@typescript-eslint/parser": "^3.1.0",

"nodeunit": "^0.11.3",
"prettier": "^2.0.0",
"prettier": "2.8.7",
"rimraf": "^3.0.0",
"rollup": "^2.0.0",
"rollup-plugin-dts": "1.4.10",
"rollup": "3.20.7",
"rollup-plugin-dts": "5.3.0",
"tslib": "^1.10.0",
"typescript": "^4.0.0"
"typescript": "5.0.4"
}
}

@@ -103,38 +103,58 @@ # tween.js

<td>
<a href="http://tweenjs.github.io/tween.js/examples/12_graphs_custom_functions.html">
<img src="https://tweenjs.github.io/tween.js/assets/examples/03_graphs.png" alt="Custom functions" />
<a href="http://tweenjs.github.io/tween.js/examples/00_hello_world.html">
<img width="100" height="50" src="https://tweenjs.github.io/tween.js/assets/examples/00_hello_world.png" alt="hello world" />
</a>
</td>
<td>
Custom functions<br />
(<a href="examples/12_graphs_custom_functions.html">source</a>)
hello world<br />
(<a href="examples/00_hello_world.html">source</a>)
</td>
<td>
<a href="http://tweenjs.github.io/tween.js/examples/11_stop_all_chained_tweens.html">
<img src="https://tweenjs.github.io/tween.js/assets/examples/11_stop_all_chained_tweens.png" alt="Stop all chained tweens" />
<a href="http://tweenjs.github.io/tween.js/examples/01_bars.html">
<img width="100" height="50" src="https://tweenjs.github.io/tween.js/assets/examples/01_bars.png" alt="Bars" />
</a>
</td>
<td>
Stop all chained tweens<br />
(<a href="examples/11_stop_all_chained_tweens.html">source</a>)
Bars<br />
(<a href="examples/01_bars.html">source</a>)
</td>
<tr>
</tr>
<td>
<a href="http://tweenjs.github.io/tween.js/examples/02_black_and_red.html">
<img width="100" height="50" src="https://tweenjs.github.io/tween.js/assets/examples/02_black_and_red.png" alt="Black and red" />
</a>
</td>
<td>
Black and red<br />
(<a href="examples/02_black_and_red.html">source</a>)
</td>
<td>
<a href="http://tweenjs.github.io/tween.js/examples/03_graphs.html">
<img width="100" height="50" src="https://tweenjs.github.io/tween.js/assets/examples/03_graphs.png" alt="Graphs" />
</a>
</td>
<td>
Graphs<br />
(<a href="examples/03_graphs.html">source</a>)
</td>
</tr>
<tr>
<td>
<a href="http://tweenjs.github.io/tween.js/examples/10_yoyo.html">
<img src="https://tweenjs.github.io/tween.js/assets/examples/10_yoyo.png" alt="Yoyo" />
<a href="http://tweenjs.github.io/tween.js/examples/04_simplest.html">
<img width="100" height="50" src="https://tweenjs.github.io/tween.js/assets/examples/04_simplest.png" alt="Simplest possible example" />
</a>
</td>
<td>
Yoyo<br />
(<a href="examples/10_yoyo.html">source</a>)
Simplest possible example<br />
(<a href="examples/04_simplest.html">source</a>)
</td>
<td>
<a href="http://tweenjs.github.io/tween.js/examples/09_relative_values.html">
<img src="https://tweenjs.github.io/tween.js/assets/examples/09_relative.png" alt="Relative values" />
<a href="http://tweenjs.github.io/tween.js/examples/05_video_and_time.html">
<img width="100" height="50" src="https://tweenjs.github.io/tween.js/assets/examples/06_video_and_time.png" alt="Video and time" />
</a>
</td>
<td>
Relative values<br />
(<a href="examples/09_relative_values.html">source</a>)
Video and time<br />
(<a href="examples/05_video_and_time.html">source</a>)
</td>

@@ -144,4 +164,44 @@ </tr>

<td>
<a href="http://tweenjs.github.io/tween.js/examples/06_array_interpolation.html">
<img width="100" height="50" src="https://tweenjs.github.io/tween.js/assets/examples/03_graphs.png" alt="Array interpolation" />
</a>
</td>
<td>
Array interpolation<br />
(<a href="examples/06_array_interpolation.html">source</a>)
</td>
<td>
<a href="http://tweenjs.github.io/tween.js/examples/07_dynamic_to.html">
<img width="100" height="50" src="https://tweenjs.github.io/tween.js/assets/examples/07_dynamic_to.png" alt="Dynamic to, object" />
</a>
</td>
<td>
Dynamic to, object<br />
(<a href="examples/07_dynamic_to.html">source</a>)
</td>
</tr>
<tr>
<td>
<a href="http://tweenjs.github.io/tween.js/examples/07a_dynamic_to_two_array_values.html">
<img width="100" height="50" src="https://tweenjs.github.io/tween.js/assets/examples/07a_dynamic_to.png" alt="Dynamic to, interpolation array" />
</a>
</td>
<td>
Dynamic to, interpolation array<br />
(<a href="examples/07a_dynamic_to_two_array_values.html">source</a>)
</td>
<td>
<a href="http://tweenjs.github.io/tween.js/examples/07b_dynamic_to_an_array_of_values.html">
<img width="100" height="50" src="https://tweenjs.github.io/tween.js/assets/examples/07b_dynamic_to.png" alt="Dynamic to, large interpolation array" />
</a>
</td>
<td>
Dynamic to, large interpolation array<br />
(<a href="examples/07b_dynamic_to_an_array_of_values.html">source</a>)
</td>
</tr>
<tr>
<td>
<a href="http://tweenjs.github.io/tween.js/examples/08_repeat.html">
<img src="https://tweenjs.github.io/tween.js/assets/examples/08_repeat.png" alt="Repeat" />
<img width="100" height="50" src="https://tweenjs.github.io/tween.js/assets/examples/08_repeat.png" alt="Repeat" />
</a>

@@ -154,9 +214,9 @@ </td>

<td>
<a href="http://tweenjs.github.io/tween.js/examples/07_dynamic_to.html">
<img src="https://tweenjs.github.io/tween.js/assets/examples/07_dynamic_to.png" alt="Dynamic to" />
<a href="http://tweenjs.github.io/tween.js/examples/09_relative_values.html">
<img width="100" height="50" src="https://tweenjs.github.io/tween.js/assets/examples/09_relative.png" alt="Relative values" />
</a>
</td>
<td>
Dynamic to<br />
(<a href="examples/07_dynamic_to.html">source</a>)
Relative values<br />
(<a href="examples/09_relative_values.html">source</a>)
</td>

@@ -166,18 +226,18 @@ </tr>

<td>
<a href="http://tweenjs.github.io/tween.js/examples/06_array_interpolation.html">
<img src="https://tweenjs.github.io/tween.js/assets/examples/03_graphs.png" alt="Array interpolation" />
<a href="http://tweenjs.github.io/tween.js/examples/10_yoyo.html">
<img width="100" height="50" src="https://tweenjs.github.io/tween.js/assets/examples/10_yoyo.png" alt="Yoyo" />
</a>
</td>
<td>
Array interpolation<br />
(<a href="examples/06_array_interpolation.html">source</a>)
Yoyo<br />
(<a href="examples/10_yoyo.html">source</a>)
</td>
<td>
<a href="http://tweenjs.github.io/tween.js/examples/05_video_and_time.html">
<img src="https://tweenjs.github.io/tween.js/assets/examples/06_video_and_time.png" alt="Video and time" />
<a href="http://tweenjs.github.io/tween.js/examples/11_stop_all_chained_tweens.html">
<img width="100" height="50" src="https://tweenjs.github.io/tween.js/assets/examples/11_stop_all_chained_tweens.png" alt="Stop all chained tweens" />
</a>
</td>
<td>
Video and time<br />
(<a href="examples/05_video_and_time.html">source</a>)
Stop all chained tweens<br />
(<a href="examples/11_stop_all_chained_tweens.html">source</a>)
</td>

@@ -187,18 +247,18 @@ </tr>

<td>
<a href="http://tweenjs.github.io/tween.js/examples/04_simplest.html">
<img src="https://tweenjs.github.io/tween.js/assets/examples/04_simplest.png" alt="Simplest possible example" />
<a href="http://tweenjs.github.io/tween.js/examples/12_graphs_custom_functions.html">
<img width="100" height="50" src="https://tweenjs.github.io/tween.js/assets/examples/03_graphs.png" alt="Custom functions" />
</a>
</td>
<td>
Simplest possible example<br />
(<a href="examples/04_simplest.html">source</a>)
Custom functions<br />
(<a href="examples/12_graphs_custom_functions.html">source</a>)
</td>
<td>
<a href="http://tweenjs.github.io/tween.js/examples/03_graphs.html">
<img src="https://tweenjs.github.io/tween.js/assets/examples/03_graphs.png" alt="Graphs" />
<a href="http://tweenjs.github.io/tween.js/examples/13_relative_start_time.html">
<img width="100" height="50" src="https://tweenjs.github.io/tween.js/assets/examples/13_relative_start_time.png" alt="Relative start time" />
</a>
</td>
<td>
Graphs<br />
(<a href="examples/03_graphs.html">source</a>)
Relative start time<br />
(<a href="examples/13_relative_start_time.html">source</a>)
</td>

@@ -208,18 +268,18 @@ </tr>

<td>
<a href="http://tweenjs.github.io/tween.js/examples/02_black_and_red.html">
<img src="https://tweenjs.github.io/tween.js/assets/examples/02_black_and_red.png" alt="Black and red" />
<a href="http://tweenjs.github.io/tween.js/examples/14_pause_tween.html">
<img width="100" height="50" src="https://tweenjs.github.io/tween.js/assets/examples/14_pause_tween.png" alt="Pause tween" />
</a>
</td>
<td>
Black and red<br />
(<a href="examples/02_black_and_red.html">source</a>)
Pause tween<br />
(<a href="examples/14_pause_tween.html">source</a>)
</td>
<td>
<a href="http://tweenjs.github.io/tween.js/examples/01_bars.html">
<img src="https://tweenjs.github.io/tween.js/assets/examples/01_bars.png" alt="Bars" />
<a href="http://tweenjs.github.io/tween.js/examples/15_complex_properties.html">
<img width="100" height="50" src="https://tweenjs.github.io/tween.js/assets/examples/15_complex_properties.png" alt="Complex properties" />
</a>
</td>
<td>
Bars<br />
(<a href="examples/01_bars.html">source</a>)
Complex properties<br />
(<a href="examples/15_complex_properties.html">source</a>)
</td>

@@ -229,9 +289,9 @@ </tr>

<td>
<a href="http://tweenjs.github.io/tween.js/examples/00_hello_world.html">
<img src="https://tweenjs.github.io/tween.js/assets/examples/00_hello_world.png" alt="hello world" />
<a href="http://tweenjs.github.io/tween.js/examples/16_animate_an_array_of_values.html">
<img width="100" height="50" src="https://tweenjs.github.io/tween.js/assets/examples/16_animate_an_array_of_values.png" alt="Animate an array of values" />
</a>
</td>
<td>
hello world<br />
(<a href="examples/00_hello_world.html">source</a>)
Animate an array of values<br />
(<a href="examples/16_animate_an_array_of_values.html">source</a>)
</td>

@@ -238,0 +298,0 @@ </tr>

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