es6-tween
Advanced tools
Comparing version 4.0.2 to 4.1.0
@@ -10,5 +10,9 @@ (function (global, factory) { | ||
var root = typeof (window) !== 'undefined' ? window : typeof (global) !== 'undefined' ? global : this; | ||
var requestAnimationFrame = root.requestAnimationFrame || (function (fn) { return root.setTimeout(fn, 16); }); | ||
var cancelAnimationFrame = root.cancelAnimationFrame || (function (id) { return root.clearTimeout(id); }); | ||
var root = typeof window !== 'undefined' | ||
? window | ||
: typeof global !== 'undefined' ? global : this; | ||
var requestAnimationFrame = root.requestAnimationFrame || | ||
(function (fn) { return root.setTimeout(fn, 16); }); | ||
var cancelAnimationFrame = root.cancelAnimationFrame || | ||
(function (id) { return root.clearTimeout(id); }); | ||
@@ -24,3 +28,3 @@ /* global process */ | ||
var now = (function () { | ||
if (typeof (process) !== 'undefined' && process.hrtime !== undefined) { | ||
if (typeof process !== 'undefined' && process.hrtime !== undefined) { | ||
return function () { | ||
@@ -41,3 +45,7 @@ var time = process.hrtime(); | ||
else { | ||
var offset_1 = root.performance && root.performance.timing && root.performance.timing.navigationStart ? root.performance.timing.navigationStart : Date.now(); | ||
var offset_1 = root.performance && | ||
root.performance.timing && | ||
root.performance.timing.navigationStart | ||
? root.performance.timing.navigationStart | ||
: Date.now(); | ||
return function () { | ||
@@ -47,3 +55,3 @@ return Date.now() - offset_1; | ||
} | ||
}()); | ||
})(); | ||
/** | ||
@@ -64,2 +72,4 @@ * Lightweight, effecient and modular ES6 version of tween.js | ||
var _stopTicker = cancelAnimationFrame; | ||
var emptyFrame = 0; | ||
var powerModeThrottle = 120; | ||
/** | ||
@@ -86,2 +96,3 @@ * Adds tween to list | ||
_tweens.push(tween); | ||
emptyFrame = 0; | ||
if (_autoPlay && !isStarted) { | ||
@@ -175,4 +186,8 @@ _tick = _ticker(update); | ||
if (!_tweens.length) { | ||
emptyFrame++; | ||
} | ||
if (emptyFrame > powerModeThrottle) { | ||
_stopTicker(_tick); | ||
isStarted = false; | ||
emptyFrame = 0; | ||
return false; | ||
@@ -412,3 +427,3 @@ } | ||
var Interpolation = { | ||
Linear: function (v, k) { | ||
Linear: function (v, k, value) { | ||
var m = v.length - 1; | ||
@@ -419,10 +434,10 @@ var f = m * k; | ||
if (k < 0) { | ||
return fn(v[0], v[1], f); | ||
return fn(v[0], v[1], f, value); | ||
} | ||
if (k > 1) { | ||
return fn(v[m], v[m - 1], m - f); | ||
return fn(v[m], v[m - 1], m - f, value); | ||
} | ||
return fn(v[i], v[i + 1 > m ? m : i + 1], f - i); | ||
return fn(v[i], v[i + 1 > m ? m : i + 1], f - i, value); | ||
}, | ||
Bezier: function (v, k) { | ||
Bezier: function (v, k, value) { | ||
var b = 0; | ||
@@ -437,3 +452,3 @@ var n = v.length - 1; | ||
}, | ||
CatmullRom: function (v, k) { | ||
CatmullRom: function (v, k, value) { | ||
var m = v.length - 1; | ||
@@ -447,17 +462,35 @@ var f = m * k; | ||
} | ||
return fn(v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m], f - i); | ||
return fn(v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m], f - i, value); | ||
} | ||
else { | ||
if (k < 0) { | ||
return v[0] - (fn(v[0], v[0], v[1], v[1], -f) - v[0]); | ||
return v[0] - (fn(v[0], v[0], v[1], v[1], -f, value) - v[0]); | ||
} | ||
if (k > 1) { | ||
return v[m] - (fn(v[m], v[m], v[m - 1], v[m - 1], f - m) - v[m]); | ||
return v[m] - (fn(v[m], v[m], v[m - 1], v[m - 1], f - m, value) - 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); | ||
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, value); | ||
} | ||
}, | ||
Utils: { | ||
Linear: function (p0, p1, t) { | ||
return typeof p0 === 'function' ? p0(t) : (p1 - p0) * t + p0; | ||
Linear: function (p0, p1, t, v) { | ||
if (typeof v === 'string') { | ||
return p1; | ||
} | ||
else if (typeof v === 'number') { | ||
return typeof p0 === 'function' ? p0(t) : (p1 - p0) * t + p0; | ||
} | ||
else if (typeof v === 'object') { | ||
if (v.length !== undefined) { | ||
for (var p = 0, len = v.length; p < len; p++) { | ||
v[p] = Interpolation.Utils.Linear(p0[p], p1[p], t, v[p]); | ||
} | ||
} | ||
else { | ||
for (var p in v) { | ||
v[p] = Interpolation.Utils.Linear(p0[p], p1[p], t, v[p]); | ||
} | ||
} | ||
return v; | ||
} | ||
}, | ||
@@ -482,8 +515,26 @@ Bernstein: function (n, i) { | ||
})(), | ||
CatmullRom: function (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; | ||
CatmullRom: function (p0, p1, p2, p3, t, v) { | ||
if (typeof v === 'string') { | ||
return p1; | ||
} | ||
else if (typeof v === 'number') { | ||
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; | ||
} | ||
else if (typeof v === 'object') { | ||
if (v.length !== undefined) { | ||
for (var p = 0, len = v.length; p < len; p++) { | ||
v[p] = Interpolation.Utils.CatmullRom(p0[p], p1[p], p2[p], p3[p], t, v[p]); | ||
} | ||
} | ||
else { | ||
for (var p in v) { | ||
v[p] = Interpolation.Utils.CatmullRom(p0[p], p1[p], p2[p], p3[p], t, v[p]); | ||
} | ||
} | ||
return v; | ||
} | ||
} | ||
@@ -502,3 +553,6 @@ } | ||
var i = labels.indexOf(name); | ||
if (typeof name === 'string' && name.indexOf('=') !== -1 && !offset && i === -1) { | ||
if (typeof name === 'string' && | ||
name.indexOf('=') !== -1 && | ||
!offset && | ||
i === -1) { | ||
var rty = name.substr(name.indexOf('=') - 1, 2); | ||
@@ -597,5 +651,21 @@ var rt = name.split(rty); | ||
if (collection) { | ||
return !selector ? null : selector === window || selector === document ? [selector] : typeof selector === 'string' ? !!document.querySelectorAll && document.querySelectorAll(selector) : Array.isArray(selector) ? selector : selector.nodeType ? [selector] : []; | ||
return !selector | ||
? null | ||
: selector === window || selector === document | ||
? [selector] | ||
: typeof selector === 'string' | ||
? !!document.querySelectorAll && document.querySelectorAll(selector) | ||
: Array.isArray(selector) | ||
? selector | ||
: selector.nodeType ? [selector] : []; | ||
} | ||
return !selector ? null : selector === window || selector === document ? selector : typeof selector === 'string' ? !!document.querySelector && document.querySelector(selector) : Array.isArray(selector) ? selector[0] : selector.nodeType ? selector : null; | ||
return !selector | ||
? null | ||
: selector === window || selector === document | ||
? selector | ||
: typeof selector === 'string' | ||
? !!document.querySelector && document.querySelector(selector) | ||
: Array.isArray(selector) | ||
? selector[0] | ||
: selector.nodeType ? selector : null; | ||
}; | ||
@@ -641,3 +711,5 @@ | ||
} | ||
var isNaNForST = function (v) { return isNaN(+v) || v[0] === '+' || v[0] === '-' || v === '' || v === ' '; }; | ||
var isNaNForST = function (v) { | ||
return isNaN(+v) || v[0] === '+' || v[0] === '-' || v === '' || v === ' '; | ||
}; | ||
// Decompose value, now for only `string` that required | ||
@@ -648,4 +720,8 @@ function decompose(prop, obj, from, to) { | ||
if (typeof fromValue === 'string' && typeof toValue === 'string') { | ||
var fromValue1 = fromValue.match(NUM_REGEX).map(function (v) { return isNaNForST(v) ? v : +v; }); | ||
var toValue1 = toValue.match(NUM_REGEX).map(function (v, i) { return isNaNForST(v) ? v : +v; }); | ||
var fromValue1 = fromValue | ||
.match(NUM_REGEX) | ||
.map(function (v) { return (isNaNForST(v) ? v : +v); }); | ||
var toValue1 = toValue | ||
.match(NUM_REGEX) | ||
.map(function (v, i) { return (isNaNForST(v) ? v : +v); }); | ||
fromValue1.unshift(STRING_PROP); | ||
@@ -658,3 +734,5 @@ from[prop] = fromValue1; | ||
if (Array.isArray(fromValue)) { | ||
return fromValue.map(function (v, i) { return decompose(i, obj[prop], fromValue, toValue); }); | ||
return fromValue.map(function (v, i) { | ||
return decompose(i, obj[prop], fromValue, toValue); | ||
}); | ||
} | ||
@@ -678,3 +756,5 @@ else { | ||
} | ||
if (fromValue === undefined || typeof fromValue === 'string' || fromValue === toValue) { | ||
if (fromValue === undefined || | ||
typeof fromValue === 'string' || | ||
fromValue === toValue) { | ||
return toValue; | ||
@@ -690,5 +770,13 @@ } | ||
var isRelative = typeof toValue[i - 1] === 'string'; | ||
STRING_BUFFER += typeof toValue[i - 1] !== 'number' ? fromValue[i] : (((isRelative ? fromValue[i] + (+toValue[i - 1]) : fromValue[i] + (toValue[i - 1] - fromValue[i]) * t) * DECIMAL) | 0) / DECIMAL; | ||
STRING_BUFFER += | ||
typeof toValue[i - 1] !== 'number' | ||
? fromValue[i] | ||
: (((isRelative | ||
? fromValue[i] + +toValue[i - 1] | ||
: fromValue[i] + (toValue[i - 1] - fromValue[i]) * t) * | ||
DECIMAL) | | ||
0) / | ||
DECIMAL; | ||
if (originalT === 1) { | ||
fromValue[i] = fromValue[i] + (+toValue[i - 1]); | ||
fromValue[i] = fromValue[i] + +toValue[i - 1]; | ||
} | ||
@@ -718,3 +806,9 @@ } | ||
var isRelative = typeof toValue === 'string'; | ||
obj[prop] = (((isRelative ? fromValue + (+toValue) * t : fromValue + (toValue - fromValue) * t) * DECIMAL) | 0) / DECIMAL; | ||
obj[prop] = | ||
(((isRelative | ||
? fromValue + +toValue * t | ||
: fromValue + (toValue - fromValue) * t) * | ||
DECIMAL) | | ||
0) / | ||
DECIMAL; | ||
if (isRelative && originalT === 1) { | ||
@@ -769,5 +863,6 @@ from[prop] = obj[prop]; | ||
if (lastArr || lastObj) { | ||
nested[prop] = index === propsLastIndex ? value : lastArr || nextIsArray ? [] : | ||
lastObj ? {} | ||
: null; | ||
nested[prop] = | ||
index === propsLastIndex | ||
? value | ||
: lastArr || nextIsArray ? [] : lastObj ? {} : null; | ||
lastObj = lastArr = false; | ||
@@ -1163,3 +1258,3 @@ return nested[prop]; | ||
} | ||
if (Array.isArray(end) && typeof start === 'number') { | ||
if (Array.isArray(end) && !Array.isArray(start)) { | ||
end.unshift(start); | ||
@@ -1385,4 +1480,4 @@ } | ||
} | ||
else if (Array.isArray(end) && typeof start === 'number') { | ||
object[property] = _interpolationFunction(end, value); | ||
else if (Array.isArray(end) && !Array.isArray(start)) { | ||
object[property] = _interpolationFunction(end, value, object[property]); | ||
} | ||
@@ -1389,0 +1484,0 @@ else if (end && end.update) { |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.TWEEN={})}(this,function(t){"use strict";function e(t){if(void 0===t||"object"!=typeof t)return t;if(Array.isArray(t))return[].concat(t);if("object"==typeof t){var r={};for(var n in t)r[n]=e(t[n]);return r}return t}function r(t,e,n,i){var o=n[t],s=i[t];if("string"==typeof o&&"string"==typeof s){var u=o.match(j).map(function(t){return P(t)?t:+t}),a=s.match(j).map(function(t,e){return P(t)?t:+t});return u.unshift(M),n[t]=u,i[t]=a,!0}if("object"==typeof o&&"object"==typeof s){if(Array.isArray(o))return o.map(function(n,i){return r(i,e[t],o,s)});for(var f in s)r(f,e[t],o,s);return!0}return!1}function n(t,e,r,i,o,s){var u=r[t],a=i[t];if(void 0===a)return u;if(void 0===u||"string"==typeof u||u===a)return a;if("object"==typeof u&&"object"==typeof a){if(!u||!a)return e[t];if(u[0]===M){for(var f="",h=1,p=u.length;h<p;h++){c="string"==typeof a[h-1];f+="number"!=typeof a[h-1]?u[h]:((c?u[h]+ +a[h-1]:u[h]+(a[h-1]-u[h])*o)*x|0)/x,1===s&&(u[h]=u[h]+ +a[h-1])}return e[t]=f,f}if(Array.isArray(u))for(var h=0,p=u.length;h<p;h++)u[h]!==a[h]&&n(h,e[t],u,a,o,s);else for(var h in u)u[h]!==a[h]&&n(h,e[t],u,a,o,s)}else if("number"==typeof u){var c="string"==typeof a;e[t]=((c?u+ +a*o:u+(a-u)*o)*x|0)/x,c&&1===s&&(r[t]=e[t])}else"function"==typeof a&&(e[t]=a(o));return e[t]}var i,o="undefined"!=typeof window?window:"undefined"!=typeof global?global:this,s=o.requestAnimationFrame||function(t){return o.setTimeout(t,16)},u=o.cancelAnimationFrame||function(t){return o.clearTimeout(t)},a=function(){if("undefined"!=typeof process&&void 0!==process.hrtime)return function(){var t=process.hrtime();return 1e3*t[0]+t[1]/1e6};if(void 0!==o.performance&&void 0!==o.performance.now)return o.performance.now.bind(o.performance);var t=o.performance&&o.performance.timing&&o.performance.timing.navigationStart?o.performance.timing.navigationStart:Date.now();return function(){return Date.now()-t}}(),f=[],h=!1,p=!1,c=s,l=u,d=function(t){var e=f.indexOf(t);if(e>-1&&f.splice(e,1),f.length>0){e=f.length-1;var r=f[e];t.prev=r,r.next=t}f.push(t),p&&!h&&(i=c(v),h=!0)},_=function(t){for(var e=0;e<f.length;e++)if(t===f[e])return f[e];return null},y=function(t){var e=f.indexOf(t);-1!==e&&f.splice(e,1)},v=function(t,e){if(t=void 0!==t?t:a(),p&&h&&(i=c(v)),!f.length)return l(i),h=!1,!1;for(var r=0;r<f.length;)f[r++].update(t,e);return!0},m={},g={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(2,-10*t)},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(2-Math.pow(2,-10*(t-1)))}},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(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)},Out:function(t){return 0===t?0:1===t?1:Math.pow(2,-10*t)*Math.sin(5*(t-.1)*Math.PI)+1},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?-.5*Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI):.5*Math.pow(2,-10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)+1}},Back:{In:function(t){var e=1.70158;return t*t*((e+1)*t-e)},Out:function(t){var e=1.70158;return--t*t*((e+1)*t+e)+1},InOut:function(t){var e=2.5949095;return(t*=2)<1?t*t*((e+1)*t-e)*.5:.5*((t-=2)*t*((e+1)*t+e)+2)}},Bounce:{In:function(t){return 1-g.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*g.Bounce.In(2*t):.5*g.Bounce.Out(2*t-1)+.5}},Stepped:{steps:function(t){return function(e){return(e*t|0)/t}}}},T={Linear:function(t,e){var r=t.length-1,n=r*e,i=Math.floor(n),o=T.Utils.Linear;return e<0?o(t[0],t[1],n):e>1?o(t[r],t[r-1],r-n):o(t[i],t[i+1>r?r:i+1],n-i)},Bezier:function(t,e){for(var r=0,n=t.length-1,i=Math.pow,o=T.Utils.Bernstein,s=0;s<=n;s++)r+=i(1-e,n-s)*i(e,s)*t[s]*o(n,s);return r},CatmullRom:function(t,e){var r=t.length-1,n=r*e,i=Math.floor(n),o=T.Utils.CatmullRom;return t[0]===t[r]?(e<0&&(i=Math.floor(n=r*(1+e))),o(t[(i-1+r)%r],t[i],t[(i+1)%r],t[(i+2)%r],n-i)):e<0?t[0]-(o(t[0],t[0],t[1],t[1],-n)-t[0]):e>1?t[r]-(o(t[r],t[r],t[r-1],t[r-1],n-r)-t[r]):o(t[i?i-1:0],t[i],t[r<i+1?r:i+1],t[r<i+2?r:i+2],n-i)},Utils:{Linear:function(t,e,r){return"function"==typeof t?t(r):(e-t)*r+t},Bernstein:function(t,e){var r=T.Utils.Factorial;return r(t)/r(e)/r(t-e)},Factorial:function(){var t=[1];return function(e){var r=1;if(t[e])return t[e];for(var n=e;n>1;n--)r*=n;return t[e]=r,r}}(),CatmullRom:function(t,e,r,n,i){var o=.5*(r-t),s=.5*(n-e),u=i*i;return(2*e-2*r+o+s)*(i*u)+(-3*e+3*r-2*o-s)*u+o*i+e}}},b=function(){function t(){this.totalTime=0,this.labels=[],this.offsets=[]}return t.prototype.parseLabel=function(t,e){var r=this,n=r.offsets,i=r.labels,o=i.indexOf(t);if("string"==typeof t&&-1!==t.indexOf("=")&&!e&&-1===o){var s=t.substr(t.indexOf("=")-1,2),u=t.split(s);e=2===u.length?s+u[1]:null,t=u[0],o=i.indexOf(t)}if(-1!==o&&t){var a=n[o]||0;if("number"==typeof e)a=e;else if("string"==typeof e&&-1!==e.indexOf("=")){var f=e.charAt(0);e=Number(e.substr(2)),"+"===f||"-"===f?a+=parseFloat(f+e):"*"===f?a*=e:"/"===f?a/=e:"%"===f&&(a*=e/100)}return a}return"number"==typeof e?e:0},t.prototype.addLabel=function(t,e){return this.labels.push(t),this.offsets.push(this.parseLabel(t,e)),this},t.prototype.setLabel=function(t,e){var r=this.labels.indexOf(t);return-1!==r&&this.offsets.splice(r,1,this.parseLabel(t,e)),this},t.prototype.eraseLabel=function(t){var e=this.labels.indexOf(t);return-1!==e&&(this.labels.splice(e,1),this.offsets.splice(e,1)),this},t}(),w={},O=function(t,e,r){if(!t||!t.nodeType)return e;var n=t.queueID||"q_"+Date.now();t.queueID||(t.queueID=n);var i=w[n];if(i){if(i.object!==e||t!==i.tween.node||r._startTime!==i.tween._startTime){for(var o in e)o in i.object&&(r._startTime===i.tween._startTime?delete i.object[o]:i.propNormaliseRequired=!0);return e}return y(i.tween),i.object}return w[n]={tween:r,object:e,propNormaliseRequired:!1},w[n].object},I=function(t,e){return e?t?t===window||t===document?[t]:"string"==typeof t?!!document.querySelectorAll&&document.querySelectorAll(t):Array.isArray(t)?t:t.nodeType?[t]:[]:null:t?t===window||t===document?t:"string"==typeof t?!!document.querySelector&&document.querySelector(t):Array.isArray(t)?t[0]:t.nodeType?t:null:null},M="STRING_PROP",j=/\s+|([A-Za-z?().,{}:""[\]#\%]+)|([-+]+)?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,P=function(t){return isNaN(+t)||"+"===t[0]||"-"===t[0]||""===t||" "===t},x=Math.pow(10,4),A=/([.\[])/g,L=/\]/g,q=function(t,e){var r=t[e],n=e.replace(L,"").split(A),i=n.length-1,o=Array.isArray(t),s="object"==typeof t&&!o;return s?(t[e]=null,delete t[e]):o&&t.splice(e,1),n.reduce(function(t,e,u){o&&"."!==e&&"["!==e&&(e*=1);var a="["===n[u+1];if("."===e||"["===e)return"."===e?(s=!0,o=!1):"["===e&&(s=!1,o=!0),t;if(void 0===t[e]){if(o||s)return t[e]=u===i?r:o||a?[]:s?{}:null,s=o=!1,t[e]}else if(void 0!==t[e])return u===i&&(t[e]=r),t[e];return t},t)},F=function(t){if("object"==typeof t&&t)for(var e in t)if(-1!==e.indexOf(".")||-1!==e.indexOf("["))q(t,e);else if("object"==typeof t[e]&&t[e]){var r=t[e];for(var n in r)if(-1!==n.indexOf(".")||-1!==n.indexOf("["))q(r,n);else if("object"==typeof r[n]&&r[n]){var i=r[n];for(var o in i)-1===o.indexOf(".")&&-1===o.indexOf("[")||q(i,o)}}return t},S=0,C=g.Linear.None,k=function(){function t(t,e){return this._chainedTweensCount=0,this.id=S++,!t||"object"!=typeof t||e||t.nodeType?t&&(t.nodeType||t.length||"string"==typeof t)&&(t=this.node=I(t),e=this.object=O(t,e,this)):(e=this.object=t,t=null),this._valuesEnd=null,this._valuesStart={},this._duration=1e3,this._easingFunction=C,this._easingReverse=C,this._interpolationFunction=T.Linear,this._startTime=0,this._initTime=0,this._delayTime=0,this._repeat=0,this._r=0,this._isPlaying=!1,this._yoyo=!1,this._reversed=!1,this._onStartCallbackFired=!1,this._pausedTime=null,this._isFinite=!0,this._maxListener=15,this._prevTime=null,this}return t.fromTo=function(e,r,n,i){void 0===i&&(i={}),i.quickRender=i.quickRender?i.quickRender:!n;var o=new t(e,r).to(n,i);return i.quickRender&&(o.render().update(o._startTime),o._rendered=!1,o._onStartCallbackFired=!1),o},t.to=function(e,r,n){return t.fromTo(e,null,r,n)},t.from=function(e,r,n){return t.fromTo(e,r,null,n)},t.prototype.setMaxListener=function(t){return void 0===t&&(t=15),this._maxListener=t,this},t.prototype.on=function(t,e){for(var r=this._maxListener,n=t+"Callback",i=0;i<r;i++){var o=n+i;if(!this[o]){this[o]=e;break}}return this},t.prototype.once=function(t,e){return this},t.prototype.off=function(t,e){for(var r=this._maxListener,n=t+"Callback",i=0;i<r;i++){var o=n+i;this[o]===e&&(this[o]=null)}return this},t.prototype.emit=function(t,e,r,n,i){var o=this._maxListener,s=t+"Callback";if(!this[s+0])return this;for(var u=0;u<o;u++){var a=s+u;this[a]&&this[a](e,r,n,i)}return this},t.prototype.isPlaying=function(){return this._isPlaying},t.prototype.isStarted=function(){return this._onStartCallbackFired},t.prototype.reverse=function(t){var e=this._reversed;return this._reversed=void 0!==t?t:!e,this},t.prototype.reversed=function(){return this._reversed},t.prototype.pause=function(){return this._isPlaying?(this._isPlaying=!1,y(this),this._pausedTime=a(),this.emit("pause",this.object)):this},t.prototype.play=function(){return this._isPlaying?this:(this._isPlaying=!0,this._startTime+=a()-this._pausedTime,this._initTime=this._startTime,d(this),this._pausedTime=a(),this.emit("play",this.object))},t.prototype.restart=function(t){return this._repeat=this._r,this.reassignValues(),d(this),this.emit("restart",this.object)},t.prototype.seek=function(t,e){var r=this,n=r._duration,i=(r._repeat,r._initTime),o=r._startTime,s=(r._delayTime,r._reversed),u=i+t;return this._isPlaying=!0,u<o&&o>=i&&(this._startTime-=n,this._reversed=!s),this.update(t,!1),this.emit("seek",t,this.object),e?this:this.pause()},t.prototype.duration=function(t){return this._duration="function"==typeof t?t(this._duration):t,this},t.prototype.to=function(t,e,r){if(void 0===e&&(e=1e3),this._valuesEnd=t,"number"==typeof e||"function"==typeof e)this._duration="function"==typeof e?e(this._duration):e;else if("object"==typeof e)for(var n in e)if("function"==typeof this[n]){var i=Array.isArray(e[n])?e[n]:[e[n]],o=i[0],s=void 0===o?null:o,u=i[1],a=void 0===u?null:u,f=i[2],h=void 0===f?null:f,p=i[3],c=void 0===p?null:p;this[n](s,a,h,c)}return this},t.prototype.render=function(){if(this._rendered)return this;var t=this,n=t._valuesStart,i=t._valuesEnd,o=t.object,s=t.Renderer,u=t.node,a=t.InitialValues;if(u&&u.queueID&&w[u.queueID]){var f=w[u.queueID];if(f.propNormaliseRequired&&f.tween!==this){for(var h in i)void 0!==f.tween._valuesEnd[h]&&delete f.tween._valuesEnd[h];f.normalisedProp=!0,f.propNormaliseRequired=!1}}F(o),F(i),u&&a&&(o?i||(i=this._valuesEnd=a(u,o)):o=this.object=O(u,a(u,i),this));for(var h in i){var p=o&&o[h],c=i[h];if(m[h]){var l=m[h].prototype.update?new m[h](this,p,c,h,o):m[h](this,p,c,h,o);l&&(i[h]=l)}else"number"==typeof p&&isNaN(p)||null===p||null===c||void 0===p||void 0===c||p===c||(Array.isArray(c)&&"number"==typeof p&&c.unshift(p),n[h]=e(p),r(h,o,n,i))}return s&&this.node&&(this.__render=new s(this,o,i)),this},t.prototype.start=function(t){return this._startTime=void 0!==t?"string"==typeof t?a()+parseFloat(t):t:a(),this._startTime+=this._delayTime,this._initTime=this._prevTime=this._startTime,this._onStartCallbackFired=!1,this._rendered=!1,this._isPlaying=!0,d(this),this},t.prototype.stop=function(){var t=this,e=t._isPlaying,r=t._isFinite,n=t.object,i=t._startTime,o=(t._delayTime,t._duration),s=t._r,u=t._yoyo,a=t._reversed;if(!e)return this;var f=r?(s+1)%2==1:!a;return this._reversed=!1,u&&f?this.update(i):this.update(i+o),y(this),this.emit("stop",n)},t.prototype.delay=function(t){return this._delayTime="function"==typeof t?t(this._delayTime):t,this},t.prototype.chainedTweens=function(){if(this._chainedTweensCount=arguments.length,!this._chainedTweensCount)return this;for(var t=0,e=this._chainedTweensCount;t<e;t++)this["_chainedTweens"+t]=arguments[t];return this},t.prototype.repeat=function(t){return this._repeat=this._duration?"function"==typeof t?t(this._repeat):t:0,this._r=this._repeat,this._isFinite=isFinite(t),this},t.prototype.reverseDelay=function(t){return this._reverseDelayTime="function"==typeof t?t(this._reverseDelayTime):t,this},t.prototype.yoyo=function(t,e){return this._yoyo="function"==typeof t?t(this._yoyo):null===t?this._yoyo:t,t||(this._reversed=!1),this._easingReverse=e||null,this},t.prototype.easing=function(t){return this._easingFunction=t,this},t.prototype.interpolation=function(t){return"function"==typeof t&&(this._interpolationFunction=t),this},t.prototype.reassignValues=function(t){var e=this,r=e._valuesStart,n=e.object,i=e._delayTime;this._isPlaying=!0,this._startTime=void 0!==t?t:a(),this._startTime+=i,this._reversed=!1,d(this);for(var o in r){var s=r[o];n[o]=s}return this},t.prototype.update=function(t,e,r){var i,o,s,u=this,f=u._onStartCallbackFired,h=u._easingFunction,p=u._interpolationFunction,c=u._easingReverse,l=u._repeat,d=u._delayTime,_=u._reverseDelayTime,v=u._yoyo,m=u._reversed,g=u._startTime,T=u._prevTime,b=u._duration,w=u._valuesStart,O=u._valuesEnd,I=u.object,M=u._isFinite,j=u._isPlaying,P=u.__render,A=u._chainedTweensCount,L=0;if(b){var q=(t=void 0!==t?t:a())-T;if(q>250&&(t+=q-50/3),this._prevTime=t,!j||t<g&&!r)return!0;i=(i=(t-g)/b)>1?1:i,i=m?1-i:i}else i=1;if(f||(this._rendered||(this.render(),this._rendered=!0),this.emit("start",I),this._onStartCallbackFired=!0),o=m?c||h:h,!I)return!0;for(s in O){var F=w[s];if(void 0!==F&&null!==F){var k=O[s],R=o[s]?o[s](i):"function"==typeof o?o(i):C(i);"number"==typeof k?I[s]=((F+(k-F)*R)*x|0)/x:Array.isArray(k)&&"number"==typeof F?I[s]=p(k,R):k&&k.update?k.update(R):"function"==typeof k?I[s]=k(R):n(s,I,w,O,R,i),L++}}if(!L)return y(this),!1;if(P&&P.update(I,i),this.emit("update",I,i,t),1===i||m&&!i){if(l>0&&b>0)return M&&this._repeat--,v&&(this._reversed=!m),this.emit(v&&!m?"reverse":"repeat",I),this._startTime=m&&_?t-_:t+d,!0;if(e||(this._isPlaying=!1,y(this),S--),this.emit("complete",I),this._repeat=this._r,A)for(var D=0;D<A;D++)this["_chainedTweens"+D].start(t+b);return!1}return!0},t}(),R=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),D=this&&this.__assign||Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++){e=arguments[r];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},E=function(t){var e,r,n;for(n=t.length;n;n-=1)e=Math.floor(Math.random()*n),r=t[n-1],t[n-1]=t[e],t[e]=r;return t},N=0,B=function(t){function e(e){var r=t.call(this)||this;return r._duration=0,r._startTime=a(),r._tweens=[],r.elapsed=0,r._id=N++,r._defaultParams=e,r.position=new b,r.position.addLabel("afterLast",r._duration),r.position.addLabel("afterInit",r._startTime),r}return R(e,t),e.prototype.mapTotal=function(t){return t.call(this,this._tweens),this},e.prototype.timingOrder=function(t){var e=t(this._tweens.map(function(t){return t._startTime}));return this._tweens.map(function(t,r){t._startTime=e[r]}),this},e.prototype.getTiming=function(t,e,r,n){if(void 0===n&&(n=0),"reverse"===t){var i=r.stagger,o=(i||0)*(e.length-1);return e.map(function(t,e){return o-(i||0)*e+n})}if("async"===t)return e.map(function(t){return n});if("sequence"===t||"delayed"===t){var s=r.stagger;return s||(s=(r.duration||1e3)/(e.length-1)),e.map(function(t,e){return s*e+n})}if("oneByOne"===t)return e.map(function(t){return r.duration});if("shuffle"===t){var u=r.stagger;return E(e.map(function(t,e){return(u||0)*e+n}))}var a=r.stagger;return e.map(function(t,e){return(a||0)*e+n})},e.prototype.fromTo=function(t,e,r,n){if((t=I(t,!0))&&t.length){this._defaultParams&&(n=D({},this._defaultParams,n));for(var i=n.label,o="number"==typeof i?i:this.position.parseLabel(void 0!==i?i:"afterLast",null),s=this.getTiming(n.mode,t,n,o),u=0,a=void 0,f=t.length;u<f;u++)a=t[u],this.add(k.fromTo(a,"function"==typeof e?e(u,t.length):D({},e),"function"==typeof r?r(u,t.length):r,"function"==typeof n?n(u,t.length):n),s[u])}return this.start()},e.prototype.from=function(t,e,r){return this.fromTo(t,e,null,r)},e.prototype.to=function(t,e,r){return this.fromTo(t,null,e,r)},e.prototype.addLabel=function(t,e){return this.position.addLabel(t,e),this},e.prototype.map=function(t){for(var e=0,r=this._tweens.length;e<r;e++){var n=this._tweens[e];t(n,e),this._duration=Math.max(this._duration,n._duration+n._startTime)}return this},e.prototype.add=function(t,e){var r=this;if(Array.isArray(t))return t.map(function(t){r.add(t,e)}),this;"object"!=typeof t||t instanceof k||(t=new k(t.from).to(t.to,t));var n=this,i=n._defaultParams,o=n._duration;if(i)for(var s in i)"function"==typeof t[s]&&t[s](i[s]);var u="number"==typeof e?e:this.position.parseLabel(void 0!==e?e:"afterLast",null);return t._startTime=Math.max(this._startTime,t._delayTime,u),t._delayTime=u,t._isPlaying=!0,this._duration=Math.max(o,t._startTime+t._delayTime+t._duration),this._tweens.push(t),this.position.setLabel("afterLast",this._duration),this},e.prototype.restart=function(){return this._startTime+=a(),d(this),this.emit("restart")},e.prototype.easing=function(t){return this.map(function(e){return e.easing(t)})},e.prototype.interpolation=function(t){return this.map(function(e){return e.interpolation(t)})},e.prototype.update=function(t){var e=this,r=e._tweens,n=e._duration,i=e._reverseDelayTime,o=e._startTime,s=e._reversed,u=e._yoyo,a=e._repeat,f=e._isFinite;if(!e._isPlaying||t<o)return!0;var h=(t-o)/n;h=h>1?1:h,h=s?1-h:h,this.elapsed=h;for(var p=t-o,c=s?n-p:p,l=0;l<r.length;)r[l].update(c),l++;if(this.emit("update",h,p),1===h||s&&0===h){if(a){for(f&&this._repeat--,this.emit(s?"reverse":"repeat"),u&&(this._reversed=!s,this.timingOrder(function(t){return t.reverse()})),this._startTime=s&&i?t+i:t,l=0;l<r.length;)r[l].reassignValues(t),l++;return!0}return this.emit("complete"),this._repeat=this._r,y(this),this._isPlaying=!1,!1}return!0},e.prototype.progress=function(t){return void 0!==t?this.update(t*this._duration):this.elapsed},e}(k);t.Plugins=m,t.Selector=I,t.onTick=function(t){return f.push({update:t})},t.has=function(t){return null!==_(t)},t.get=_,t.getAll=function(){return f},t.removeAll=function(){f.length=0},t.remove=y,t.add=d,t.now=a,t.update=v,t.autoPlay=function(t){p=t},t.isRunning=function(){return h},t.Tween=k,t.Easing=g,t.Interpolation=T,t.Timeline=B,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.TWEEN={})}(this,function(t){"use strict";function e(t){if(void 0===t||"object"!=typeof t)return t;if(Array.isArray(t))return[].concat(t);if("object"==typeof t){var r={};for(var n in t)r[n]=e(t[n]);return r}return t}function r(t,e,n,i){var o=n[t],s=i[t];if("string"==typeof o&&"string"==typeof s){var u=o.match(P).map(function(t){return A(t)?t:+t}),a=s.match(P).map(function(t,e){return A(t)?t:+t});return u.unshift(M),n[t]=u,i[t]=a,!0}if("object"==typeof o&&"object"==typeof s){if(Array.isArray(o))return o.map(function(n,i){return r(i,e[t],o,s)});for(var f in s)r(f,e[t],o,s);return!0}return!1}function n(t,e,r,i,o,s){var u=r[t],a=i[t];if(void 0===a)return u;if(void 0===u||"string"==typeof u||u===a)return a;if("object"==typeof u&&"object"==typeof a){if(!u||!a)return e[t];if(u[0]===M){for(var f="",h=1,p=u.length;h<p;h++){l="string"==typeof a[h-1];f+="number"!=typeof a[h-1]?u[h]:((l?u[h]+ +a[h-1]:u[h]+(a[h-1]-u[h])*o)*L|0)/L,1===s&&(u[h]=u[h]+ +a[h-1])}return e[t]=f,f}if(Array.isArray(u))for(var h=0,p=u.length;h<p;h++)u[h]!==a[h]&&n(h,e[t],u,a,o,s);else for(var h in u)u[h]!==a[h]&&n(h,e[t],u,a,o,s)}else if("number"==typeof u){var l="string"==typeof a;e[t]=((l?u+ +a*o:u+(a-u)*o)*L|0)/L,l&&1===s&&(r[t]=e[t])}else"function"==typeof a&&(e[t]=a(o));return e[t]}var i,o="undefined"!=typeof window?window:"undefined"!=typeof global?global:this,s=o.requestAnimationFrame||function(t){return o.setTimeout(t,16)},u=o.cancelAnimationFrame||function(t){return o.clearTimeout(t)},a=function(){if("undefined"!=typeof process&&void 0!==process.hrtime)return function(){var t=process.hrtime();return 1e3*t[0]+t[1]/1e6};if(void 0!==o.performance&&void 0!==o.performance.now)return o.performance.now.bind(o.performance);var t=o.performance&&o.performance.timing&&o.performance.timing.navigationStart?o.performance.timing.navigationStart:Date.now();return function(){return Date.now()-t}}(),f=[],h=!1,p=!1,l=s,c=u,d=0,_=function(t){var e=f.indexOf(t);if(e>-1&&f.splice(e,1),f.length>0){e=f.length-1;var r=f[e];t.prev=r,r.next=t}f.push(t),d=0,p&&!h&&(i=l(m),h=!0)},y=function(t){for(var e=0;e<f.length;e++)if(t===f[e])return f[e];return null},v=function(t){var e=f.indexOf(t);-1!==e&&f.splice(e,1)},m=function(t,e){if(t=void 0!==t?t:a(),p&&h&&(i=l(m)),f.length||d++,d>120)return c(i),h=!1,d=0,!1;for(var r=0;r<f.length;)f[r++].update(t,e);return!0},g={},T={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(2,-10*t)},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(2-Math.pow(2,-10*(t-1)))}},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(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)},Out:function(t){return 0===t?0:1===t?1:Math.pow(2,-10*t)*Math.sin(5*(t-.1)*Math.PI)+1},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?-.5*Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI):.5*Math.pow(2,-10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)+1}},Back:{In:function(t){var e=1.70158;return t*t*((e+1)*t-e)},Out:function(t){var e=1.70158;return--t*t*((e+1)*t+e)+1},InOut:function(t){var e=2.5949095;return(t*=2)<1?t*t*((e+1)*t-e)*.5:.5*((t-=2)*t*((e+1)*t+e)+2)}},Bounce:{In:function(t){return 1-T.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*T.Bounce.In(2*t):.5*T.Bounce.Out(2*t-1)+.5}},Stepped:{steps:function(t){return function(e){return(e*t|0)/t}}}},b={Linear:function(t,e,r){var n=t.length-1,i=n*e,o=Math.floor(i),s=b.Utils.Linear;return e<0?s(t[0],t[1],i,r):e>1?s(t[n],t[n-1],n-i,r):s(t[o],t[o+1>n?n:o+1],i-o,r)},Bezier:function(t,e,r){for(var n=0,i=t.length-1,o=Math.pow,s=b.Utils.Bernstein,u=0;u<=i;u++)n+=o(1-e,i-u)*o(e,u)*t[u]*s(i,u);return n},CatmullRom:function(t,e,r){var n=t.length-1,i=n*e,o=Math.floor(i),s=b.Utils.CatmullRom;return t[0]===t[n]?(e<0&&(o=Math.floor(i=n*(1+e))),s(t[(o-1+n)%n],t[o],t[(o+1)%n],t[(o+2)%n],i-o,r)):e<0?t[0]-(s(t[0],t[0],t[1],t[1],-i,r)-t[0]):e>1?t[n]-(s(t[n],t[n],t[n-1],t[n-1],i-n,r)-t[n]):s(t[o?o-1:0],t[o],t[n<o+1?n:o+1],t[n<o+2?n:o+2],i-o,r)},Utils:{Linear:function(t,e,r,n){if("string"==typeof n)return e;if("number"==typeof n)return"function"==typeof t?t(r):(e-t)*r+t;if("object"==typeof n){if(void 0!==n.length)for(var i=0,o=n.length;i<o;i++)n[i]=b.Utils.Linear(t[i],e[i],r,n[i]);else for(var i in n)n[i]=b.Utils.Linear(t[i],e[i],r,n[i]);return n}},Bernstein:function(t,e){var r=b.Utils.Factorial;return r(t)/r(e)/r(t-e)},Factorial:function(){var t=[1];return function(e){var r=1;if(t[e])return t[e];for(var n=e;n>1;n--)r*=n;return t[e]=r,r}}(),CatmullRom:function(t,e,r,n,i,o){if("string"==typeof o)return e;if("number"==typeof o){var s=.5*(r-t),u=.5*(n-e),a=i*i;return(2*e-2*r+s+u)*(i*a)+(-3*e+3*r-2*s-u)*a+s*i+e}if("object"==typeof o){if(void 0!==o.length)for(var f=0,h=o.length;f<h;f++)o[f]=b.Utils.CatmullRom(t[f],e[f],r[f],n[f],i,o[f]);else for(var f in o)o[f]=b.Utils.CatmullRom(t[f],e[f],r[f],n[f],i,o[f]);return o}}}},w=function(){function t(){this.totalTime=0,this.labels=[],this.offsets=[]}return t.prototype.parseLabel=function(t,e){var r=this,n=r.offsets,i=r.labels,o=i.indexOf(t);if("string"==typeof t&&-1!==t.indexOf("=")&&!e&&-1===o){var s=t.substr(t.indexOf("=")-1,2),u=t.split(s);e=2===u.length?s+u[1]:null,t=u[0],o=i.indexOf(t)}if(-1!==o&&t){var a=n[o]||0;if("number"==typeof e)a=e;else if("string"==typeof e&&-1!==e.indexOf("=")){var f=e.charAt(0);e=Number(e.substr(2)),"+"===f||"-"===f?a+=parseFloat(f+e):"*"===f?a*=e:"/"===f?a/=e:"%"===f&&(a*=e/100)}return a}return"number"==typeof e?e:0},t.prototype.addLabel=function(t,e){return this.labels.push(t),this.offsets.push(this.parseLabel(t,e)),this},t.prototype.setLabel=function(t,e){var r=this.labels.indexOf(t);return-1!==r&&this.offsets.splice(r,1,this.parseLabel(t,e)),this},t.prototype.eraseLabel=function(t){var e=this.labels.indexOf(t);return-1!==e&&(this.labels.splice(e,1),this.offsets.splice(e,1)),this},t}(),O={},j=function(t,e,r){if(!t||!t.nodeType)return e;var n=t.queueID||"q_"+Date.now();t.queueID||(t.queueID=n);var i=O[n];if(i){if(i.object!==e||t!==i.tween.node||r._startTime!==i.tween._startTime){for(var o in e)o in i.object&&(r._startTime===i.tween._startTime?delete i.object[o]:i.propNormaliseRequired=!0);return e}return v(i.tween),i.object}return O[n]={tween:r,object:e,propNormaliseRequired:!1},O[n].object},I=function(t,e){return e?t?t===window||t===document?[t]:"string"==typeof t?!!document.querySelectorAll&&document.querySelectorAll(t):Array.isArray(t)?t:t.nodeType?[t]:[]:null:t?t===window||t===document?t:"string"==typeof t?!!document.querySelector&&document.querySelector(t):Array.isArray(t)?t[0]:t.nodeType?t:null:null},M="STRING_PROP",P=/\s+|([A-Za-z?().,{}:""[\]#\%]+)|([-+]+)?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,A=function(t){return isNaN(+t)||"+"===t[0]||"-"===t[0]||""===t||" "===t},L=Math.pow(10,4),x=/([.\[])/g,q=/\]/g,F=function(t,e){var r=t[e],n=e.replace(q,"").split(x),i=n.length-1,o=Array.isArray(t),s="object"==typeof t&&!o;return s?(t[e]=null,delete t[e]):o&&t.splice(e,1),n.reduce(function(t,e,u){o&&"."!==e&&"["!==e&&(e*=1);var a="["===n[u+1];if("."===e||"["===e)return"."===e?(s=!0,o=!1):"["===e&&(s=!1,o=!0),t;if(void 0===t[e]){if(o||s)return t[e]=u===i?r:o||a?[]:s?{}:null,s=o=!1,t[e]}else if(void 0!==t[e])return u===i&&(t[e]=r),t[e];return t},t)},C=function(t){if("object"==typeof t&&t)for(var e in t)if(-1!==e.indexOf(".")||-1!==e.indexOf("["))F(t,e);else if("object"==typeof t[e]&&t[e]){var r=t[e];for(var n in r)if(-1!==n.indexOf(".")||-1!==n.indexOf("["))F(r,n);else if("object"==typeof r[n]&&r[n]){var i=r[n];for(var o in i)-1===o.indexOf(".")&&-1===o.indexOf("[")||F(i,o)}}return t},S=0,R=T.Linear.None,k=function(){function t(t,e){return this._chainedTweensCount=0,this.id=S++,!t||"object"!=typeof t||e||t.nodeType?t&&(t.nodeType||t.length||"string"==typeof t)&&(t=this.node=I(t),e=this.object=j(t,e,this)):(e=this.object=t,t=null),this._valuesEnd=null,this._valuesStart={},this._duration=1e3,this._easingFunction=R,this._easingReverse=R,this._interpolationFunction=b.Linear,this._startTime=0,this._initTime=0,this._delayTime=0,this._repeat=0,this._r=0,this._isPlaying=!1,this._yoyo=!1,this._reversed=!1,this._onStartCallbackFired=!1,this._pausedTime=null,this._isFinite=!0,this._maxListener=15,this._prevTime=null,this}return t.fromTo=function(e,r,n,i){void 0===i&&(i={}),i.quickRender=i.quickRender?i.quickRender:!n;var o=new t(e,r).to(n,i);return i.quickRender&&(o.render().update(o._startTime),o._rendered=!1,o._onStartCallbackFired=!1),o},t.to=function(e,r,n){return t.fromTo(e,null,r,n)},t.from=function(e,r,n){return t.fromTo(e,r,null,n)},t.prototype.setMaxListener=function(t){return void 0===t&&(t=15),this._maxListener=t,this},t.prototype.on=function(t,e){for(var r=this._maxListener,n=t+"Callback",i=0;i<r;i++){var o=n+i;if(!this[o]){this[o]=e;break}}return this},t.prototype.once=function(t,e){return this},t.prototype.off=function(t,e){for(var r=this._maxListener,n=t+"Callback",i=0;i<r;i++){var o=n+i;this[o]===e&&(this[o]=null)}return this},t.prototype.emit=function(t,e,r,n,i){var o=this._maxListener,s=t+"Callback";if(!this[s+0])return this;for(var u=0;u<o;u++){var a=s+u;this[a]&&this[a](e,r,n,i)}return this},t.prototype.isPlaying=function(){return this._isPlaying},t.prototype.isStarted=function(){return this._onStartCallbackFired},t.prototype.reverse=function(t){var e=this._reversed;return this._reversed=void 0!==t?t:!e,this},t.prototype.reversed=function(){return this._reversed},t.prototype.pause=function(){return this._isPlaying?(this._isPlaying=!1,v(this),this._pausedTime=a(),this.emit("pause",this.object)):this},t.prototype.play=function(){return this._isPlaying?this:(this._isPlaying=!0,this._startTime+=a()-this._pausedTime,this._initTime=this._startTime,_(this),this._pausedTime=a(),this.emit("play",this.object))},t.prototype.restart=function(t){return this._repeat=this._r,this.reassignValues(),_(this),this.emit("restart",this.object)},t.prototype.seek=function(t,e){var r=this,n=r._duration,i=(r._repeat,r._initTime),o=r._startTime,s=(r._delayTime,r._reversed),u=i+t;return this._isPlaying=!0,u<o&&o>=i&&(this._startTime-=n,this._reversed=!s),this.update(t,!1),this.emit("seek",t,this.object),e?this:this.pause()},t.prototype.duration=function(t){return this._duration="function"==typeof t?t(this._duration):t,this},t.prototype.to=function(t,e,r){if(void 0===e&&(e=1e3),this._valuesEnd=t,"number"==typeof e||"function"==typeof e)this._duration="function"==typeof e?e(this._duration):e;else if("object"==typeof e)for(var n in e)if("function"==typeof this[n]){var i=Array.isArray(e[n])?e[n]:[e[n]],o=i[0],s=void 0===o?null:o,u=i[1],a=void 0===u?null:u,f=i[2],h=void 0===f?null:f,p=i[3],l=void 0===p?null:p;this[n](s,a,h,l)}return this},t.prototype.render=function(){if(this._rendered)return this;var t=this,n=t._valuesStart,i=t._valuesEnd,o=t.object,s=t.Renderer,u=t.node,a=t.InitialValues;if(u&&u.queueID&&O[u.queueID]){var f=O[u.queueID];if(f.propNormaliseRequired&&f.tween!==this){for(var h in i)void 0!==f.tween._valuesEnd[h]&&delete f.tween._valuesEnd[h];f.normalisedProp=!0,f.propNormaliseRequired=!1}}C(o),C(i),u&&a&&(o?i||(i=this._valuesEnd=a(u,o)):o=this.object=j(u,a(u,i),this));for(var h in i){var p=o&&o[h],l=i[h];if(g[h]){var c=g[h].prototype.update?new g[h](this,p,l,h,o):g[h](this,p,l,h,o);c&&(i[h]=c)}else"number"==typeof p&&isNaN(p)||null===p||null===l||void 0===p||void 0===l||p===l||(Array.isArray(l)&&!Array.isArray(p)&&l.unshift(p),n[h]=e(p),r(h,o,n,i))}return s&&this.node&&(this.__render=new s(this,o,i)),this},t.prototype.start=function(t){return this._startTime=void 0!==t?"string"==typeof t?a()+parseFloat(t):t:a(),this._startTime+=this._delayTime,this._initTime=this._prevTime=this._startTime,this._onStartCallbackFired=!1,this._rendered=!1,this._isPlaying=!0,_(this),this},t.prototype.stop=function(){var t=this,e=t._isPlaying,r=t._isFinite,n=t.object,i=t._startTime,o=(t._delayTime,t._duration),s=t._r,u=t._yoyo,a=t._reversed;if(!e)return this;var f=r?(s+1)%2==1:!a;return this._reversed=!1,u&&f?this.update(i):this.update(i+o),v(this),this.emit("stop",n)},t.prototype.delay=function(t){return this._delayTime="function"==typeof t?t(this._delayTime):t,this},t.prototype.chainedTweens=function(){if(this._chainedTweensCount=arguments.length,!this._chainedTweensCount)return this;for(var t=0,e=this._chainedTweensCount;t<e;t++)this["_chainedTweens"+t]=arguments[t];return this},t.prototype.repeat=function(t){return this._repeat=this._duration?"function"==typeof t?t(this._repeat):t:0,this._r=this._repeat,this._isFinite=isFinite(t),this},t.prototype.reverseDelay=function(t){return this._reverseDelayTime="function"==typeof t?t(this._reverseDelayTime):t,this},t.prototype.yoyo=function(t,e){return this._yoyo="function"==typeof t?t(this._yoyo):null===t?this._yoyo:t,t||(this._reversed=!1),this._easingReverse=e||null,this},t.prototype.easing=function(t){return this._easingFunction=t,this},t.prototype.interpolation=function(t){return"function"==typeof t&&(this._interpolationFunction=t),this},t.prototype.reassignValues=function(t){var e=this,r=e._valuesStart,n=e.object,i=e._delayTime;this._isPlaying=!0,this._startTime=void 0!==t?t:a(),this._startTime+=i,this._reversed=!1,_(this);for(var o in r){var s=r[o];n[o]=s}return this},t.prototype.update=function(t,e,r){var i,o,s,u=this,f=u._onStartCallbackFired,h=u._easingFunction,p=u._interpolationFunction,l=u._easingReverse,c=u._repeat,d=u._delayTime,_=u._reverseDelayTime,y=u._yoyo,m=u._reversed,g=u._startTime,T=u._prevTime,b=u._duration,w=u._valuesStart,O=u._valuesEnd,j=u.object,I=u._isFinite,M=u._isPlaying,P=u.__render,A=u._chainedTweensCount,x=0;if(b){var q=(t=void 0!==t?t:a())-T;if(q>250&&(t+=q-50/3),this._prevTime=t,!M||t<g&&!r)return!0;i=(i=(t-g)/b)>1?1:i,i=m?1-i:i}else i=1;if(f||(this._rendered||(this.render(),this._rendered=!0),this.emit("start",j),this._onStartCallbackFired=!0),o=m?l||h:h,!j)return!0;for(s in O){var F=w[s];if(void 0!==F&&null!==F){var C=O[s],k=o[s]?o[s](i):"function"==typeof o?o(i):R(i);"number"==typeof C?j[s]=((F+(C-F)*k)*L|0)/L:Array.isArray(C)&&!Array.isArray(F)?j[s]=p(C,k,j[s]):C&&C.update?C.update(k):"function"==typeof C?j[s]=C(k):n(s,j,w,O,k,i),x++}}if(!x)return v(this),!1;if(P&&P.update(j,i),this.emit("update",j,i,t),1===i||m&&!i){if(c>0&&b>0)return I&&this._repeat--,y&&(this._reversed=!m),this.emit(y&&!m?"reverse":"repeat",j),this._startTime=m&&_?t-_:t+d,!0;if(e||(this._isPlaying=!1,v(this),S--),this.emit("complete",j),this._repeat=this._r,A)for(var D=0;D<A;D++)this["_chainedTweens"+D].start(t+b);return!1}return!0},t}(),D=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),E=this&&this.__assign||Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++){e=arguments[r];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},N=function(t){var e,r,n;for(n=t.length;n;n-=1)e=Math.floor(Math.random()*n),r=t[n-1],t[n-1]=t[e],t[e]=r;return t},B=0,U=function(t){function e(e){var r=t.call(this)||this;return r._duration=0,r._startTime=a(),r._tweens=[],r.elapsed=0,r._id=B++,r._defaultParams=e,r.position=new w,r.position.addLabel("afterLast",r._duration),r.position.addLabel("afterInit",r._startTime),r}return D(e,t),e.prototype.mapTotal=function(t){return t.call(this,this._tweens),this},e.prototype.timingOrder=function(t){var e=t(this._tweens.map(function(t){return t._startTime}));return this._tweens.map(function(t,r){t._startTime=e[r]}),this},e.prototype.getTiming=function(t,e,r,n){if(void 0===n&&(n=0),"reverse"===t){var i=r.stagger,o=(i||0)*(e.length-1);return e.map(function(t,e){return o-(i||0)*e+n})}if("async"===t)return e.map(function(t){return n});if("sequence"===t||"delayed"===t){var s=r.stagger;return s||(s=(r.duration||1e3)/(e.length-1)),e.map(function(t,e){return s*e+n})}if("oneByOne"===t)return e.map(function(t){return r.duration});if("shuffle"===t){var u=r.stagger;return N(e.map(function(t,e){return(u||0)*e+n}))}var a=r.stagger;return e.map(function(t,e){return(a||0)*e+n})},e.prototype.fromTo=function(t,e,r,n){if((t=I(t,!0))&&t.length){this._defaultParams&&(n=E({},this._defaultParams,n));for(var i=n.label,o="number"==typeof i?i:this.position.parseLabel(void 0!==i?i:"afterLast",null),s=this.getTiming(n.mode,t,n,o),u=0,a=void 0,f=t.length;u<f;u++)a=t[u],this.add(k.fromTo(a,"function"==typeof e?e(u,t.length):E({},e),"function"==typeof r?r(u,t.length):r,"function"==typeof n?n(u,t.length):n),s[u])}return this.start()},e.prototype.from=function(t,e,r){return this.fromTo(t,e,null,r)},e.prototype.to=function(t,e,r){return this.fromTo(t,null,e,r)},e.prototype.addLabel=function(t,e){return this.position.addLabel(t,e),this},e.prototype.map=function(t){for(var e=0,r=this._tweens.length;e<r;e++){var n=this._tweens[e];t(n,e),this._duration=Math.max(this._duration,n._duration+n._startTime)}return this},e.prototype.add=function(t,e){var r=this;if(Array.isArray(t))return t.map(function(t){r.add(t,e)}),this;"object"!=typeof t||t instanceof k||(t=new k(t.from).to(t.to,t));var n=this,i=n._defaultParams,o=n._duration;if(i)for(var s in i)"function"==typeof t[s]&&t[s](i[s]);var u="number"==typeof e?e:this.position.parseLabel(void 0!==e?e:"afterLast",null);return t._startTime=Math.max(this._startTime,t._delayTime,u),t._delayTime=u,t._isPlaying=!0,this._duration=Math.max(o,t._startTime+t._delayTime+t._duration),this._tweens.push(t),this.position.setLabel("afterLast",this._duration),this},e.prototype.restart=function(){return this._startTime+=a(),_(this),this.emit("restart")},e.prototype.easing=function(t){return this.map(function(e){return e.easing(t)})},e.prototype.interpolation=function(t){return this.map(function(e){return e.interpolation(t)})},e.prototype.update=function(t){var e=this,r=e._tweens,n=e._duration,i=e._reverseDelayTime,o=e._startTime,s=e._reversed,u=e._yoyo,a=e._repeat,f=e._isFinite;if(!e._isPlaying||t<o)return!0;var h=(t-o)/n;h=h>1?1:h,h=s?1-h:h,this.elapsed=h;for(var p=t-o,l=s?n-p:p,c=0;c<r.length;)r[c].update(l),c++;if(this.emit("update",h,p),1===h||s&&0===h){if(a){for(f&&this._repeat--,this.emit(s?"reverse":"repeat"),u&&(this._reversed=!s,this.timingOrder(function(t){return t.reverse()})),this._startTime=s&&i?t+i:t,c=0;c<r.length;)r[c].reassignValues(t),c++;return!0}return this.emit("complete"),this._repeat=this._r,v(this),this._isPlaying=!1,!1}return!0},e.prototype.progress=function(t){return void 0!==t?this.update(t*this._duration):this.elapsed},e}(k);t.Plugins=g,t.Selector=I,t.onTick=function(t){return f.push({update:t})},t.has=function(t){return null!==y(t)},t.get=y,t.getAll=function(){return f},t.removeAll=function(){f.length=0},t.remove=v,t.add=_,t.now=a,t.update=m,t.autoPlay=function(t){p=t},t.isRunning=function(){return h},t.Tween=k,t.Easing=T,t.Interpolation=b,t.Timeline=U,Object.defineProperty(t,"__esModule",{value:!0})}); |
{ | ||
"name": "es6-tween", | ||
"version": "4.0.2", | ||
"version": "4.1.0", | ||
"description": "ES6 implementation of amazing tween.js", | ||
@@ -5,0 +5,0 @@ "browser": "full/Tween.min.js", |
@@ -85,5 +85,2 @@ # es6-tween | ||
import { Easing, Tween, autoPlay } from 'es6-tween' | ||
// Lite | ||
import { Easing, Interpolation, Tween, autoPlay } from 'es6-tween/src/index.lite' | ||
``` | ||
@@ -90,0 +87,0 @@ |
@@ -39,3 +39,5 @@ // Frame lag-fix constants | ||
} | ||
var isNaNForST = function (v) { return isNaN(+v) || v[0] === '+' || v[0] === '-' || v === '' || v === ' '; }; | ||
var isNaNForST = function (v) { | ||
return isNaN(+v) || v[0] === '+' || v[0] === '-' || v === '' || v === ' '; | ||
}; | ||
// Decompose value, now for only `string` that required | ||
@@ -46,4 +48,8 @@ export function decompose(prop, obj, from, to) { | ||
if (typeof fromValue === 'string' && typeof toValue === 'string') { | ||
var fromValue1 = fromValue.match(NUM_REGEX).map(function (v) { return isNaNForST(v) ? v : +v; }); | ||
var toValue1 = toValue.match(NUM_REGEX).map(function (v, i) { return isNaNForST(v) ? v : +v; }); | ||
var fromValue1 = fromValue | ||
.match(NUM_REGEX) | ||
.map(function (v) { return (isNaNForST(v) ? v : +v); }); | ||
var toValue1 = toValue | ||
.match(NUM_REGEX) | ||
.map(function (v, i) { return (isNaNForST(v) ? v : +v); }); | ||
fromValue1.unshift(STRING_PROP); | ||
@@ -56,3 +62,5 @@ from[prop] = fromValue1; | ||
if (Array.isArray(fromValue)) { | ||
return fromValue.map(function (v, i) { return decompose(i, obj[prop], fromValue, toValue); }); | ||
return fromValue.map(function (v, i) { | ||
return decompose(i, obj[prop], fromValue, toValue); | ||
}); | ||
} | ||
@@ -76,3 +84,5 @@ else { | ||
} | ||
if (fromValue === undefined || typeof fromValue === 'string' || fromValue === toValue) { | ||
if (fromValue === undefined || | ||
typeof fromValue === 'string' || | ||
fromValue === toValue) { | ||
return toValue; | ||
@@ -88,5 +98,13 @@ } | ||
var isRelative = typeof toValue[i - 1] === 'string'; | ||
STRING_BUFFER += typeof toValue[i - 1] !== 'number' ? fromValue[i] : (((isRelative ? fromValue[i] + (+toValue[i - 1]) : fromValue[i] + (toValue[i - 1] - fromValue[i]) * t) * DECIMAL) | 0) / DECIMAL; | ||
STRING_BUFFER += | ||
typeof toValue[i - 1] !== 'number' | ||
? fromValue[i] | ||
: (((isRelative | ||
? fromValue[i] + +toValue[i - 1] | ||
: fromValue[i] + (toValue[i - 1] - fromValue[i]) * t) * | ||
DECIMAL) | | ||
0) / | ||
DECIMAL; | ||
if (originalT === 1) { | ||
fromValue[i] = fromValue[i] + (+toValue[i - 1]); | ||
fromValue[i] = fromValue[i] + +toValue[i - 1]; | ||
} | ||
@@ -116,3 +134,9 @@ } | ||
var isRelative = typeof toValue === 'string'; | ||
obj[prop] = (((isRelative ? fromValue + (+toValue) * t : fromValue + (toValue - fromValue) * t) * DECIMAL) | 0) / DECIMAL; | ||
obj[prop] = | ||
(((isRelative | ||
? fromValue + +toValue * t | ||
: fromValue + (toValue - fromValue) * t) * | ||
DECIMAL) | | ||
0) / | ||
DECIMAL; | ||
if (isRelative && originalT === 1) { | ||
@@ -167,5 +191,6 @@ from[prop] = obj[prop]; | ||
if (lastArr || lastObj) { | ||
nested[prop] = index === propsLastIndex ? value : lastArr || nextIsArray ? [] : | ||
lastObj ? {} | ||
: null; | ||
nested[prop] = | ||
index === propsLastIndex | ||
? value | ||
: lastArr || nextIsArray ? [] : lastObj ? {} : null; | ||
lastObj = lastArr = false; | ||
@@ -172,0 +197,0 @@ return nested[prop]; |
@@ -11,3 +11,3 @@ /* global process */ | ||
var now = (function () { | ||
if (typeof (process) !== 'undefined' && process.hrtime !== undefined) { | ||
if (typeof process !== 'undefined' && process.hrtime !== undefined) { | ||
return function () { | ||
@@ -28,3 +28,7 @@ var time = process.hrtime(); | ||
else { | ||
var offset_1 = root.performance && root.performance.timing && root.performance.timing.navigationStart ? root.performance.timing.navigationStart : Date.now(); | ||
var offset_1 = root.performance && | ||
root.performance.timing && | ||
root.performance.timing.navigationStart | ||
? root.performance.timing.navigationStart | ||
: Date.now(); | ||
return function () { | ||
@@ -34,3 +38,3 @@ return Date.now() - offset_1; | ||
} | ||
}()); | ||
})(); | ||
/** | ||
@@ -51,2 +55,4 @@ * Lightweight, effecient and modular ES6 version of tween.js | ||
var _stopTicker = cancelAnimationFrame; | ||
var emptyFrame = 0; | ||
var powerModeThrottle = 120; | ||
/** | ||
@@ -73,2 +79,3 @@ * Adds tween to list | ||
_tweens.push(tween); | ||
emptyFrame = 0; | ||
if (_autoPlay && !isStarted) { | ||
@@ -88,2 +95,13 @@ _tick = _ticker(update); | ||
/** | ||
* Sets after how much frames empty updating should stop | ||
* @param {number} [frameCount=120] count of frames that should stop after all tweens removed | ||
* @memberof TWEEN | ||
* @example | ||
* TWEEN.FrameThrottle(60) | ||
*/ | ||
var FrameThrottle = function (frameCount) { | ||
if (frameCount === void 0) { frameCount = 120; } | ||
powerModeThrottle = frameCount; | ||
}; | ||
/** | ||
* @returns {Array<Tween>} List of tweens in Array | ||
@@ -163,4 +181,8 @@ * @memberof TWEEN | ||
if (!_tweens.length) { | ||
emptyFrame++; | ||
} | ||
if (emptyFrame > powerModeThrottle) { | ||
_stopTicker(_tick); | ||
isStarted = false; | ||
emptyFrame = 0; | ||
return false; | ||
@@ -194,2 +216,2 @@ } | ||
var Plugins = {}; | ||
export { Plugins, get, has, getAll, removeAll, remove, add, now, update, autoPlay, onTick, isRunning }; | ||
export { Plugins, get, has, getAll, removeAll, remove, add, now, update, autoPlay, onTick, isRunning, }; |
@@ -1,2 +0,2 @@ | ||
import { add, onTick, autoPlay, get, getAll, has, isRunning, now, Plugins, remove, removeAll, update } from './core'; | ||
import { add, onTick, autoPlay, get, getAll, has, isRunning, now, Plugins, remove, removeAll, update, } from './core'; | ||
import Easing from './Easing'; | ||
@@ -8,2 +8,2 @@ import Interpolation from './Interpolation'; | ||
import './shim'; | ||
export { Plugins, Selector, onTick, has, get, getAll, removeAll, remove, add, now, update, autoPlay, isRunning, Tween, Easing, Interpolation, Timeline }; | ||
export { Plugins, Selector, onTick, has, get, getAll, removeAll, remove, add, now, update, autoPlay, isRunning, Tween, Easing, Interpolation, Timeline, }; |
@@ -12,12 +12,12 @@ /** | ||
declare const Interpolation: { | ||
Linear(v: any, k: any): any; | ||
Bezier(v: any, k: any): number; | ||
CatmullRom(v: any, k: any): any; | ||
Linear(v: any, k: any, value: any): any; | ||
Bezier(v: any, k: any, value: any): number; | ||
CatmullRom(v: any, k: any, value: any): any; | ||
Utils: { | ||
Linear(p0: any, p1: any, t: any): any; | ||
Linear(p0: any, p1: any, t: any, v: any): any; | ||
Bernstein(n: any, i: any): number; | ||
Factorial: (n: any) => number; | ||
CatmullRom(p0: any, p1: any, p2: any, p3: any, t: any): any; | ||
CatmullRom(p0: any, p1: any, p2: any, p3: any, t: any, v: any): any; | ||
}; | ||
}; | ||
export default Interpolation; |
@@ -12,3 +12,3 @@ /** | ||
var Interpolation = { | ||
Linear: function (v, k) { | ||
Linear: function (v, k, value) { | ||
var m = v.length - 1; | ||
@@ -19,10 +19,10 @@ var f = m * k; | ||
if (k < 0) { | ||
return fn(v[0], v[1], f); | ||
return fn(v[0], v[1], f, value); | ||
} | ||
if (k > 1) { | ||
return fn(v[m], v[m - 1], m - f); | ||
return fn(v[m], v[m - 1], m - f, value); | ||
} | ||
return fn(v[i], v[i + 1 > m ? m : i + 1], f - i); | ||
return fn(v[i], v[i + 1 > m ? m : i + 1], f - i, value); | ||
}, | ||
Bezier: function (v, k) { | ||
Bezier: function (v, k, value) { | ||
var b = 0; | ||
@@ -37,3 +37,3 @@ var n = v.length - 1; | ||
}, | ||
CatmullRom: function (v, k) { | ||
CatmullRom: function (v, k, value) { | ||
var m = v.length - 1; | ||
@@ -47,17 +47,35 @@ var f = m * k; | ||
} | ||
return fn(v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m], f - i); | ||
return fn(v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m], f - i, value); | ||
} | ||
else { | ||
if (k < 0) { | ||
return v[0] - (fn(v[0], v[0], v[1], v[1], -f) - v[0]); | ||
return v[0] - (fn(v[0], v[0], v[1], v[1], -f, value) - v[0]); | ||
} | ||
if (k > 1) { | ||
return v[m] - (fn(v[m], v[m], v[m - 1], v[m - 1], f - m) - v[m]); | ||
return v[m] - (fn(v[m], v[m], v[m - 1], v[m - 1], f - m, value) - 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); | ||
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, value); | ||
} | ||
}, | ||
Utils: { | ||
Linear: function (p0, p1, t) { | ||
return typeof p0 === 'function' ? p0(t) : (p1 - p0) * t + p0; | ||
Linear: function (p0, p1, t, v) { | ||
if (typeof v === 'string') { | ||
return p1; | ||
} | ||
else if (typeof v === 'number') { | ||
return typeof p0 === 'function' ? p0(t) : (p1 - p0) * t + p0; | ||
} | ||
else if (typeof v === 'object') { | ||
if (v.length !== undefined) { | ||
for (var p = 0, len = v.length; p < len; p++) { | ||
v[p] = Interpolation.Utils.Linear(p0[p], p1[p], t, v[p]); | ||
} | ||
} | ||
else { | ||
for (var p in v) { | ||
v[p] = Interpolation.Utils.Linear(p0[p], p1[p], t, v[p]); | ||
} | ||
} | ||
return v; | ||
} | ||
}, | ||
@@ -82,8 +100,26 @@ Bernstein: function (n, i) { | ||
})(), | ||
CatmullRom: function (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; | ||
CatmullRom: function (p0, p1, p2, p3, t, v) { | ||
if (typeof v === 'string') { | ||
return p1; | ||
} | ||
else if (typeof v === 'number') { | ||
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; | ||
} | ||
else if (typeof v === 'object') { | ||
if (v.length !== undefined) { | ||
for (var p = 0, len = v.length; p < len; p++) { | ||
v[p] = Interpolation.Utils.CatmullRom(p0[p], p1[p], p2[p], p3[p], t, v[p]); | ||
} | ||
} | ||
else { | ||
for (var p in v) { | ||
v[p] = Interpolation.Utils.CatmullRom(p0[p], p1[p], p2[p], p3[p], t, v[p]); | ||
} | ||
} | ||
return v; | ||
} | ||
} | ||
@@ -90,0 +126,0 @@ } |
@@ -1,2 +0,2 @@ | ||
export declare const Store: {}; | ||
export declare const Store: Object; | ||
export default function (node: any, object: any, tween: any): any; |
@@ -10,3 +10,6 @@ var PlaybackPosition = /** @class */ (function () { | ||
var i = labels.indexOf(name); | ||
if (typeof name === 'string' && name.indexOf('=') !== -1 && !offset && i === -1) { | ||
if (typeof name === 'string' && | ||
name.indexOf('=') !== -1 && | ||
!offset && | ||
i === -1) { | ||
var rty = name.substr(name.indexOf('=') - 1, 2); | ||
@@ -13,0 +16,0 @@ var rt = name.split(rty); |
export default function (selector, collection) { | ||
if (collection) { | ||
return !selector ? null : selector === window || selector === document ? [selector] : typeof selector === 'string' ? !!document.querySelectorAll && document.querySelectorAll(selector) : Array.isArray(selector) ? selector : selector.nodeType ? [selector] : []; | ||
return !selector | ||
? null | ||
: selector === window || selector === document | ||
? [selector] | ||
: typeof selector === 'string' | ||
? !!document.querySelectorAll && document.querySelectorAll(selector) | ||
: Array.isArray(selector) | ||
? selector | ||
: selector.nodeType ? [selector] : []; | ||
} | ||
return !selector ? null : selector === window || selector === document ? selector : typeof selector === 'string' ? !!document.querySelector && document.querySelector(selector) : Array.isArray(selector) ? selector[0] : selector.nodeType ? selector : null; | ||
return !selector | ||
? null | ||
: selector === window || selector === document | ||
? selector | ||
: typeof selector === 'string' | ||
? !!document.querySelector && document.querySelector(selector) | ||
: Array.isArray(selector) | ||
? selector[0] | ||
: selector.nodeType ? selector : null; | ||
} |
@@ -1,7 +0,2 @@ | ||
export declare let assign: { | ||
<T, U>(target: T, source: U): T & U; | ||
<T, U, V>(target: T, source1: U, source2: V): T & U & V; | ||
<T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W; | ||
(target: object, ...sources: any[]): any; | ||
}; | ||
export declare let assign: (source: object, ...args: any[]) => Object; | ||
export declare let create: { | ||
@@ -8,0 +3,0 @@ (o: object): any; |
@@ -10,3 +10,3 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
/* global global */ | ||
export var assign = Object.assign || (function (source) { | ||
export var assign = (function (source) { | ||
var args = []; | ||
@@ -28,4 +28,8 @@ for (var _i = 1; _i < arguments.length; _i++) { | ||
}); | ||
export var root = typeof (window) !== 'undefined' ? window : typeof (global) !== 'undefined' ? global : this; | ||
export var requestAnimationFrame = root.requestAnimationFrame || (function (fn) { return root.setTimeout(fn, 16); }); | ||
export var cancelAnimationFrame = root.cancelAnimationFrame || (function (id) { return root.clearTimeout(id); }); | ||
export var root = typeof window !== 'undefined' | ||
? window | ||
: typeof global !== 'undefined' ? global : this; | ||
export var requestAnimationFrame = root.requestAnimationFrame || | ||
(function (fn) { return root.setTimeout(fn, 16); }); | ||
export var cancelAnimationFrame = root.cancelAnimationFrame || | ||
(function (id) { return root.clearTimeout(id); }); |
@@ -22,3 +22,3 @@ var __extends = (this && this.__extends) || (function () { | ||
import Tween from './Tween'; | ||
import { EVENT_COMPLETE, EVENT_REPEAT, EVENT_REVERSE, EVENT_RESTART, EVENT_UPDATE } from './constants'; | ||
import { EVENT_COMPLETE, EVENT_REPEAT, EVENT_REVERSE, EVENT_RESTART, EVENT_UPDATE, } from './constants'; | ||
import Selector from './selector'; | ||
@@ -25,0 +25,0 @@ export var shuffle = function (a) { |
@@ -380,3 +380,3 @@ import { add, now, Plugins, remove } from './core'; | ||
} | ||
if (Array.isArray(end) && typeof start === 'number') { | ||
if (Array.isArray(end) && !Array.isArray(start)) { | ||
end.unshift(start); | ||
@@ -602,4 +602,4 @@ } | ||
} | ||
else if (Array.isArray(end) && typeof start === 'number') { | ||
object[property] = _interpolationFunction(end, value); | ||
else if (Array.isArray(end) && !Array.isArray(start)) { | ||
object[property] = _interpolationFunction(end, value, object[property]); | ||
} | ||
@@ -606,0 +606,0 @@ else if (end && end.update) { |
Sorry, the diff of this file is not supported yet
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
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
462065
4394
238