mirror of
https://github.com/tweenjs/tween.js.git
synced 2026-02-01 17:27:10 +00:00
v18.6.1
This commit is contained in:
parent
3d4c6ded50
commit
f96e971653
273
dist/index.d.ts
vendored
273
dist/index.d.ts
vendored
@ -1,273 +0,0 @@
|
||||
declare module "TWEEN" {
|
||||
|
||||
type EasingFunction = (amount: number) => number;
|
||||
|
||||
/**
|
||||
* The Ease class provides a collection of easing functions for use with tween.js.
|
||||
*/
|
||||
const Easing: {
|
||||
Linear: {
|
||||
None: (amount: number) => number;
|
||||
};
|
||||
Quadratic: {
|
||||
In: (amount: number) => number;
|
||||
Out: (amount: number) => number;
|
||||
InOut: (amount: number) => number;
|
||||
};
|
||||
Cubic: {
|
||||
In: (amount: number) => number;
|
||||
Out: (amount: number) => number;
|
||||
InOut: (amount: number) => number;
|
||||
};
|
||||
Quartic: {
|
||||
In: (amount: number) => number;
|
||||
Out: (amount: number) => number;
|
||||
InOut: (amount: number) => number;
|
||||
};
|
||||
Quintic: {
|
||||
In: (amount: number) => number;
|
||||
Out: (amount: number) => number;
|
||||
InOut: (amount: number) => number;
|
||||
};
|
||||
Sinusoidal: {
|
||||
In: (amount: number) => number;
|
||||
Out: (amount: number) => number;
|
||||
InOut: (amount: number) => number;
|
||||
};
|
||||
Exponential: {
|
||||
In: (amount: number) => number;
|
||||
Out: (amount: number) => number;
|
||||
InOut: (amount: number) => number;
|
||||
};
|
||||
Circular: {
|
||||
In: (amount: number) => number;
|
||||
Out: (amount: number) => number;
|
||||
InOut: (amount: number) => number;
|
||||
};
|
||||
Elastic: {
|
||||
In: (amount: number) => number;
|
||||
Out: (amount: number) => number;
|
||||
InOut: (amount: number) => number;
|
||||
};
|
||||
Back: {
|
||||
In: (amount: number) => number;
|
||||
Out: (amount: number) => number;
|
||||
InOut: (amount: number) => number;
|
||||
};
|
||||
Bounce: {
|
||||
In: (amount: number) => number;
|
||||
Out: (amount: number) => number;
|
||||
InOut: (amount: number) => number;
|
||||
};
|
||||
};
|
||||
|
||||
let NOW: () => number;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
type InterpolationFunction = (v: number[], k: number) => number;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
const Interpolation: {
|
||||
Linear: (v: number[], k: number) => number;
|
||||
Bezier: (v: number[], k: number) => number;
|
||||
CatmullRom: (v: number[], k: number) => number;
|
||||
Utils: {
|
||||
Linear: (p0: number, p1: number, t: number) => number;
|
||||
Bernstein: (n: number, i: number) => number;
|
||||
Factorial: (n: number) => number;
|
||||
CatmullRom: (p0: number, p1: number, p2: number, p3: number, t: number) => number;
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Utils
|
||||
*/
|
||||
class Sequence {
|
||||
private static _nextId;
|
||||
static nextId(): number;
|
||||
}
|
||||
|
||||
const VERSION = "18.5.0";
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
class Main extends Group {
|
||||
version: string;
|
||||
now: () => number;
|
||||
Group: typeof Group;
|
||||
Easing: {
|
||||
Linear: {
|
||||
None: (amount: number) => number;
|
||||
};
|
||||
Quadratic: {
|
||||
In: (amount: number) => number;
|
||||
Out: (amount: number) => number;
|
||||
InOut: (amount: number) => number;
|
||||
};
|
||||
Cubic: {
|
||||
In: (amount: number) => number;
|
||||
Out: (amount: number) => number;
|
||||
InOut: (amount: number) => number;
|
||||
};
|
||||
Quartic: {
|
||||
In: (amount: number) => number;
|
||||
Out: (amount: number) => number;
|
||||
InOut: (amount: number) => number;
|
||||
};
|
||||
Quintic: {
|
||||
In: (amount: number) => number;
|
||||
Out: (amount: number) => number;
|
||||
InOut: (amount: number) => number;
|
||||
};
|
||||
Sinusoidal: {
|
||||
In: (amount: number) => number;
|
||||
Out: (amount: number) => number;
|
||||
InOut: (amount: number) => number;
|
||||
};
|
||||
Exponential: {
|
||||
In: (amount: number) => number;
|
||||
Out: (amount: number) => number;
|
||||
InOut: (amount: number) => number;
|
||||
};
|
||||
Circular: {
|
||||
In: (amount: number) => number;
|
||||
Out: (amount: number) => number;
|
||||
InOut: (amount: number) => number;
|
||||
};
|
||||
Elastic: {
|
||||
In: (amount: number) => number;
|
||||
Out: (amount: number) => number;
|
||||
InOut: (amount: number) => number;
|
||||
};
|
||||
Back: {
|
||||
In: (amount: number) => number;
|
||||
Out: (amount: number) => number;
|
||||
InOut: (amount: number) => number;
|
||||
};
|
||||
Bounce: {
|
||||
In: (amount: number) => number;
|
||||
Out: (amount: number) => number;
|
||||
InOut: (amount: number) => number;
|
||||
};
|
||||
};
|
||||
Interpolation: {
|
||||
Linear: (v: number[], k: number) => number;
|
||||
Bezier: (v: number[], k: number) => number;
|
||||
CatmullRom: (v: number[], k: number) => number;
|
||||
Utils: {
|
||||
Linear: (p0: number, p1: number, t: number) => number;
|
||||
Bernstein: (n: number, i: number) => number;
|
||||
Factorial: (n: number) => number;
|
||||
CatmullRom: (p0: number, p1: number, p2: number, p3: number, t: number) => number;
|
||||
};
|
||||
};
|
||||
nextId: typeof Sequence.nextId;
|
||||
Tween: typeof Tween;
|
||||
}
|
||||
|
||||
const TWEEN: Main;
|
||||
|
||||
/**
|
||||
* 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!
|
||||
*/
|
||||
|
||||
|
||||
|
||||
class Tween<T extends UnknownProps> {
|
||||
private _object;
|
||||
private _group;
|
||||
private _isPaused;
|
||||
private _pauseStart;
|
||||
private _valuesStart;
|
||||
private _valuesEnd;
|
||||
private _valuesStartRepeat;
|
||||
private _duration;
|
||||
private _initialRepeat;
|
||||
private _repeat;
|
||||
private _repeatDelayTime?;
|
||||
private _yoyo;
|
||||
private _isPlaying;
|
||||
private _reversed;
|
||||
private _delayTime;
|
||||
private _startTime;
|
||||
private _easingFunction;
|
||||
private _interpolationFunction;
|
||||
private _chainedTweens;
|
||||
private _onStartCallback?;
|
||||
private _onStartCallbackFired;
|
||||
private _onUpdateCallback?;
|
||||
private _onRepeatCallback?;
|
||||
private _onCompleteCallback?;
|
||||
private _onStopCallback?;
|
||||
private _id;
|
||||
private _isChainStopped;
|
||||
constructor(_object: T, _group?: Group);
|
||||
getId(): number;
|
||||
isPlaying(): boolean;
|
||||
isPaused(): boolean;
|
||||
to(properties: UnknownProps, duration?: number): this;
|
||||
duration(d: number): this;
|
||||
start(time: number): this;
|
||||
private _setupProperties;
|
||||
stop(): this;
|
||||
end(): this;
|
||||
pause(time: number): this;
|
||||
resume(time: number): this;
|
||||
stopChainedTweens(): this;
|
||||
group(group: Group): this;
|
||||
delay(amount: number): this;
|
||||
repeat(times: number): this;
|
||||
repeatDelay(amount: number): this;
|
||||
yoyo(yoyo: boolean): this;
|
||||
easing(easingFunction: EasingFunction): this;
|
||||
interpolation(interpolationFunction: InterpolationFunction): this;
|
||||
chain(...tweens: Array<Tween<UnknownProps>>): this;
|
||||
onStart(callback: (object: T) => void): this;
|
||||
onUpdate(callback: (object: T, elapsed: number) => void): this;
|
||||
onRepeat(callback: (object: T) => void): this;
|
||||
onComplete(callback: (object: T) => void): this;
|
||||
onStop(callback: (object: T) => void): this;
|
||||
update(time: number): boolean;
|
||||
private _updateProperties;
|
||||
private _handleRelativeValue;
|
||||
private _swapEndStartRepeatValues;
|
||||
}
|
||||
|
||||
type UnknownProps = Record<string, unknown>;
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
export default TWEEN;
|
||||
}
|
||||
|
||||
declare module "@tweenjs/tween.js" {
|
||||
import TWEEN from "TWEEN";
|
||||
export = TWEEN;
|
||||
}
|
||||
269
dist/tween.amd.js
vendored
269
dist/tween.amd.js
vendored
@ -1,90 +1,4 @@
|
||||
define(function () { '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;
|
||||
}());
|
||||
define(['exports'], function (exports) { 'use strict';
|
||||
|
||||
/**
|
||||
* The Ease class provides a collection of easing functions for use with tween.js.
|
||||
@ -273,6 +187,92 @@ define(function () { '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;
|
||||
}());
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -366,6 +366,8 @@ define(function () { 'use strict';
|
||||
return Sequence;
|
||||
}());
|
||||
|
||||
var mainGroup = new Group();
|
||||
|
||||
/**
|
||||
* Tween.js - Licensed under the MIT license
|
||||
* https://github.com/tweenjs/tween.js
|
||||
@ -376,7 +378,7 @@ define(function () { 'use strict';
|
||||
*/
|
||||
var Tween = /** @class */ (function () {
|
||||
function Tween(_object, _group) {
|
||||
if (_group === void 0) { _group = TWEEN; }
|
||||
if (_group === void 0) { _group = mainGroup; }
|
||||
this._object = _object;
|
||||
this._group = _group;
|
||||
this._isPaused = false;
|
||||
@ -392,11 +394,11 @@ define(function () { 'use strict';
|
||||
this._reversed = false;
|
||||
this._delayTime = 0;
|
||||
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;
|
||||
}
|
||||
Tween.prototype.getId = function () {
|
||||
@ -409,7 +411,6 @@ define(function () { 'use strict';
|
||||
return this._isPaused;
|
||||
};
|
||||
Tween.prototype.to = function (properties, duration) {
|
||||
// to (properties, duration) {
|
||||
for (var prop in properties) {
|
||||
this._valuesEnd[prop] = properties[prop];
|
||||
}
|
||||
@ -443,8 +444,7 @@ define(function () { 'use strict';
|
||||
this._isPaused = false;
|
||||
this._onStartCallbackFired = false;
|
||||
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;
|
||||
this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat);
|
||||
return this;
|
||||
@ -533,7 +533,7 @@ define(function () { 'use strict';
|
||||
return this;
|
||||
}
|
||||
this._isPaused = true;
|
||||
this._pauseStart = time === undefined ? TWEEN.now() : time;
|
||||
this._pauseStart = time === undefined ? now$1() : time;
|
||||
// eslint-disable-next-line
|
||||
// @ts-ignore FIXME?
|
||||
this._group.remove(this);
|
||||
@ -544,7 +544,7 @@ define(function () { 'use strict';
|
||||
return this;
|
||||
}
|
||||
this._isPaused = false;
|
||||
this._startTime += (time === undefined ? TWEEN.now() : time) - this._pauseStart;
|
||||
this._startTime += (time === undefined ? now$1() : time) - this._pauseStart;
|
||||
this._pauseStart = 0;
|
||||
// eslint-disable-next-line
|
||||
// @ts-ignore FIXME?
|
||||
@ -617,6 +617,7 @@ define(function () { 'use strict';
|
||||
Tween.prototype.update = function (time) {
|
||||
var property;
|
||||
var elapsed;
|
||||
time = time !== undefined ? time : now$1();
|
||||
var endTime = this._startTime + this._duration;
|
||||
if (time > endTime && !this._isPlaying) {
|
||||
return false;
|
||||
@ -746,7 +747,7 @@ define(function () { 'use strict';
|
||||
return Tween;
|
||||
}());
|
||||
|
||||
var VERSION = '18.5.0';
|
||||
var VERSION = '18.6.1';
|
||||
|
||||
/**
|
||||
* Tween.js - Licensed under the MIT license
|
||||
@ -756,42 +757,54 @@ define(function () { 'use strict';
|
||||
* See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors.
|
||||
* Thank you all, you're awesome!
|
||||
*/
|
||||
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;
|
||||
/**
|
||||
* 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 });
|
||||
|
||||
});
|
||||
|
||||
265
dist/tween.cjs.js
vendored
265
dist/tween.cjs.js
vendored
@ -1,90 +1,6 @@
|
||||
'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;
|
||||
}());
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
/**
|
||||
* The Ease class provides a collection of easing functions for use with tween.js.
|
||||
@ -273,6 +189,92 @@ var Easing = {
|
||||
},
|
||||
};
|
||||
|
||||
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;
|
||||
}());
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -366,6 +368,8 @@ var Sequence = /** @class */ (function () {
|
||||
return Sequence;
|
||||
}());
|
||||
|
||||
var mainGroup = new Group();
|
||||
|
||||
/**
|
||||
* Tween.js - Licensed under the MIT license
|
||||
* https://github.com/tweenjs/tween.js
|
||||
@ -376,7 +380,7 @@ var Sequence = /** @class */ (function () {
|
||||
*/
|
||||
var Tween = /** @class */ (function () {
|
||||
function Tween(_object, _group) {
|
||||
if (_group === void 0) { _group = TWEEN; }
|
||||
if (_group === void 0) { _group = mainGroup; }
|
||||
this._object = _object;
|
||||
this._group = _group;
|
||||
this._isPaused = false;
|
||||
@ -392,11 +396,11 @@ var Tween = /** @class */ (function () {
|
||||
this._reversed = false;
|
||||
this._delayTime = 0;
|
||||
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;
|
||||
}
|
||||
Tween.prototype.getId = function () {
|
||||
@ -409,7 +413,6 @@ var Tween = /** @class */ (function () {
|
||||
return this._isPaused;
|
||||
};
|
||||
Tween.prototype.to = function (properties, duration) {
|
||||
// to (properties, duration) {
|
||||
for (var prop in properties) {
|
||||
this._valuesEnd[prop] = properties[prop];
|
||||
}
|
||||
@ -443,8 +446,7 @@ var Tween = /** @class */ (function () {
|
||||
this._isPaused = false;
|
||||
this._onStartCallbackFired = false;
|
||||
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;
|
||||
this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat);
|
||||
return this;
|
||||
@ -533,7 +535,7 @@ var Tween = /** @class */ (function () {
|
||||
return this;
|
||||
}
|
||||
this._isPaused = true;
|
||||
this._pauseStart = time === undefined ? TWEEN.now() : time;
|
||||
this._pauseStart = time === undefined ? now$1() : time;
|
||||
// eslint-disable-next-line
|
||||
// @ts-ignore FIXME?
|
||||
this._group.remove(this);
|
||||
@ -544,7 +546,7 @@ var Tween = /** @class */ (function () {
|
||||
return this;
|
||||
}
|
||||
this._isPaused = false;
|
||||
this._startTime += (time === undefined ? TWEEN.now() : time) - this._pauseStart;
|
||||
this._startTime += (time === undefined ? now$1() : time) - this._pauseStart;
|
||||
this._pauseStart = 0;
|
||||
// eslint-disable-next-line
|
||||
// @ts-ignore FIXME?
|
||||
@ -617,6 +619,7 @@ var Tween = /** @class */ (function () {
|
||||
Tween.prototype.update = function (time) {
|
||||
var property;
|
||||
var elapsed;
|
||||
time = time !== undefined ? time : now$1();
|
||||
var endTime = this._startTime + this._duration;
|
||||
if (time > endTime && !this._isPlaying) {
|
||||
return false;
|
||||
@ -746,7 +749,7 @@ var Tween = /** @class */ (function () {
|
||||
return Tween;
|
||||
}());
|
||||
|
||||
var VERSION = '18.5.0';
|
||||
var VERSION = '18.6.1';
|
||||
|
||||
/**
|
||||
* Tween.js - Licensed under the MIT license
|
||||
@ -756,40 +759,50 @@ var VERSION = '18.5.0';
|
||||
* See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors.
|
||||
* Thank you all, you're awesome!
|
||||
*/
|
||||
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;
|
||||
/**
|
||||
* 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;
|
||||
|
||||
256
dist/tween.d.ts
vendored
Normal file
256
dist/tween.d.ts
vendored
Normal file
@ -0,0 +1,256 @@
|
||||
declare type EasingFunction = (amount: number) => number;
|
||||
/**
|
||||
* The Ease class provides a collection of easing functions for use with tween.js.
|
||||
*/
|
||||
declare const Easing: {
|
||||
Linear: {
|
||||
None: (amount: number) => number;
|
||||
};
|
||||
Quadratic: {
|
||||
In: (amount: number) => number;
|
||||
Out: (amount: number) => number;
|
||||
InOut: (amount: number) => number;
|
||||
};
|
||||
Cubic: {
|
||||
In: (amount: number) => number;
|
||||
Out: (amount: number) => number;
|
||||
InOut: (amount: number) => number;
|
||||
};
|
||||
Quartic: {
|
||||
In: (amount: number) => number;
|
||||
Out: (amount: number) => number;
|
||||
InOut: (amount: number) => number;
|
||||
};
|
||||
Quintic: {
|
||||
In: (amount: number) => number;
|
||||
Out: (amount: number) => number;
|
||||
InOut: (amount: number) => number;
|
||||
};
|
||||
Sinusoidal: {
|
||||
In: (amount: number) => number;
|
||||
Out: (amount: number) => number;
|
||||
InOut: (amount: number) => number;
|
||||
};
|
||||
Exponential: {
|
||||
In: (amount: number) => number;
|
||||
Out: (amount: number) => number;
|
||||
InOut: (amount: number) => number;
|
||||
};
|
||||
Circular: {
|
||||
In: (amount: number) => number;
|
||||
Out: (amount: number) => number;
|
||||
InOut: (amount: number) => number;
|
||||
};
|
||||
Elastic: {
|
||||
In: (amount: number) => number;
|
||||
Out: (amount: number) => number;
|
||||
InOut: (amount: number) => number;
|
||||
};
|
||||
Back: {
|
||||
In: (amount: number) => number;
|
||||
Out: (amount: number) => number;
|
||||
InOut: (amount: number) => number;
|
||||
};
|
||||
Bounce: {
|
||||
In: (amount: number) => number;
|
||||
Out: (amount: number) => number;
|
||||
InOut: (amount: number) => number;
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
declare type InterpolationFunction = (v: number[], k: number) => number;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
declare const Interpolation: {
|
||||
Linear: (v: number[], k: number) => number;
|
||||
Bezier: (v: number[], k: number) => number;
|
||||
CatmullRom: (v: number[], k: number) => number;
|
||||
Utils: {
|
||||
Linear: (p0: number, p1: number, t: number) => number;
|
||||
Bernstein: (n: number, i: number) => number;
|
||||
Factorial: (n: number) => number;
|
||||
CatmullRom: (p0: number, p1: number, p2: number, p3: number, t: number) => number;
|
||||
};
|
||||
};
|
||||
|
||||
declare class Tween<T extends UnknownProps> {
|
||||
private _object;
|
||||
private _group;
|
||||
private _isPaused;
|
||||
private _pauseStart;
|
||||
private _valuesStart;
|
||||
private _valuesEnd;
|
||||
private _valuesStartRepeat;
|
||||
private _duration;
|
||||
private _initialRepeat;
|
||||
private _repeat;
|
||||
private _repeatDelayTime?;
|
||||
private _yoyo;
|
||||
private _isPlaying;
|
||||
private _reversed;
|
||||
private _delayTime;
|
||||
private _startTime;
|
||||
private _easingFunction;
|
||||
private _interpolationFunction;
|
||||
private _chainedTweens;
|
||||
private _onStartCallback?;
|
||||
private _onStartCallbackFired;
|
||||
private _onUpdateCallback?;
|
||||
private _onRepeatCallback?;
|
||||
private _onCompleteCallback?;
|
||||
private _onStopCallback?;
|
||||
private _id;
|
||||
private _isChainStopped;
|
||||
constructor(_object: T, _group?: Group);
|
||||
getId(): number;
|
||||
isPlaying(): boolean;
|
||||
isPaused(): boolean;
|
||||
to(properties: UnknownProps, duration?: number): this;
|
||||
duration(d: number): this;
|
||||
start(time?: number): this;
|
||||
private _setupProperties;
|
||||
stop(): this;
|
||||
end(): this;
|
||||
pause(time: number): this;
|
||||
resume(time: number): this;
|
||||
stopChainedTweens(): this;
|
||||
group(group: Group): this;
|
||||
delay(amount: number): this;
|
||||
repeat(times: number): this;
|
||||
repeatDelay(amount: number): this;
|
||||
yoyo(yoyo: boolean): this;
|
||||
easing(easingFunction: EasingFunction): this;
|
||||
interpolation(interpolationFunction: InterpolationFunction): this;
|
||||
chain(...tweens: Array<Tween<UnknownProps>>): this;
|
||||
onStart(callback: (object: T) => void): this;
|
||||
onUpdate(callback: (object: T, elapsed: number) => void): this;
|
||||
onRepeat(callback: (object: T) => void): this;
|
||||
onComplete(callback: (object: T) => void): this;
|
||||
onStop(callback: (object: T) => void): this;
|
||||
update(time?: number): boolean;
|
||||
private _updateProperties;
|
||||
private _handleRelativeValue;
|
||||
private _swapEndStartRepeatValues;
|
||||
}
|
||||
declare type UnknownProps = Record<string, unknown>;
|
||||
|
||||
/**
|
||||
* 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 let now: () => number;
|
||||
|
||||
/**
|
||||
* Utils
|
||||
*/
|
||||
declare class Sequence {
|
||||
private static _nextId;
|
||||
static nextId(): number;
|
||||
}
|
||||
|
||||
declare const VERSION = "18.6.1";
|
||||
|
||||
declare const nextId: typeof Sequence.nextId;
|
||||
declare const getAll: () => Tween<Record<string, unknown>>[];
|
||||
declare const removeAll: () => void;
|
||||
declare const add: (tween: Tween<Record<string, unknown>>) => void;
|
||||
declare const remove: (tween: Tween<Record<string, unknown>>) => void;
|
||||
declare const update: (time: number, preserve?: boolean | undefined) => boolean;
|
||||
declare const exports: {
|
||||
Easing: {
|
||||
Linear: {
|
||||
None: (amount: number) => number;
|
||||
};
|
||||
Quadratic: {
|
||||
In: (amount: number) => number;
|
||||
Out: (amount: number) => number;
|
||||
InOut: (amount: number) => number;
|
||||
};
|
||||
Cubic: {
|
||||
In: (amount: number) => number;
|
||||
Out: (amount: number) => number;
|
||||
InOut: (amount: number) => number;
|
||||
};
|
||||
Quartic: {
|
||||
In: (amount: number) => number;
|
||||
Out: (amount: number) => number;
|
||||
InOut: (amount: number) => number;
|
||||
};
|
||||
Quintic: {
|
||||
In: (amount: number) => number;
|
||||
Out: (amount: number) => number;
|
||||
InOut: (amount: number) => number;
|
||||
};
|
||||
Sinusoidal: {
|
||||
In: (amount: number) => number;
|
||||
Out: (amount: number) => number;
|
||||
InOut: (amount: number) => number;
|
||||
};
|
||||
Exponential: {
|
||||
In: (amount: number) => number;
|
||||
Out: (amount: number) => number;
|
||||
InOut: (amount: number) => number;
|
||||
};
|
||||
Circular: {
|
||||
In: (amount: number) => number;
|
||||
Out: (amount: number) => number;
|
||||
InOut: (amount: number) => number;
|
||||
};
|
||||
Elastic: {
|
||||
In: (amount: number) => number;
|
||||
Out: (amount: number) => number;
|
||||
InOut: (amount: number) => number;
|
||||
};
|
||||
Back: {
|
||||
In: (amount: number) => number;
|
||||
Out: (amount: number) => number;
|
||||
InOut: (amount: number) => number;
|
||||
};
|
||||
Bounce: {
|
||||
In: (amount: number) => number;
|
||||
Out: (amount: number) => number;
|
||||
InOut: (amount: number) => number;
|
||||
};
|
||||
};
|
||||
Group: typeof Group;
|
||||
Interpolation: {
|
||||
Linear: (v: number[], k: number) => number;
|
||||
Bezier: (v: number[], k: number) => number;
|
||||
CatmullRom: (v: number[], k: number) => number;
|
||||
Utils: {
|
||||
Linear: (p0: number, p1: number, t: number) => number;
|
||||
Bernstein: (n: number, i: number) => number;
|
||||
Factorial: (n: number) => number;
|
||||
CatmullRom: (p0: number, p1: number, p2: number, p3: number, t: number) => number;
|
||||
};
|
||||
};
|
||||
now: () => number;
|
||||
Sequence: typeof Sequence;
|
||||
nextId: typeof Sequence.nextId;
|
||||
Tween: typeof Tween;
|
||||
VERSION: string;
|
||||
getAll: () => Tween<Record<string, unknown>>[];
|
||||
removeAll: () => void;
|
||||
add: (tween: Tween<Record<string, unknown>>) => void;
|
||||
remove: (tween: Tween<Record<string, unknown>>) => void;
|
||||
update: (time: number, preserve?: boolean | undefined) => boolean;
|
||||
};
|
||||
|
||||
export default exports;
|
||||
export { Easing, Group, Interpolation, Sequence, Tween, VERSION, add, getAll, nextId, now, remove, removeAll, update };
|
||||
253
dist/tween.esm.js
vendored
253
dist/tween.esm.js
vendored
@ -1,89 +1,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;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@ -271,6 +185,92 @@ var Easing = {
|
||||
},
|
||||
};
|
||||
|
||||
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;
|
||||
}());
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -364,6 +364,8 @@ var Sequence = /** @class */ (function () {
|
||||
return Sequence;
|
||||
}());
|
||||
|
||||
var mainGroup = new Group();
|
||||
|
||||
/**
|
||||
* Tween.js - Licensed under the MIT license
|
||||
* https://github.com/tweenjs/tween.js
|
||||
@ -374,7 +376,7 @@ var Sequence = /** @class */ (function () {
|
||||
*/
|
||||
var Tween = /** @class */ (function () {
|
||||
function Tween(_object, _group) {
|
||||
if (_group === void 0) { _group = TWEEN; }
|
||||
if (_group === void 0) { _group = mainGroup; }
|
||||
this._object = _object;
|
||||
this._group = _group;
|
||||
this._isPaused = false;
|
||||
@ -390,11 +392,11 @@ var Tween = /** @class */ (function () {
|
||||
this._reversed = false;
|
||||
this._delayTime = 0;
|
||||
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;
|
||||
}
|
||||
Tween.prototype.getId = function () {
|
||||
@ -407,7 +409,6 @@ var Tween = /** @class */ (function () {
|
||||
return this._isPaused;
|
||||
};
|
||||
Tween.prototype.to = function (properties, duration) {
|
||||
// to (properties, duration) {
|
||||
for (var prop in properties) {
|
||||
this._valuesEnd[prop] = properties[prop];
|
||||
}
|
||||
@ -441,8 +442,7 @@ var Tween = /** @class */ (function () {
|
||||
this._isPaused = false;
|
||||
this._onStartCallbackFired = false;
|
||||
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;
|
||||
this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat);
|
||||
return this;
|
||||
@ -531,7 +531,7 @@ var Tween = /** @class */ (function () {
|
||||
return this;
|
||||
}
|
||||
this._isPaused = true;
|
||||
this._pauseStart = time === undefined ? TWEEN.now() : time;
|
||||
this._pauseStart = time === undefined ? now$1() : time;
|
||||
// eslint-disable-next-line
|
||||
// @ts-ignore FIXME?
|
||||
this._group.remove(this);
|
||||
@ -542,7 +542,7 @@ var Tween = /** @class */ (function () {
|
||||
return this;
|
||||
}
|
||||
this._isPaused = false;
|
||||
this._startTime += (time === undefined ? TWEEN.now() : time) - this._pauseStart;
|
||||
this._startTime += (time === undefined ? now$1() : time) - this._pauseStart;
|
||||
this._pauseStart = 0;
|
||||
// eslint-disable-next-line
|
||||
// @ts-ignore FIXME?
|
||||
@ -615,6 +615,7 @@ var Tween = /** @class */ (function () {
|
||||
Tween.prototype.update = function (time) {
|
||||
var property;
|
||||
var elapsed;
|
||||
time = time !== undefined ? time : now$1();
|
||||
var endTime = this._startTime + this._duration;
|
||||
if (time > endTime && !this._isPlaying) {
|
||||
return false;
|
||||
@ -744,7 +745,7 @@ var Tween = /** @class */ (function () {
|
||||
return Tween;
|
||||
}());
|
||||
|
||||
var VERSION = '18.5.0';
|
||||
var VERSION = '18.6.1';
|
||||
|
||||
/**
|
||||
* Tween.js - Licensed under the MIT license
|
||||
@ -754,40 +755,38 @@ var VERSION = '18.5.0';
|
||||
* See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors.
|
||||
* Thank you all, you're awesome!
|
||||
*/
|
||||
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;
|
||||
/**
|
||||
* 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 };
|
||||
|
||||
275
dist/tween.umd.js
vendored
275
dist/tween.umd.js
vendored
@ -1,94 +1,8 @@
|
||||
(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';
|
||||
|
||||
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;
|
||||
}());
|
||||
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';
|
||||
|
||||
/**
|
||||
* The Ease class provides a collection of easing functions for use with tween.js.
|
||||
@ -277,6 +191,92 @@
|
||||
},
|
||||
};
|
||||
|
||||
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;
|
||||
}());
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -370,6 +370,8 @@
|
||||
return Sequence;
|
||||
}());
|
||||
|
||||
var mainGroup = new Group();
|
||||
|
||||
/**
|
||||
* Tween.js - Licensed under the MIT license
|
||||
* https://github.com/tweenjs/tween.js
|
||||
@ -380,7 +382,7 @@
|
||||
*/
|
||||
var Tween = /** @class */ (function () {
|
||||
function Tween(_object, _group) {
|
||||
if (_group === void 0) { _group = TWEEN; }
|
||||
if (_group === void 0) { _group = mainGroup; }
|
||||
this._object = _object;
|
||||
this._group = _group;
|
||||
this._isPaused = false;
|
||||
@ -396,11 +398,11 @@
|
||||
this._reversed = false;
|
||||
this._delayTime = 0;
|
||||
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;
|
||||
}
|
||||
Tween.prototype.getId = function () {
|
||||
@ -413,7 +415,6 @@
|
||||
return this._isPaused;
|
||||
};
|
||||
Tween.prototype.to = function (properties, duration) {
|
||||
// to (properties, duration) {
|
||||
for (var prop in properties) {
|
||||
this._valuesEnd[prop] = properties[prop];
|
||||
}
|
||||
@ -447,8 +448,7 @@
|
||||
this._isPaused = false;
|
||||
this._onStartCallbackFired = false;
|
||||
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;
|
||||
this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat);
|
||||
return this;
|
||||
@ -537,7 +537,7 @@
|
||||
return this;
|
||||
}
|
||||
this._isPaused = true;
|
||||
this._pauseStart = time === undefined ? TWEEN.now() : time;
|
||||
this._pauseStart = time === undefined ? now$1() : time;
|
||||
// eslint-disable-next-line
|
||||
// @ts-ignore FIXME?
|
||||
this._group.remove(this);
|
||||
@ -548,7 +548,7 @@
|
||||
return this;
|
||||
}
|
||||
this._isPaused = false;
|
||||
this._startTime += (time === undefined ? TWEEN.now() : time) - this._pauseStart;
|
||||
this._startTime += (time === undefined ? now$1() : time) - this._pauseStart;
|
||||
this._pauseStart = 0;
|
||||
// eslint-disable-next-line
|
||||
// @ts-ignore FIXME?
|
||||
@ -621,6 +621,7 @@
|
||||
Tween.prototype.update = function (time) {
|
||||
var property;
|
||||
var elapsed;
|
||||
time = time !== undefined ? time : now$1();
|
||||
var endTime = this._startTime + this._duration;
|
||||
if (time > endTime && !this._isPlaying) {
|
||||
return false;
|
||||
@ -750,7 +751,7 @@
|
||||
return Tween;
|
||||
}());
|
||||
|
||||
var VERSION = '18.5.0';
|
||||
var VERSION = '18.6.1';
|
||||
|
||||
/**
|
||||
* Tween.js - Licensed under the MIT license
|
||||
@ -760,42 +761,54 @@
|
||||
* See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors.
|
||||
* Thank you all, you're awesome!
|
||||
*/
|
||||
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;
|
||||
/**
|
||||
* 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 });
|
||||
|
||||
})));
|
||||
|
||||
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@tweenjs/tween.js",
|
||||
"version": "18.6.0",
|
||||
"version": "18.6.1",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"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/tween.d.ts",
|
||||
"module": "dist/tween.esm.js",
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
const VERSION = '18.6.0'
|
||||
const VERSION = '18.6.1'
|
||||
export default VERSION
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user