es6-tween
Advanced tools
Comparing version 0.1.4 to 0.1.5
1057
dist/Tween.js
@@ -6,6 +6,6 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
define([], factory); | ||
else { | ||
var a = factory(); | ||
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; | ||
} | ||
else if(typeof exports === 'object') | ||
exports["TWEEN"] = factory(); | ||
else | ||
root["TWEEN"] = factory(); | ||
})(this, function() { | ||
@@ -77,3 +77,3 @@ return /******/ (function(modules) { // webpackBootstrap | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = 0); | ||
/******/ return __webpack_require__(__webpack_require__.s = 8); | ||
/******/ }) | ||
@@ -86,106 +86,524 @@ /************************************************************************/ | ||
"use strict"; | ||
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var Easing = { | ||
// TWEEN.js | ||
var _tweens = []; | ||
var _time = 0; | ||
var isStarted = false; | ||
var _autoPlay = false; | ||
var _tick = void 0; | ||
Linear: { | ||
None: function None(k) { | ||
var autoStart = function autoStart(time) { | ||
if (TWEEN.update(_time)) { | ||
_time = time; | ||
_tick = requestAnimationFrame(autoStart); | ||
} else { | ||
isStarted = false; | ||
cancelAnimationFrame(_tick); | ||
} | ||
}; | ||
return k; | ||
} | ||
}, | ||
var TWEEN = function () { | ||
function TWEEN() { | ||
_classCallCheck(this, TWEEN); | ||
} | ||
Quadratic: { | ||
In: function In(k) { | ||
_createClass(TWEEN, null, [{ | ||
key: "getAll", | ||
value: function getAll() { | ||
return _tweens; | ||
return k * k; | ||
}, | ||
Out: function Out(k) { | ||
return k * (2 - k); | ||
}, | ||
InOut: function InOut(k) { | ||
if ((k *= 2) < 1) { | ||
return 0.5 * k * k; | ||
} | ||
return -0.5 * (--k * (k - 2) - 1); | ||
} | ||
}, { | ||
key: "autoPlay", | ||
value: function autoPlay(state) { | ||
_autoPlay = state; | ||
}, | ||
Cubic: { | ||
In: function In(k) { | ||
return k * k * k; | ||
}, | ||
Out: function Out(k) { | ||
return --k * k * k + 1; | ||
}, | ||
InOut: function InOut(k) { | ||
if ((k *= 2) < 1) { | ||
return 0.5 * k * k * k; | ||
} | ||
return 0.5 * ((k -= 2) * k * k + 2); | ||
} | ||
}, { | ||
key: "removeAll", | ||
value: function removeAll() { | ||
_tweens = []; | ||
}, | ||
Quartic: { | ||
In: function In(k) { | ||
return k * k * k * k; | ||
}, | ||
Out: function Out(k) { | ||
return 1 - --k * k * k * k; | ||
}, | ||
InOut: function InOut(k) { | ||
if ((k *= 2) < 1) { | ||
return 0.5 * k * k * k * k; | ||
} | ||
return -0.5 * ((k -= 2) * k * k * k - 2); | ||
} | ||
}, { | ||
key: "add", | ||
value: function add(tween) { | ||
_tweens.push(tween); | ||
}, | ||
if (_autoPlay && !isStarted) { | ||
autoStart(TWEEN.now()); | ||
isStarted = true; | ||
Quintic: { | ||
In: function In(k) { | ||
return k * k * k * k * k; | ||
}, | ||
Out: function Out(k) { | ||
return --k * k * k * k * k + 1; | ||
}, | ||
InOut: function InOut(k) { | ||
if ((k *= 2) < 1) { | ||
return 0.5 * k * k * k * k * k; | ||
} | ||
return 0.5 * ((k -= 2) * k * k * k * k + 2); | ||
} | ||
}, { | ||
key: "remove", | ||
value: function remove(tween) { | ||
_tweens.filter(function (tweens) { | ||
return tweens !== tween; | ||
}); | ||
}, | ||
Sinusoidal: { | ||
In: function In(k) { | ||
return 1 - Math.cos(k * Math.PI / 2); | ||
}, | ||
Out: function Out(k) { | ||
return Math.sin(k * Math.PI / 2); | ||
}, | ||
InOut: function InOut(k) { | ||
return 0.5 * (1 - Math.cos(Math.PI * k)); | ||
} | ||
}, { | ||
key: "now", | ||
value: function now() { | ||
return _time; | ||
}, | ||
Exponential: { | ||
In: function In(k) { | ||
return k === 0 ? 0 : Math.pow(1024, k - 1); | ||
}, | ||
Out: function Out(k) { | ||
return k === 1 ? 1 : 1 - Math.pow(-10 * k, 2); | ||
}, | ||
InOut: function InOut(k) { | ||
if (k === 0) { | ||
return 0; | ||
} | ||
if (k === 1) { | ||
return 1; | ||
} | ||
if ((k *= 2) < 1) { | ||
return 0.5 * Math.pow(1024, k - 1); | ||
} | ||
return 0.5 * (-Math.pow(-10 * (k - 1), 2) + 2); | ||
} | ||
}, { | ||
key: "update", | ||
value: function update(time, preserve) { | ||
}, | ||
time = time !== undefined ? time : TWEEN.now(); | ||
Circular: { | ||
In: function In(k) { | ||
_time = time; | ||
return 1 - Math.sqrt(1 - k * k); | ||
}, | ||
Out: function Out(k) { | ||
if (_tweens.length === 0) { | ||
return Math.sqrt(1 - --k * k); | ||
}, | ||
InOut: function InOut(k) { | ||
return false; | ||
if ((k *= 2) < 1) { | ||
return -0.5 * (Math.sqrt(1 - k * k) - 1); | ||
} | ||
var i = 0; | ||
return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1); | ||
} | ||
}, | ||
while (i < _tweens.length) { | ||
Elastic: { | ||
In: function In(k) { | ||
if (_tweens[i].update(time) || preserve) { | ||
i++; | ||
} else { | ||
_tweens.splice(i, 1); | ||
} | ||
if (k === 0) { | ||
return 0; | ||
} | ||
return true; | ||
if (k === 1) { | ||
return 1; | ||
} | ||
return -Math.pow(10 * (k - 1), 2) * Math.sin((k - 1.1) * 5 * Math.PI); | ||
}, | ||
Out: function Out(k) { | ||
if (k === 0) { | ||
return 0; | ||
} | ||
if (k === 1) { | ||
return 1; | ||
} | ||
return Math.pow(-10 * k, 2) * Math.sin((k - 0.1) * 5 * Math.PI) + 1; | ||
}, | ||
InOut: function InOut(k) { | ||
if (k === 0) { | ||
return 0; | ||
} | ||
if (k === 1) { | ||
return 1; | ||
} | ||
k *= 2; | ||
if (k < 1) { | ||
return -0.5 * Math.pow(10 * (k - 1), 2) * Math.sin((k - 1.1) * 5 * Math.PI); | ||
} | ||
return 0.5 * Math.pow(-10 * (k - 1), 2) * Math.sin((k - 1.1) * 5 * Math.PI) + 1; | ||
} | ||
}]); | ||
}, | ||
return TWEEN; | ||
Back: { | ||
In: function In(k) { | ||
var s = 1.70158; | ||
return k * k * ((s + 1) * k - s); | ||
}, | ||
Out: function Out(k) { | ||
var s = 1.70158; | ||
return --k * k * ((s + 1) * k + s) + 1; | ||
}, | ||
InOut: function InOut(k) { | ||
var s = 1.70158 * 1.525; | ||
if ((k *= 2) < 1) { | ||
return 0.5 * (k * k * ((s + 1) * k - s)); | ||
} | ||
return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2); | ||
} | ||
}, | ||
Bounce: { | ||
In: function In(k) { | ||
return 1 - Easing.Bounce.Out(1 - k); | ||
}, | ||
Out: function Out(k) { | ||
if (k < 1 / 2.75) { | ||
return 7.5625 * k * k; | ||
} else if (k < 2 / 2.75) { | ||
return 7.5625 * (k -= 1.5 / 2.75) * k + 0.75; | ||
} else if (k < 2.5 / 2.75) { | ||
return 7.5625 * (k -= 2.25 / 2.75) * k + 0.9375; | ||
} else { | ||
return 7.5625 * (k -= 2.625 / 2.75) * k + 0.984375; | ||
} | ||
}, | ||
InOut: function InOut(k) { | ||
if (k < 0.5) { | ||
return Easing.Bounce.In(k * 2) * 0.5; | ||
} | ||
return Easing.Bounce.Out(k * 2 - 1) * 0.5 + 0.5; | ||
} | ||
} | ||
}; | ||
exports.default = Easing; | ||
/***/ }), | ||
/* 1 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var Interpolation = { | ||
Linear: function Linear(v, k) { | ||
var m = v.length - 1; | ||
var f = m * k; | ||
var i = Math.floor(f); | ||
var fn = Interpolation.Utils.Linear; | ||
if (k < 0) { | ||
return fn(v[0], v[1], f); | ||
} | ||
if (k > 1) { | ||
return fn(v[m], v[m - 1], m - f); | ||
} | ||
return fn(v[i], v[i + 1 > m ? m : i + 1], f - i); | ||
}, | ||
Bezier: function Bezier(v, k) { | ||
var b = 0; | ||
var n = v.length - 1; | ||
var pw = Math.pow; | ||
var bn = Interpolation.Utils.Bernstein; | ||
for (var i = 0; i <= n; i++) { | ||
b += pw(1 - k, n - i) * pw(k, i) * v[i] * bn(n, i); | ||
} | ||
return b; | ||
}, | ||
CatmullRom: function CatmullRom(v, k) { | ||
var m = v.length - 1; | ||
var f = m * k; | ||
var i = Math.floor(f); | ||
var fn = Interpolation.Utils.CatmullRom; | ||
if (v[0] === v[m]) { | ||
if (k < 0) { | ||
i = Math.floor(f = m * (1 + k)); | ||
} | ||
return fn(v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m], f - i); | ||
} else { | ||
if (k < 0) { | ||
return v[0] - (fn(v[0], v[0], v[1], v[1], -f) - v[0]); | ||
} | ||
if (k > 1) { | ||
return v[m] - (fn(v[m], v[m], v[m - 1], v[m - 1], f - m) - v[m]); | ||
} | ||
return fn(v[i ? i - 1 : 0], v[i], v[m < i + 1 ? m : i + 1], v[m < i + 2 ? m : i + 2], f - i); | ||
} | ||
}, | ||
Utils: { | ||
Linear: function Linear(p0, p1, t) { | ||
return (p1 - p0) * t + p0; | ||
}, | ||
Bernstein: function Bernstein(n, i) { | ||
var fc = Interpolation.Utils.Factorial; | ||
return fc(n) / fc(i) / fc(n - i); | ||
}, | ||
Factorial: function () { | ||
var a = [1]; | ||
return function (n) { | ||
var s = 1; | ||
if (a[n]) { | ||
return a[n]; | ||
} | ||
for (var i = n; i > 1; i--) { | ||
s *= i; | ||
} | ||
a[n] = s; | ||
return s; | ||
}; | ||
}(), | ||
CatmullRom: function CatmullRom(p0, p1, p2, p3, t) { | ||
var v0 = (p2 - p0) * 0.5; | ||
var v1 = (p3 - p1) * 0.5; | ||
var t2 = t * t; | ||
var t3 = t * t2; | ||
return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1; | ||
} | ||
} | ||
}; | ||
exports.default = Interpolation; | ||
/***/ }), | ||
/* 2 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
// TWEEN.js | ||
var _tweens = []; | ||
var _time = 0; | ||
var isStarted = false; | ||
var _autoPlay = false; | ||
var _tick = void 0; | ||
var getAll = function getAll() { | ||
return _tweens; | ||
}; | ||
var autoPlay = function autoPlay(state) { | ||
_autoPlay = state; | ||
}; | ||
var removeAll = function removeAll() { | ||
_tweens = []; | ||
}; | ||
var add = function add(tween) { | ||
_tweens.push(tween); | ||
if (_autoPlay && !isStarted) { | ||
autoStart(now()); | ||
isStarted = true; | ||
} | ||
}; | ||
var remove = function remove(tween) { | ||
_tweens.filter(function (tweens) { | ||
return tweens !== tween; | ||
}); | ||
}; | ||
var now = function now() { | ||
return _time; | ||
}; | ||
var update = function update(time, preserve) { | ||
time = time !== undefined ? time : now(); | ||
_time = time; | ||
if (_tweens.length === 0) { | ||
return false; | ||
} | ||
var i = 0; | ||
while (i < _tweens.length) { | ||
if (_tweens[i].update(time) || preserve) { | ||
i++; | ||
} else { | ||
_tweens.splice(i, 1); | ||
} | ||
} | ||
return true; | ||
}; | ||
function autoStart(time) { | ||
if (update(_time)) { | ||
_time = time; | ||
_tick = requestAnimationFrame(autoStart); | ||
} else { | ||
isStarted = false; | ||
cancelAnimationFrame(_tick); | ||
} | ||
} | ||
exports.getAll = getAll; | ||
exports.removeAll = removeAll; | ||
exports.remove = remove; | ||
exports.add = add; | ||
exports.now = now; | ||
exports.update = update; | ||
exports.autoPlay = autoPlay; | ||
/***/ }), | ||
/* 3 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var g; | ||
// This works in non-strict mode | ||
g = function () { | ||
return this; | ||
}(); | ||
// TWEEN.Tween.js | ||
try { | ||
// This works if eval is allowed (see CSP) | ||
g = g || Function("return this")() || (1, eval)("this"); | ||
} catch (e) { | ||
// This works if the window reference is available | ||
if ((typeof window === "undefined" ? "undefined" : _typeof(window)) === "object") g = window; | ||
} | ||
// g can still be undefined, but nothing to do about it... | ||
// We return undefined, instead of nothing here, so it's | ||
// easier to handle this case. if(!global) { ...} | ||
TWEEN.Tween = function () { | ||
function _class() { | ||
module.exports = g; | ||
/***/ }), | ||
/* 4 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _core = __webpack_require__(2); | ||
var _Easing = __webpack_require__(0); | ||
var _Easing2 = _interopRequireDefault(_Easing); | ||
var _Interpolation = __webpack_require__(1); | ||
var _Interpolation2 = _interopRequireDefault(_Interpolation); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var Tween = function () { | ||
function Tween() { | ||
var object = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
_classCallCheck(this, _class); | ||
_classCallCheck(this, Tween); | ||
@@ -217,4 +635,4 @@ this.object = object; | ||
_createClass(_class, [{ | ||
key: "emit", | ||
_createClass(Tween, [{ | ||
key: 'emit', | ||
value: function emit(name, fn, a2, a3, a4) { | ||
@@ -230,3 +648,3 @@ | ||
}, { | ||
key: "pause", | ||
key: 'pause', | ||
value: function pause() { | ||
@@ -246,3 +664,3 @@ | ||
}, { | ||
key: "play", | ||
key: 'play', | ||
value: function play() { | ||
@@ -263,3 +681,3 @@ | ||
}, { | ||
key: "duration", | ||
key: 'duration', | ||
value: function duration(amount) { | ||
@@ -272,3 +690,3 @@ | ||
}, { | ||
key: "to", | ||
key: 'to', | ||
value: function to() { | ||
@@ -285,3 +703,3 @@ var properties = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
}, { | ||
key: "start", | ||
key: 'start', | ||
value: function start(time) { | ||
@@ -304,3 +722,3 @@ var _startTime = this._startTime, | ||
}, { | ||
key: "stop", | ||
key: 'stop', | ||
value: function stop() { | ||
@@ -323,3 +741,3 @@ var _isPlaying = this._isPlaying, | ||
}, { | ||
key: "end", | ||
key: 'end', | ||
value: function end() { | ||
@@ -333,3 +751,3 @@ var _startTime = this._startTime, | ||
}, { | ||
key: "stopChainedTweens", | ||
key: 'stopChainedTweens', | ||
value: function stopChainedTweens() { | ||
@@ -346,3 +764,3 @@ var _chainedTweens = this._chainedTweens; | ||
}, { | ||
key: "delay", | ||
key: 'delay', | ||
value: function delay(amount) { | ||
@@ -355,3 +773,3 @@ | ||
}, { | ||
key: "repeat", | ||
key: 'repeat', | ||
value: function repeat(times) { | ||
@@ -364,3 +782,3 @@ | ||
}, { | ||
key: "repeatDelay", | ||
key: 'repeatDelay', | ||
value: function repeatDelay(amount) { | ||
@@ -373,3 +791,3 @@ | ||
}, { | ||
key: "yoyo", | ||
key: 'yoyo', | ||
value: function yoyo(state) { | ||
@@ -382,3 +800,3 @@ | ||
}, { | ||
key: "easing", | ||
key: 'easing', | ||
value: function easing(fn) { | ||
@@ -391,3 +809,3 @@ | ||
}, { | ||
key: "interpolation", | ||
key: 'interpolation', | ||
value: function interpolation(fn) { | ||
@@ -400,3 +818,3 @@ | ||
}, { | ||
key: "chain", | ||
key: 'chain', | ||
value: function chain() { | ||
@@ -412,3 +830,3 @@ for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
}, { | ||
key: "update", | ||
key: 'update', | ||
value: function update(time) { | ||
@@ -537,379 +955,172 @@ var _onUpdateCallback = this._onUpdateCallback, | ||
return _class; | ||
return Tween; | ||
}(); | ||
TWEEN.Easing = { | ||
exports.default = Tween; | ||
Linear: { | ||
None: function None(k) { | ||
/***/ }), | ||
/* 5 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
return k; | ||
} | ||
}, | ||
"use strict"; | ||
Quadratic: { | ||
In: function In(k) { | ||
return k * k; | ||
}, | ||
Out: function Out(k) { | ||
if (Object.assign === undefined) { | ||
Object.assign = function () { | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return k * (2 - k); | ||
}, | ||
InOut: function InOut(k) { | ||
var first = args.shift(); | ||
args.map(function (obj) { | ||
for (var p in obj) { | ||
first[p] = obj[p]; | ||
} | ||
}); | ||
return first; | ||
}; | ||
} | ||
if ((k *= 2) < 1) { | ||
return 0.5 * k * k; | ||
} | ||
/***/ }), | ||
/* 6 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
return -0.5 * (--k * (k - 2) - 1); | ||
} | ||
}, | ||
"use strict"; | ||
/* WEBPACK VAR INJECTION */(function(global) { | ||
Cubic: { | ||
In: function In(k) { | ||
var ROOT = typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : undefined; | ||
var _vendor = ['webkit', 'moz', 'ms', 'o']; | ||
var animFrame = 'AnimationFrame'; | ||
var rafSuffixForVendor = 'Request' + animFrame; | ||
var cafSuffixForVendor = 'Cancel' + animFrame; | ||
var cafSuffixForVendor2 = 'CancelRequest' + animFrame; | ||
var _timeout = setTimeout; | ||
var _clearTimeout = clearTimeout; | ||
return k * k * k; | ||
}, | ||
Out: function Out(k) { | ||
if (ROOT.requestAnimationFrame === undefined) { | ||
return --k * k * k + 1; | ||
}, | ||
InOut: function InOut(k) { | ||
var _raf = void 0, | ||
now = void 0, | ||
lastTime = Date.now(), | ||
frameMs = 50 / 3, | ||
fpsSec = frameMs; | ||
if ((k *= 2) < 1) { | ||
return 0.5 * k * k * k; | ||
} | ||
_vendor.map(function (vendor) { | ||
if ((_raf = ROOT[vendor + rafSuffixForVendor]) === undefined) { | ||
_raf = function _raf(fn) { | ||
return _timeout(function () { | ||
now = Date.now(); | ||
fn(now - lastTime); | ||
fpsSec = frameMs + (Date.now() - now); | ||
}, fpsSec); | ||
}; | ||
} | ||
}); | ||
return 0.5 * ((k -= 2) * k * k + 2); | ||
} | ||
}, | ||
if (_raf !== undefined) { | ||
ROOT.requestAnimationFrame = _raf; | ||
} | ||
} | ||
Quartic: { | ||
In: function In(k) { | ||
if (ROOT.cancelAnimationFrame === undefined) { | ||
var _caf = void 0; | ||
return k * k * k * k; | ||
}, | ||
Out: function Out(k) { | ||
return 1 - --k * k * k * k; | ||
}, | ||
InOut: function InOut(k) { | ||
if ((k *= 2) < 1) { | ||
return 0.5 * k * k * k * k; | ||
} | ||
return -0.5 * ((k -= 2) * k * k * k - 2); | ||
} | ||
}, | ||
Quintic: { | ||
In: function In(k) { | ||
return k * k * k * k * k; | ||
}, | ||
Out: function Out(k) { | ||
return --k * k * k * k * k + 1; | ||
}, | ||
InOut: function InOut(k) { | ||
if ((k *= 2) < 1) { | ||
return 0.5 * k * k * k * k * k; | ||
} | ||
return 0.5 * ((k -= 2) * k * k * k * k + 2); | ||
} | ||
}, | ||
Sinusoidal: { | ||
In: function In(k) { | ||
return 1 - Math.cos(k * Math.PI / 2); | ||
}, | ||
Out: function Out(k) { | ||
return Math.sin(k * Math.PI / 2); | ||
}, | ||
InOut: function InOut(k) { | ||
return 0.5 * (1 - Math.cos(Math.PI * k)); | ||
} | ||
}, | ||
Exponential: { | ||
In: function In(k) { | ||
return k === 0 ? 0 : Math.pow(1024, k - 1); | ||
}, | ||
Out: function Out(k) { | ||
return k === 1 ? 1 : 1 - Math.pow(-10 * k, 2); | ||
}, | ||
InOut: function InOut(k) { | ||
if (k === 0) { | ||
return 0; | ||
} | ||
if (k === 1) { | ||
return 1; | ||
} | ||
if ((k *= 2) < 1) { | ||
return 0.5 * Math.pow(1024, k - 1); | ||
} | ||
return 0.5 * (-Math.pow(-10 * (k - 1), 2) + 2); | ||
} | ||
}, | ||
Circular: { | ||
In: function In(k) { | ||
return 1 - Math.sqrt(1 - k * k); | ||
}, | ||
Out: function Out(k) { | ||
return Math.sqrt(1 - --k * k); | ||
}, | ||
InOut: function InOut(k) { | ||
if ((k *= 2) < 1) { | ||
return -0.5 * (Math.sqrt(1 - k * k) - 1); | ||
} | ||
return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1); | ||
} | ||
}, | ||
Elastic: { | ||
In: function In(k) { | ||
if (k === 0) { | ||
return 0; | ||
} | ||
if (k === 1) { | ||
return 1; | ||
} | ||
return -Math.pow(10 * (k - 1), 2) * Math.sin((k - 1.1) * 5 * Math.PI); | ||
}, | ||
Out: function Out(k) { | ||
if (k === 0) { | ||
return 0; | ||
} | ||
if (k === 1) { | ||
return 1; | ||
} | ||
return Math.pow(-10 * k, 2) * Math.sin((k - 0.1) * 5 * Math.PI) + 1; | ||
}, | ||
InOut: function InOut(k) { | ||
if (k === 0) { | ||
return 0; | ||
} | ||
if (k === 1) { | ||
return 1; | ||
} | ||
k *= 2; | ||
if (k < 1) { | ||
return -0.5 * Math.pow(10 * (k - 1), 2) * Math.sin((k - 1.1) * 5 * Math.PI); | ||
} | ||
return 0.5 * Math.pow(-10 * (k - 1), 2) * Math.sin((k - 1.1) * 5 * Math.PI) + 1; | ||
} | ||
}, | ||
Back: { | ||
In: function In(k) { | ||
var s = 1.70158; | ||
return k * k * ((s + 1) * k - s); | ||
}, | ||
Out: function Out(k) { | ||
var s = 1.70158; | ||
return --k * k * ((s + 1) * k + s) + 1; | ||
}, | ||
InOut: function InOut(k) { | ||
var s = 1.70158 * 1.525; | ||
if ((k *= 2) < 1) { | ||
return 0.5 * (k * k * ((s + 1) * k - s)); | ||
} | ||
return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2); | ||
} | ||
}, | ||
Bounce: { | ||
In: function In(k) { | ||
return 1 - TWEEN.Easing.Bounce.Out(1 - k); | ||
}, | ||
Out: function Out(k) { | ||
if (k < 1 / 2.75) { | ||
return 7.5625 * k * k; | ||
} else if (k < 2 / 2.75) { | ||
return 7.5625 * (k -= 1.5 / 2.75) * k + 0.75; | ||
} else if (k < 2.5 / 2.75) { | ||
return 7.5625 * (k -= 2.25 / 2.75) * k + 0.9375; | ||
} else { | ||
return 7.5625 * (k -= 2.625 / 2.75) * k + 0.984375; | ||
} | ||
}, | ||
InOut: function InOut(k) { | ||
if (k < 0.5) { | ||
return TWEEN.Easing.Bounce.In(k * 2) * 0.5; | ||
} | ||
return TWEEN.Easing.Bounce.Out(k * 2 - 1) * 0.5 + 0.5; | ||
} | ||
_vendor.map(function (vendor) { | ||
if ((_caf = ROOT[vendor + cafSuffixForVendor]) === undefined && (_caf = ROOT[vendor + cafSuffixForVendor2]) === undefined) { | ||
_caf = function _caf(fn) { | ||
return _clearTimeout(fn); | ||
}; | ||
} | ||
}); | ||
}; | ||
if (_caf !== undefined) { | ||
ROOT.cancelAnimationFrame = _caf; | ||
} | ||
} | ||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3))) | ||
TWEEN.Interpolation = { | ||
Linear: function Linear(v, k) { | ||
/***/ }), | ||
/* 7 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var m = v.length - 1; | ||
var f = m * k; | ||
var i = Math.floor(f); | ||
var fn = TWEEN.Interpolation.Utils.Linear; | ||
"use strict"; | ||
/* WEBPACK VAR INJECTION */(function(global) { | ||
if (k < 0) { | ||
return fn(v[0], v[1], f); | ||
} | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
if (k > 1) { | ||
return fn(v[m], v[m - 1], m - f); | ||
} | ||
var ROOT = typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : undefined; | ||
return fn(v[i], v[i + 1 > m ? m : i + 1], f - i); | ||
}, | ||
Bezier: function Bezier(v, k) { | ||
if (ROOT.Map === undefined) { | ||
ROOT.Map = function Map() { | ||
_classCallCheck(this, Map); | ||
var b = 0; | ||
var n = v.length - 1; | ||
var pw = Math.pow; | ||
var bn = TWEEN.Interpolation.Utils.Bernstein; | ||
var _obj = {}; | ||
for (var i = 0; i <= n; i++) { | ||
b += pw(1 - k, n - i) * pw(k, i) * v[i] * bn(n, i); | ||
} | ||
this.set = function (property, value) { | ||
return b; | ||
}, | ||
CatmullRom: function CatmullRom(v, k) { | ||
_obj[property] = value; | ||
var m = v.length - 1; | ||
var f = m * k; | ||
var i = Math.floor(f); | ||
var fn = TWEEN.Interpolation.Utils.CatmullRom; | ||
return this; | ||
}; | ||
if (v[0] === v[m]) { | ||
this.get = function (property) { | ||
if (k < 0) { | ||
i = Math.floor(f = m * (1 + k)); | ||
} | ||
return _obj[property]; | ||
}; | ||
return fn(v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m], f - i); | ||
} else { | ||
this.has = function (property) { | ||
if (k < 0) { | ||
return v[0] - (fn(v[0], v[0], v[1], v[1], -f) - v[0]); | ||
} | ||
return this.get(property) !== undefined; | ||
}; | ||
if (k > 1) { | ||
return v[m] - (fn(v[m], v[m], v[m - 1], v[m - 1], f - m) - v[m]); | ||
} | ||
return this; | ||
}; | ||
} | ||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3))) | ||
return fn(v[i ? i - 1 : 0], v[i], v[m < i + 1 ? m : i + 1], v[m < i + 2 ? m : i + 2], f - i); | ||
} | ||
}, | ||
/***/ }), | ||
/* 8 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Utils: { | ||
Linear: function Linear(p0, p1, t) { | ||
return (p1 - p0) * t + p0; | ||
}, | ||
Bernstein: function Bernstein(n, i) { | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.Interpolation = exports.Easing = exports.Tween = exports.now = exports.autoPlay = exports.update = exports.remove = exports.removeAll = exports.add = exports.getAll = undefined; | ||
var fc = TWEEN.Interpolation.Utils.Factorial; | ||
__webpack_require__(5); | ||
return fc(n) / fc(i) / fc(n - i); | ||
}, | ||
__webpack_require__(6); | ||
__webpack_require__(7); | ||
Factorial: function () { | ||
var _core = __webpack_require__(2); | ||
var a = [1]; | ||
var _Easing = __webpack_require__(0); | ||
return function (n) { | ||
var _Easing2 = _interopRequireDefault(_Easing); | ||
var s = 1; | ||
var _Tween = __webpack_require__(4); | ||
if (a[n]) { | ||
return a[n]; | ||
} | ||
var _Tween2 = _interopRequireDefault(_Tween); | ||
for (var i = n; i > 1; i--) { | ||
s *= i; | ||
} | ||
var _Interpolation = __webpack_require__(1); | ||
a[n] = s; | ||
return s; | ||
}; | ||
}(), | ||
var _Interpolation2 = _interopRequireDefault(_Interpolation); | ||
CatmullRom: function CatmullRom(p0, p1, p2, p3, t) { | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var v0 = (p2 - p0) * 0.5; | ||
var v1 = (p3 - p1) * 0.5; | ||
var t2 = t * t; | ||
var t3 = t * t2; | ||
exports.getAll = _core.getAll; | ||
exports.add = _core.add; | ||
exports.removeAll = _core.removeAll; | ||
exports.remove = _core.remove; | ||
exports.update = _core.update; | ||
exports.autoPlay = _core.autoPlay; | ||
exports.now = _core.now; | ||
exports.Tween = _Tween2.default; | ||
exports.Easing = _Easing2.default; | ||
exports.Interpolation = _Interpolation2.default; | ||
return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1; | ||
} | ||
} | ||
}; | ||
// AMD/RequireJS | ||
if (true) { | ||
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function () { | ||
return TWEEN; | ||
}.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), | ||
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); | ||
// NodeJS | ||
} else if (typeof module !== "undefined" && module.exports) { | ||
module.exports = TWEEN; | ||
// Browser | ||
} else if (typeof window !== "undefined" && window.document) { | ||
window.TWEEN = TWEEN; | ||
// WebWorker | ||
} else if (typeof self !== "undefined" && self.importScripts !== undefined) { | ||
self.TWEEN = TWEEN; | ||
// On somecase (on TV with QT (JS compiler) this worked) | ||
} else if (typeof exports !== "undefined" && typeof global !== "undefined") { | ||
exports.TWEEN = Tween; | ||
// Else somewhere | ||
} else if (typeof undefined !== "undefined") { | ||
undefined.TWEEN = TWEEN; | ||
} | ||
/***/ }) | ||
@@ -916,0 +1127,0 @@ /******/ ]); |
@@ -1,1 +0,1 @@ | ||
!function(t,n){if("object"==typeof exports&&"object"==typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else{var e=n();for(var i in e)("object"==typeof exports?exports:t)[i]=e[i]}}(this,function(){return function(t){function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}var e={};return n.m=t,n.c=e,n.i=function(t){return t},n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:i})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},n.p="",n(n.s=0)}([function(t,n,e){"use strict";function i(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}var r,u,a=function(){function t(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(n,e,i){return e&&t(n.prototype,e),i&&t(n,i),n}}(),o=[],s=0,h=!1,c=!1,l=void 0,f=function t(n){p.update(s)?(s=n,l=requestAnimationFrame(t)):(h=!1,cancelAnimationFrame(l))},p=function(){function t(){i(this,t)}return a(t,null,[{key:"getAll",value:function(){return o}},{key:"autoPlay",value:function(t){c=t}},{key:"removeAll",value:function(){o=[]}},{key:"add",value:function(n){o.push(n),c&&!h&&(f(t.now()),h=!0)}},{key:"remove",value:function(t){o.filter(function(n){return n!==t})}},{key:"now",value:function(){return s}},{key:"update",value:function(n,e){if(n=void 0!==n?n:t.now(),s=n,0===o.length)return!1;for(var i=0;i<o.length;)o[i].update(n)||e?i++:o.splice(i,1);return!0}}]),t}();p.Tween=function(){function t(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return i(this,t),this.object=n,this._valuesStart=Object.assign({},n),this._valuesStartRepeat=Object.assign({},n),this._valuesEnd={},this._chainedTweens=[],this._duration=1e3,this._easingFunction=p.Easing.Linear.None,this._interpolationFunction=p.Interpolation.None,this._startTime=null,this._delayTime=0,this._repeat=0,this._repeatDelayTime=0,this._isPlaying=!1,this._yoyo=!1,this._reversed=!1,this._onStartCallbackFired=!1,this._events=new Map,this._pausedTime=0,this}return a(t,[{key:"emit",value:function(t,n,e,i,r){return void 0!==t&&"function"==typeof n?this._events.set(t,n):"function"!=typeof n&&void 0!==this._events.get(t)&&this._events.get(t).call(this,n,e,i,r),this}},{key:"pause",value:function(){return this._isPlaying?(this._isPlaying=!1,p.remove(this),this._pausedTime=p.now(),this.emit("pause",this.object)):this}},{key:"play",value:function(){return this._isPlaying?this:(this._isPlaying=!0,this._startTime+=p.now()-this._pausedTime,p.add(this),this._pausedTime=p.now(),this.emit("play",this.object))}},{key:"duration",value:function(t){return this._duration=t,this}},{key:"to",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3;return this._valuesEnd=t,this._duration=n,this}},{key:"start",value:function(t){var n=this._startTime,e=this._delayTime;return n=void 0!==t?t:p.now(),n+=e,this._startTime=n,p.add(this),this._isPlaying=!0,this}},{key:"stop",value:function(){var t=this._isPlaying,n=(this._onStopCallback,this.object);return t?(p.remove(this),this._isPlaying=!1,this.stopChainedTweens(),this.emit("stop",n)):this}},{key:"end",value:function(){var t=this._startTime,n=this._duration;return this.update(t+n)}},{key:"stopChainedTweens",value:function(){var t=this._chainedTweens;return t.map(function(t){return t.stop()}),this}},{key:"delay",value:function(t){return this._delayTime=t,this}},{key:"repeat",value:function(t){return this._repeat=t,this}},{key:"repeatDelay",value:function(t){return this._repeatDelayTime=t,this}},{key:"yoyo",value:function(t){return this._yoyo=t,this}},{key:"easing",value:function(t){return this._easingFunction=t,this}},{key:"interpolation",value:function(t){return this._interpolationFunction=t,this}},{key:"chain",value:function(){for(var t=arguments.length,n=Array(t),e=0;e<t;e++)n[e]=arguments[e];return this._chainedTweens=n,this}},{key:"update",value:function(t){var n=(this._onUpdateCallback,this._onStartCallback,this._onStartCallbackFired),e=(this._onCompleteCallback,this._chainedTweens),i=this._easingFunction,r=this._interpolationFunction,u=this._repeat,a=this._repeatDelayTime,o=this._delayTime,s=this._yoyo,h=this._reversed,c=this._startTime,l=this._duration,f=this._valuesStart,p=this._valuesStartRepeat,v=this._valuesEnd,y=this.object,_=void 0,d=void 0,m=void 0;if(t<c)return!0;n===!1&&(this.emit("start",y),this._onStartCallbackFired=!0),d=(t-c)/l,d=d>1?1:d,m=i(d);for(_ in v){var g=f[_],I=v[_];I instanceof Array?y[_]=r(I,m):("string"==typeof I&&(I="+"===I.charAt(0)||"-"===I.charAt(0)?g+parseFloat(I):parseFloat(I)),"number"==typeof I&&(y[_]=g+(I-g)*m))}if(this.emit("update",y,d),1===d){if(u>0){isFinite(u)&&u--;for(_ in p){if("string"==typeof v[_]&&(p[_]=p[_]+parseFloat(v[_])),s){var k=p[_];p[_]=v[_],v[_]=k}f[_]=p[_]}return this.emit("repeat",y,h),s&&(this._reversed=!h),a?this._startTime=t+a:this._startTime=t+o,!0}return this.emit("complete",y),e.map(function(t){return t.start(c+l)}),!1}return!0}}]),t}(),p.Easing={Linear:{None:function(t){return t}},Quadratic:{In:function(t){return t*t},Out:function(t){return t*(2-t)},InOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}},Cubic:{In:function(t){return t*t*t},Out:function(t){return--t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}},Quartic:{In:function(t){return t*t*t*t},Out:function(t){return 1- --t*t*t*t},InOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}},Quintic:{In:function(t){return t*t*t*t*t},Out:function(t){return--t*t*t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},Sinusoidal:{In:function(t){return 1-Math.cos(t*Math.PI/2)},Out:function(t){return Math.sin(t*Math.PI/2)},InOut:function(t){return.5*(1-Math.cos(Math.PI*t))}},Exponential:{In:function(t){return 0===t?0:Math.pow(1024,t-1)},Out:function(t){return 1===t?1:1-Math.pow(-10*t,2)},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(-Math.pow(-10*(t-1),2)+2)}},Circular:{In:function(t){return 1-Math.sqrt(1-t*t)},Out:function(t){return Math.sqrt(1- --t*t)},InOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},Elastic:{In:function(t){return 0===t?0:1===t?1:-Math.pow(10*(t-1),2)*Math.sin(5*(t-1.1)*Math.PI)},Out:function(t){return 0===t?0:1===t?1:Math.pow(-10*t,2)*Math.sin(5*(t-.1)*Math.PI)+1},InOut:function(t){return 0===t?0:1===t?1:(t*=2,t<1?-.5*Math.pow(10*(t-1),2)*Math.sin(5*(t-1.1)*Math.PI):.5*Math.pow(-10*(t-1),2)*Math.sin(5*(t-1.1)*Math.PI)+1)}},Back:{In:function(t){var n=1.70158;return t*t*((n+1)*t-n)},Out:function(t){var n=1.70158;return--t*t*((n+1)*t+n)+1},InOut:function(t){var n=2.5949095;return(t*=2)<1?.5*(t*t*((n+1)*t-n)):.5*((t-=2)*t*((n+1)*t+n)+2)}},Bounce:{In:function(t){return 1-p.Easing.Bounce.Out(1-t)},Out:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},InOut:function(t){return t<.5?.5*p.Easing.Bounce.In(2*t):.5*p.Easing.Bounce.Out(2*t-1)+.5}}},p.Interpolation={Linear:function(t,n){var e=t.length-1,i=e*n,r=Math.floor(i),u=p.Interpolation.Utils.Linear;return n<0?u(t[0],t[1],i):n>1?u(t[e],t[e-1],e-i):u(t[r],t[r+1>e?e:r+1],i-r)},Bezier:function(t,n){for(var e=0,i=t.length-1,r=Math.pow,u=p.Interpolation.Utils.Bernstein,a=0;a<=i;a++)e+=r(1-n,i-a)*r(n,a)*t[a]*u(i,a);return e},CatmullRom:function(t,n){var e=t.length-1,i=e*n,r=Math.floor(i),u=p.Interpolation.Utils.CatmullRom;return t[0]===t[e]?(n<0&&(r=Math.floor(i=e*(1+n))),u(t[(r-1+e)%e],t[r],t[(r+1)%e],t[(r+2)%e],i-r)):n<0?t[0]-(u(t[0],t[0],t[1],t[1],-i)-t[0]):n>1?t[e]-(u(t[e],t[e],t[e-1],t[e-1],i-e)-t[e]):u(t[r?r-1:0],t[r],t[e<r+1?e:r+1],t[e<r+2?e:r+2],i-r)},Utils:{Linear:function(t,n,e){return(n-t)*e+t},Bernstein:function(t,n){var e=p.Interpolation.Utils.Factorial;return e(t)/e(n)/e(t-n)},Factorial:function(){var t=[1];return function(n){var e=1;if(t[n])return t[n];for(var i=n;i>1;i--)e*=i;return t[n]=e,e}}(),CatmullRom:function(t,n,e,i,r){var u=.5*(e-t),a=.5*(i-n),o=r*r,s=r*o;return(2*n-2*e+u+a)*s+(-3*n+3*e-2*u-a)*o+u*r+n}}},r=[],u=function(){return p}.apply(n,r),!(void 0!==u&&(t.exports=u))}])}); | ||
!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.TWEEN=n():t.TWEEN=n()}(this,function(){return function(t){function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}var e={};return n.m=t,n.c=e,n.i=function(t){return t},n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:i})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},n.p="",n(n.s=8)}([function(t,n,e){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i={Linear:{None:function(t){return t}},Quadratic:{In:function(t){return t*t},Out:function(t){return t*(2-t)},InOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}},Cubic:{In:function(t){return t*t*t},Out:function(t){return--t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}},Quartic:{In:function(t){return t*t*t*t},Out:function(t){return 1- --t*t*t*t},InOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}},Quintic:{In:function(t){return t*t*t*t*t},Out:function(t){return--t*t*t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},Sinusoidal:{In:function(t){return 1-Math.cos(t*Math.PI/2)},Out:function(t){return Math.sin(t*Math.PI/2)},InOut:function(t){return.5*(1-Math.cos(Math.PI*t))}},Exponential:{In:function(t){return 0===t?0:Math.pow(1024,t-1)},Out:function(t){return 1===t?1:1-Math.pow(-10*t,2)},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(-Math.pow(-10*(t-1),2)+2)}},Circular:{In:function(t){return 1-Math.sqrt(1-t*t)},Out:function(t){return Math.sqrt(1- --t*t)},InOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},Elastic:{In:function(t){return 0===t?0:1===t?1:-Math.pow(10*(t-1),2)*Math.sin(5*(t-1.1)*Math.PI)},Out:function(t){return 0===t?0:1===t?1:Math.pow(-10*t,2)*Math.sin(5*(t-.1)*Math.PI)+1},InOut:function(t){return 0===t?0:1===t?1:(t*=2,t<1?-.5*Math.pow(10*(t-1),2)*Math.sin(5*(t-1.1)*Math.PI):.5*Math.pow(-10*(t-1),2)*Math.sin(5*(t-1.1)*Math.PI)+1)}},Back:{In:function(t){var n=1.70158;return t*t*((n+1)*t-n)},Out:function(t){var n=1.70158;return--t*t*((n+1)*t+n)+1},InOut:function(t){var n=2.5949095;return(t*=2)<1?.5*(t*t*((n+1)*t-n)):.5*((t-=2)*t*((n+1)*t+n)+2)}},Bounce:{In:function(t){return 1-i.Bounce.Out(1-t)},Out:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},InOut:function(t){return t<.5?.5*i.Bounce.In(2*t):.5*i.Bounce.Out(2*t-1)+.5}}};n.default=i},function(t,n,e){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i={Linear:function(t,n){var e=t.length-1,r=e*n,o=Math.floor(r),u=i.Utils.Linear;return n<0?u(t[0],t[1],r):n>1?u(t[e],t[e-1],e-r):u(t[o],t[o+1>e?e:o+1],r-o)},Bezier:function(t,n){for(var e=0,r=t.length-1,o=Math.pow,u=i.Utils.Bernstein,a=0;a<=r;a++)e+=o(1-n,r-a)*o(n,a)*t[a]*u(r,a);return e},CatmullRom:function(t,n){var e=t.length-1,r=e*n,o=Math.floor(r),u=i.Utils.CatmullRom;return t[0]===t[e]?(n<0&&(o=Math.floor(r=e*(1+n))),u(t[(o-1+e)%e],t[o],t[(o+1)%e],t[(o+2)%e],r-o)):n<0?t[0]-(u(t[0],t[0],t[1],t[1],-r)-t[0]):n>1?t[e]-(u(t[e],t[e],t[e-1],t[e-1],r-e)-t[e]):u(t[o?o-1:0],t[o],t[e<o+1?e:o+1],t[e<o+2?e:o+2],r-o)},Utils:{Linear:function(t,n,e){return(n-t)*e+t},Bernstein:function(t,n){var e=i.Utils.Factorial;return e(t)/e(n)/e(t-n)},Factorial:function(){var t=[1];return function(n){var e=1;if(t[n])return t[n];for(var i=n;i>1;i--)e*=i;return t[n]=e,e}}(),CatmullRom:function(t,n,e,i,r){var o=.5*(e-t),u=.5*(i-n),a=r*r,s=r*a;return(2*n-2*e+o+u)*s+(-3*n+3*e-2*o-u)*a+o*r+n}}};n.default=i},function(t,n,e){"use strict";function i(t){p(o)?(o=t,s=requestAnimationFrame(i)):(u=!1,cancelAnimationFrame(s))}Object.defineProperty(n,"__esModule",{value:!0});var r=[],o=0,u=!1,a=!1,s=void 0,c=function(){return r},f=function(t){a=t},l=function(){r=[]},h=function(t){r.push(t),a&&!u&&(i(v()),u=!0)},d=function(t){r.filter(function(n){return n!==t})},v=function(){return o},p=function(t,n){if(t=void 0!==t?t:v(),o=t,0===r.length)return!1;for(var e=0;e<r.length;)r[e].update(t)||n?e++:r.splice(e,1);return!0};n.getAll=c,n.removeAll=l,n.remove=d,n.add=h,n.now=v,n.update=p,n.autoPlay=f},function(t,n,e){"use strict";var i,r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};i=function(){return this}();try{i=i||Function("return this")()||(0,eval)("this")}catch(t){"object"===("undefined"==typeof window?"undefined":r(window))&&(i=window)}t.exports=i},function(t,n,e){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function r(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var o=function(){function t(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(n,e,i){return e&&t(n.prototype,e),i&&t(n,i),n}}(),u=(e(2),e(0)),a=(i(u),e(1)),s=(i(a),function(){function t(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),this.object=n,this._valuesStart=Object.assign({},n),this._valuesStartRepeat=Object.assign({},n),this._valuesEnd={},this._chainedTweens=[],this._duration=1e3,this._easingFunction=TWEEN.Easing.Linear.None,this._interpolationFunction=TWEEN.Interpolation.None,this._startTime=null,this._delayTime=0,this._repeat=0,this._repeatDelayTime=0,this._isPlaying=!1,this._yoyo=!1,this._reversed=!1,this._onStartCallbackFired=!1,this._events=new Map,this._pausedTime=0,this}return o(t,[{key:"emit",value:function(t,n,e,i,r){return void 0!==t&&"function"==typeof n?this._events.set(t,n):"function"!=typeof n&&void 0!==this._events.get(t)&&this._events.get(t).call(this,n,e,i,r),this}},{key:"pause",value:function(){return this._isPlaying?(this._isPlaying=!1,TWEEN.remove(this),this._pausedTime=TWEEN.now(),this.emit("pause",this.object)):this}},{key:"play",value:function(){return this._isPlaying?this:(this._isPlaying=!0,this._startTime+=TWEEN.now()-this._pausedTime,TWEEN.add(this),this._pausedTime=TWEEN.now(),this.emit("play",this.object))}},{key:"duration",value:function(t){return this._duration=t,this}},{key:"to",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3;return this._valuesEnd=t,this._duration=n,this}},{key:"start",value:function(t){var n=this._startTime,e=this._delayTime;return n=void 0!==t?t:TWEEN.now(),n+=e,this._startTime=n,TWEEN.add(this),this._isPlaying=!0,this}},{key:"stop",value:function(){var t=this._isPlaying,n=(this._onStopCallback,this.object);return t?(TWEEN.remove(this),this._isPlaying=!1,this.stopChainedTweens(),this.emit("stop",n)):this}},{key:"end",value:function(){var t=this._startTime,n=this._duration;return this.update(t+n)}},{key:"stopChainedTweens",value:function(){var t=this._chainedTweens;return t.map(function(t){return t.stop()}),this}},{key:"delay",value:function(t){return this._delayTime=t,this}},{key:"repeat",value:function(t){return this._repeat=t,this}},{key:"repeatDelay",value:function(t){return this._repeatDelayTime=t,this}},{key:"yoyo",value:function(t){return this._yoyo=t,this}},{key:"easing",value:function(t){return this._easingFunction=t,this}},{key:"interpolation",value:function(t){return this._interpolationFunction=t,this}},{key:"chain",value:function(){for(var t=arguments.length,n=Array(t),e=0;e<t;e++)n[e]=arguments[e];return this._chainedTweens=n,this}},{key:"update",value:function(t){var n=(this._onUpdateCallback,this._onStartCallback,this._onStartCallbackFired),e=(this._onCompleteCallback,this._chainedTweens),i=this._easingFunction,r=this._interpolationFunction,o=this._repeat,u=this._repeatDelayTime,a=this._delayTime,s=this._yoyo,c=this._reversed,f=this._startTime,l=this._duration,h=this._valuesStart,d=this._valuesStartRepeat,v=this._valuesEnd,p=this.object,y=void 0,_=void 0,m=void 0;if(t<f)return!0;n===!1&&(this.emit("start",p),this._onStartCallbackFired=!0),_=(t-f)/l,_=_>1?1:_,m=i(_);for(y in v){var w=h[y],b=v[y];b instanceof Array?p[y]=r(b,m):("string"==typeof b&&(b="+"===b.charAt(0)||"-"===b.charAt(0)?w+parseFloat(b):parseFloat(b)),"number"==typeof b&&(p[y]=w+(b-w)*m))}if(this.emit("update",p,_),1===_){if(o>0){isFinite(o)&&o--;for(y in d){if("string"==typeof v[y]&&(d[y]=d[y]+parseFloat(v[y])),s){var g=d[y];d[y]=v[y],v[y]=g}h[y]=d[y]}return this.emit("repeat",p,c),s&&(this._reversed=!c),u?this._startTime=t+u:this._startTime=t+a,!0}return this.emit("complete",p),e.map(function(t){return t.start(f+l)}),!1}return!0}}]),t}());n.default=s},function(t,n,e){"use strict";void 0===Object.assign&&(Object.assign=function(){for(var t=arguments.length,n=Array(t),e=0;e<t;e++)n[e]=arguments[e];var i=n.shift();return n.map(function(t){for(var n in t)i[n]=t[n]}),i})},function(t,n,e){"use strict";(function(t){var n="undefined"!=typeof window?window:"undefined"!=typeof t?t:void 0,e=["webkit","moz","ms","o"],i="AnimationFrame",r="Request"+i,o="Cancel"+i,u="CancelRequest"+i,a=setTimeout,s=clearTimeout;if(void 0===n.requestAnimationFrame){var c=void 0,f=void 0,l=Date.now(),h=50/3,d=h;e.map(function(t){void 0===(c=n[t+r])&&(c=function(t){return a(function(){f=Date.now(),t(f-l),d=h+(Date.now()-f)},d)})}),void 0!==c&&(n.requestAnimationFrame=c)}if(void 0===n.cancelAnimationFrame){var v=void 0;e.map(function(t){void 0===(v=n[t+o])&&void 0===(v=n[t+u])&&(v=function(t){return s(t)})}),void 0!==v&&(n.cancelAnimationFrame=v)}}).call(n,e(3))},function(t,n,e){"use strict";(function(t){function n(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}var e="undefined"!=typeof window?window:"undefined"!=typeof t?t:void 0;void 0===e.Map&&(e.Map=function t(){n(this,t);var e={};return this.set=function(t,n){return e[t]=n,this},this.get=function(t){return e[t]},this.has=function(t){return void 0!==this.get(t)},this})}).call(n,e(3))},function(t,n,e){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(n,"__esModule",{value:!0}),n.Interpolation=n.Easing=n.Tween=n.now=n.autoPlay=n.update=n.remove=n.removeAll=n.add=n.getAll=void 0,e(5),e(6),e(7);var r=e(2),o=e(0),u=i(o),a=e(4),s=i(a),c=e(1),f=i(c);n.getAll=r.getAll,n.add=r.add,n.removeAll=r.removeAll,n.remove=r.remove,n.update=r.update,n.autoPlay=r.autoPlay,n.now=r.now,n.Tween=s.default,n.Easing=u.default,n.Interpolation=f.default}])}); |
{ | ||
"name": "es6-tween", | ||
"version": "0.1.04", | ||
"version": "0.1.05", | ||
"description": "ES6 implementation of amazing tween.js", | ||
@@ -5,0 +5,0 @@ "main": "dist/Tween.js", |
836
src/Tween.js
@@ -1,835 +0,15 @@ | ||
// TWEEN.js | ||
let _tweens = []; | ||
let _time = 0; | ||
let isStarted = false; | ||
let autoPlay = false; | ||
let _tick; | ||
import "./shim/object_assign"; | ||
let autoStart = function autoStart(time) { | ||
if (TWEEN.update(_time)) { | ||
_time = time; | ||
_tick = requestAnimationFrame(autoStart); | ||
} else { | ||
isStarted = false; | ||
cancelAnimationFrame(_tick); | ||
} | ||
} | ||
import "./shim/raf"; | ||
class TWEEN { | ||
static getAll() { | ||
return _tweens | ||
} | ||
static autoPlay ( state ) { | ||
autoPlay = state; | ||
} | ||
static removeAll() { | ||
_tweens = [] | ||
} | ||
static add( tween ) { | ||
_tweens.push( tween ); | ||
import "./shim/set"; | ||
if ( autoPlay && !isStarted ) { | ||
autoStart(TWEEN.now()); | ||
isStarted = true; | ||
} | ||
import { getAll, add, removeAll, remove, update, autoPlay, now } from './dist/core'; | ||
} | ||
static remove( tween ) { | ||
_tweens.filter( tweens => tweens !== tween ); | ||
} | ||
static now() { | ||
return _time; | ||
} | ||
static update( time, preserve ) { | ||
import Easing from './dist/Easing'; | ||
import Tween from './dist/Tween'; | ||
time = time !== undefined ? time : TWEEN.now(); | ||
import Interpolation from './dist/Interpolation'; | ||
_time = time; | ||
if ( _tweens.length === 0 ) { | ||
return false; | ||
} | ||
let i = 0; | ||
while ( i < _tweens.length ) { | ||
if ( _tweens[ i ].update( time ) || preserve ) { | ||
i++; | ||
} else { | ||
_tweens.splice( i, 1 ); | ||
} | ||
} | ||
return true; | ||
} | ||
} | ||
// TWEEN.Tween.js | ||
TWEEN.Tween = class { | ||
constructor( object = {} ) { | ||
this.object = object; | ||
this._valuesStart = Object.assign( {}, object ); | ||
this._valuesStartRepeat = Object.assign( {}, object ); | ||
this._valuesEnd = {}; | ||
this._chainedTweens = []; | ||
this._duration = 1000; | ||
this._easingFunction = TWEEN.Easing.Linear.None; | ||
this._interpolationFunction = TWEEN.Interpolation.None; | ||
this._startTime = null; | ||
this._delayTime = 0; | ||
this._repeat = 0; | ||
this._repeatDelayTime = 0; | ||
this._isPlaying = false; | ||
this._yoyo = false; | ||
this._reversed = false; | ||
this._onStartCallbackFired = false; | ||
this._events = new Map(); | ||
this._pausedTime = 0; | ||
return this; | ||
} | ||
emit(name, fn, a2, a3, a4) { | ||
if (name !== undefined && typeof(fn) === "function") { | ||
this._events.set(name, fn); | ||
} else if (typeof(fn) !== "function" && this._events.get(name) !== undefined) { | ||
this._events.get(name).call(this, fn, a2, a3, a4); | ||
} | ||
return this; | ||
} | ||
pause () { | ||
if (!this._isPlaying) { | ||
return this; | ||
} | ||
this._isPlaying = false; | ||
TWEEN.remove(this); | ||
this._pausedTime = TWEEN.now(); | ||
return this.emit('pause', this.object); | ||
} | ||
play () { | ||
if (this._isPlaying) { | ||
return this; | ||
} | ||
this._isPlaying = true; | ||
this._startTime += TWEEN.now() - this._pausedTime; | ||
TWEEN.add(this); | ||
this._pausedTime = TWEEN.now(); | ||
return this.emit('play', this.object); | ||
} | ||
duration ( amount ) { | ||
this._duration = amount; | ||
return this; | ||
} | ||
to( properties = {}, duration = 1000 ) { | ||
this._valuesEnd = properties; | ||
this._duration = duration; | ||
return this; | ||
} | ||
start( time ) { | ||
let { _startTime, _delayTime } = this; | ||
_startTime = time !== undefined ? time : TWEEN.now(); | ||
_startTime += _delayTime; | ||
this._startTime = _startTime; | ||
TWEEN.add( this ); | ||
this._isPlaying = true; | ||
return this; | ||
} | ||
stop() { | ||
let { _isPlaying, _onStopCallback, object } = this; | ||
if ( !_isPlaying ) { | ||
return this; | ||
} | ||
TWEEN.remove( this ); | ||
this._isPlaying = false; | ||
this.stopChainedTweens(); | ||
return this.emit('stop', object); | ||
} | ||
end() { | ||
const { _startTime, _duration } = this; | ||
return this.update( _startTime + _duration ); | ||
} | ||
stopChainedTweens() { | ||
let { _chainedTweens } = this; | ||
_chainedTweens.map( item => item.stop() ); | ||
return this; | ||
} | ||
delay( amount ) { | ||
this._delayTime = amount; | ||
return this; | ||
} | ||
repeat( times ) { | ||
this._repeat = times; | ||
return this; | ||
} | ||
repeatDelay( amount ) { | ||
this._repeatDelayTime = amount; | ||
return this; | ||
} | ||
yoyo( state ) { | ||
this._yoyo = state; | ||
return this; | ||
} | ||
easing( fn ) { | ||
this._easingFunction = fn; | ||
return this; | ||
} | ||
interpolation( fn ) { | ||
this._interpolationFunction = fn; | ||
return this; | ||
} | ||
chain( ...args ) { | ||
this._chainedTweens = args; | ||
return this; | ||
} | ||
update( time ) { | ||
let { | ||
_onUpdateCallback | ||
, _onStartCallback | ||
, _onStartCallbackFired | ||
, _onCompleteCallback | ||
, _chainedTweens | ||
, _easingFunction | ||
, _interpolationFunction | ||
, _repeat | ||
, _repeatDelayTime | ||
, _delayTime | ||
, _yoyo | ||
, _reversed | ||
, _startTime | ||
, _duration | ||
, _valuesStart | ||
, _valuesStartRepeat | ||
, _valuesEnd | ||
, object | ||
} = this; | ||
let property; | ||
let elapsed; | ||
let value; | ||
if ( time < _startTime ) { | ||
return true; | ||
} | ||
if ( _onStartCallbackFired === false ) { | ||
this.emit('start', object); | ||
this._onStartCallbackFired = true; | ||
} | ||
elapsed = ( time - _startTime ) / _duration; | ||
elapsed = elapsed > 1 ? 1 : elapsed; | ||
value = _easingFunction( elapsed ); | ||
for ( property in _valuesEnd ) { | ||
let start = _valuesStart[ property ]; | ||
let end = _valuesEnd[ property ]; | ||
if ( end instanceof Array ) { | ||
object[ property ] = _interpolationFunction( end, value ); | ||
} else { | ||
// Parses relative end values with start as base (e.g.: +10, -3) | ||
if ( typeof( end ) === 'string' ) { | ||
if ( end.charAt( 0 ) === '+' || end.charAt( 0 ) === '-' ) { | ||
end = start + parseFloat( end ); | ||
} else { | ||
end = parseFloat( end ); | ||
} | ||
} | ||
// Protect against non numeric properties. | ||
if ( typeof( end ) === 'number' ) { | ||
object[ property ] = start + ( end - start ) * value; | ||
} | ||
} | ||
} | ||
this.emit('update', object, elapsed); | ||
if ( elapsed === 1 ) { | ||
if ( _repeat > 0 ) { | ||
if ( isFinite( _repeat ) ) { | ||
_repeat--; | ||
} | ||
// Reassign starting values, restart by making startTime = now | ||
for ( property in _valuesStartRepeat ) { | ||
if ( typeof( _valuesEnd[ property ] ) === 'string' ) { | ||
_valuesStartRepeat[ property ] = _valuesStartRepeat[ property ] + parseFloat( _valuesEnd[ property ] ); | ||
} | ||
if ( _yoyo ) { | ||
let tmp = _valuesStartRepeat[ property ]; | ||
_valuesStartRepeat[ property ] = _valuesEnd[ property ]; | ||
_valuesEnd[ property ] = tmp; | ||
} | ||
_valuesStart[ property ] = _valuesStartRepeat[ property ]; | ||
} | ||
this.emit('repeat', object, _reversed); | ||
if ( _yoyo ) { | ||
this._reversed = !_reversed; | ||
} | ||
if ( _repeatDelayTime ) { | ||
this._startTime = time + _repeatDelayTime; | ||
} else { | ||
this._startTime = time + _delayTime; | ||
} | ||
return true; | ||
} else { | ||
this.emit('complete', object); | ||
_chainedTweens.map(tween => tween.start( _startTime + _duration)); | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
} | ||
TWEEN.Easing = { | ||
Linear: { | ||
None( k ) { | ||
return k; | ||
} | ||
}, | ||
Quadratic: { | ||
In( k ) { | ||
return k * k; | ||
}, | ||
Out( k ) { | ||
return k * ( 2 - k ); | ||
}, | ||
InOut( k ) { | ||
if ( ( k *= 2 ) < 1 ) { | ||
return 0.5 * k * k; | ||
} | ||
return -0.5 * ( --k * ( k - 2 ) - 1 ); | ||
} | ||
}, | ||
Cubic: { | ||
In( k ) { | ||
return k * k * k; | ||
}, | ||
Out( k ) { | ||
return --k * k * k + 1; | ||
}, | ||
InOut( k ) { | ||
if ( ( k *= 2 ) < 1 ) { | ||
return 0.5 * k * k * k; | ||
} | ||
return 0.5 * ( ( k -= 2 ) * k * k + 2 ); | ||
} | ||
}, | ||
Quartic: { | ||
In( k ) { | ||
return k * k * k * k; | ||
}, | ||
Out( k ) { | ||
return 1 - ( --k * k * k * k ); | ||
}, | ||
InOut( k ) { | ||
if ( ( k *= 2 ) < 1 ) { | ||
return 0.5 * k * k * k * k; | ||
} | ||
return -0.5 * ( ( k -= 2 ) * k * k * k - 2 ); | ||
} | ||
}, | ||
Quintic: { | ||
In( k ) { | ||
return k * k * k * k * k; | ||
}, | ||
Out( k ) { | ||
return --k * k * k * k * k + 1; | ||
}, | ||
InOut( k ) { | ||
if ( ( k *= 2 ) < 1 ) { | ||
return 0.5 * k * k * k * k * k; | ||
} | ||
return 0.5 * ( ( k -= 2 ) * k * k * k * k + 2 ); | ||
} | ||
}, | ||
Sinusoidal: { | ||
In( k ) { | ||
return 1 - Math.cos( k * Math.PI / 2 ); | ||
}, | ||
Out( k ) { | ||
return Math.sin( k * Math.PI / 2 ); | ||
}, | ||
InOut( k ) { | ||
return 0.5 * ( 1 - Math.cos( Math.PI * k ) ); | ||
} | ||
}, | ||
Exponential: { | ||
In( k ) { | ||
return k === 0 ? 0 : Math.pow(1024, ( k - 1 )); | ||
}, | ||
Out( k ) { | ||
return k === 1 ? 1 : 1 - Math.pow(-10 * k, 2); | ||
}, | ||
InOut( k ) { | ||
if ( k === 0 ) { | ||
return 0; | ||
} | ||
if ( k === 1 ) { | ||
return 1; | ||
} | ||
if ( ( k *= 2 ) < 1 ) { | ||
return 0.5 * Math.pow(1024, ( k - 1 ) ); | ||
} | ||
return 0.5 * ( -Math.pow( -10 * ( k - 1 ), 2) + 2 ); | ||
} | ||
}, | ||
Circular: { | ||
In( k ) { | ||
return 1 - Math.sqrt( 1 - k * k ); | ||
}, | ||
Out( k ) { | ||
return Math.sqrt( 1 - ( --k * k ) ); | ||
}, | ||
InOut( k ) { | ||
if ( ( k *= 2 ) < 1 ) { | ||
return -0.5 * ( Math.sqrt( 1 - k * k ) - 1 ); | ||
} | ||
return 0.5 * ( Math.sqrt( 1 - ( k -= 2 ) * k ) + 1 ); | ||
} | ||
}, | ||
Elastic: { | ||
In( k ) { | ||
if ( k === 0 ) { | ||
return 0; | ||
} | ||
if ( k === 1 ) { | ||
return 1; | ||
} | ||
return -Math.pow(( 10 * ( k - 1 ) ), 2 ) * Math.sin( ( k - 1.1 ) * 5 * Math.PI ); | ||
}, | ||
Out( k ) { | ||
if ( k === 0 ) { | ||
return 0; | ||
} | ||
if ( k === 1 ) { | ||
return 1; | ||
} | ||
return Math.pow( -10 * k, 2 ) * Math.sin( ( k - 0.1 ) * 5 * Math.PI ) + 1; | ||
}, | ||
InOut( k ) { | ||
if ( k === 0 ) { | ||
return 0; | ||
} | ||
if ( k === 1 ) { | ||
return 1; | ||
} | ||
k *= 2; | ||
if ( k < 1 ) { | ||
return -0.5 * Math.pow(( 10 * ( k - 1 ) ), 2) * Math.sin( ( k - 1.1 ) * 5 * Math.PI ); | ||
} | ||
return 0.5 * Math.pow( -10 * ( k - 1 ), 2 ) * Math.sin( ( k - 1.1 ) * 5 * Math.PI ) + 1; | ||
} | ||
}, | ||
Back: { | ||
In( k ) { | ||
const s = 1.70158; | ||
return k * k * ( ( s + 1 ) * k - s ); | ||
}, | ||
Out( k ) { | ||
const s = 1.70158; | ||
return --k * k * ( ( s + 1 ) * k + s ) + 1; | ||
}, | ||
InOut( k ) { | ||
const s = 1.70158 * 1.525; | ||
if ( ( k *= 2 ) < 1 ) { | ||
return 0.5 * ( k * k * ( ( s + 1 ) * k - s ) ); | ||
} | ||
return 0.5 * ( ( k -= 2 ) * k * ( ( s + 1 ) * k + s ) + 2 ); | ||
} | ||
}, | ||
Bounce: { | ||
In( k ) { | ||
return 1 - TWEEN.Easing.Bounce.Out( 1 - k ); | ||
}, | ||
Out( k ) { | ||
if ( k < ( 1 / 2.75 ) ) { | ||
return 7.5625 * k * k; | ||
} else if ( k < ( 2 / 2.75 ) ) { | ||
return 7.5625 * ( k -= ( 1.5 / 2.75 ) ) * k + 0.75; | ||
} else if ( k < ( 2.5 / 2.75 ) ) { | ||
return 7.5625 * ( k -= ( 2.25 / 2.75 ) ) * k + 0.9375; | ||
} else { | ||
return 7.5625 * ( k -= ( 2.625 / 2.75 ) ) * k + 0.984375; | ||
} | ||
}, | ||
InOut( k ) { | ||
if ( k < 0.5 ) { | ||
return TWEEN.Easing.Bounce.In( k * 2 ) * 0.5; | ||
} | ||
return TWEEN.Easing.Bounce.Out( k * 2 - 1 ) * 0.5 + 0.5; | ||
} | ||
} | ||
}; | ||
TWEEN.Interpolation = { | ||
Linear( v, k ) { | ||
const m = v.length - 1; | ||
const f = m * k; | ||
const i = Math.floor( f ); | ||
const fn = TWEEN.Interpolation.Utils.Linear; | ||
if ( k < 0 ) { | ||
return fn( v[ 0 ], v[ 1 ], f ); | ||
} | ||
if ( k > 1 ) { | ||
return fn( v[ m ], v[ m - 1 ], m - f ); | ||
} | ||
return fn( v[ i ], v[ i + 1 > m ? m : i + 1 ], f - i ); | ||
}, | ||
Bezier( v, k ) { | ||
let b = 0; | ||
const n = v.length - 1; | ||
const pw = Math.pow; | ||
const bn = TWEEN.Interpolation.Utils.Bernstein; | ||
for ( let i = 0; i <= n; i++ ) { | ||
b += pw( 1 - k, n - i ) * pw( k, i ) * v[ i ] * bn( n, i ); | ||
} | ||
return b; | ||
}, | ||
CatmullRom( v, k ) { | ||
const m = v.length - 1; | ||
let f = m * k; | ||
let i = Math.floor( f ); | ||
const fn = TWEEN.Interpolation.Utils.CatmullRom; | ||
if ( v[ 0 ] === v[ m ] ) { | ||
if ( k < 0 ) { | ||
i = Math.floor( f = m * ( 1 + k ) ); | ||
} | ||
return fn( v[ ( i - 1 + m ) % m ], v[ i ], v[ ( i + 1 ) % m ], v[ ( i + 2 ) % m ], f - i ); | ||
} else { | ||
if ( k < 0 ) { | ||
return v[ 0 ] - ( fn( v[ 0 ], v[ 0 ], v[ 1 ], v[ 1 ], -f ) - v[ 0 ] ); | ||
} | ||
if ( k > 1 ) { | ||
return v[ m ] - ( fn( v[ m ], v[ m ], v[ m - 1 ], v[ m - 1 ], f - m ) - v[ m ] ); | ||
} | ||
return fn( v[ i ? i - 1 : 0 ], v[ i ], v[ m < i + 1 ? m : i + 1 ], v[ m < i + 2 ? m : i + 2 ], f - i ); | ||
} | ||
}, | ||
Utils: { | ||
Linear( p0, p1, t ) { | ||
return ( p1 - p0 ) * t + p0; | ||
}, | ||
Bernstein( n, i ) { | ||
const fc = TWEEN.Interpolation.Utils.Factorial; | ||
return fc( n ) / fc( i ) / fc( n - i ); | ||
}, | ||
Factorial: ( ( () => { | ||
const a = [ 1 ]; | ||
return n => { | ||
let s = 1; | ||
if ( a[ n ] ) { | ||
return a[ n ]; | ||
} | ||
for ( let i = n; i > 1; i-- ) { | ||
s *= i; | ||
} | ||
a[ n ] = s; | ||
return s; | ||
}; | ||
} ) )(), | ||
CatmullRom( p0, p1, p2, p3, t ) { | ||
const v0 = ( p2 - p0 ) * 0.5; | ||
const v1 = ( p3 - p1 ) * 0.5; | ||
const t2 = t * t; | ||
const t3 = t * t2; | ||
return ( 2 * p1 - 2 * p2 + v0 + v1 ) * t3 + ( -3 * p1 + 3 * p2 - 2 * v0 - v1 ) * t2 + v0 * t + p1; | ||
} | ||
} | ||
} | ||
// AMD/RequireJS | ||
if ( typeof( define ) === "function" && define.amd ) { | ||
define( [], function() { | ||
return TWEEN; | ||
} ); | ||
// NodeJS | ||
} else if ( typeof( module ) !== "undefined" && module.exports ) { | ||
module.exports = TWEEN; | ||
// Browser | ||
} else if ( typeof( window ) !== "undefined" && window.document ) { | ||
window.TWEEN = TWEEN; | ||
// WebWorker | ||
} else if ( typeof self !== "undefined" && self.importScripts !== undefined ) { | ||
self.TWEEN = TWEEN; | ||
// On somecase (on TV with QT (JS compiler) this worked) | ||
} else if ( typeof( exports ) !== "undefined" && typeof( global ) !== "undefined" ) { | ||
exports.TWEEN = Tween; | ||
// Else somewhere | ||
} else if (typeof(this) !== "undefined") { | ||
this.TWEEN = TWEEN; | ||
} | ||
export { getAll, add, removeAll, remove, update, autoPlay, now, Tween, Easing, Interpolation } |
@@ -23,2 +23,3 @@ const webpack = require('webpack'); | ||
filename: 'dist/' + outputFile, | ||
library: 'TWEEN', | ||
libraryTarget: 'umd' | ||
@@ -25,0 +26,0 @@ }, |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
264245
21
1456
2