es6-tween
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -87,248 +87,501 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
var Easing = { | ||
Linear: { | ||
None: function None(k) { | ||
Linear: { | ||
None: function None(k) { | ||
return k; | ||
} | ||
return k; | ||
} | ||
}, | ||
Quadratic: { | ||
In: function In(k) { | ||
return k * k; | ||
}, | ||
Out: function Out(k) { | ||
Quadratic: { | ||
In: function In(k) { | ||
return k * (2 - k); | ||
}, | ||
InOut: function InOut(k) { | ||
return k * k; | ||
}, | ||
Out: function Out(k) { | ||
if ((k *= 2) < 1) { | ||
return 0.5 * k * k; | ||
} | ||
return k * (2 - k); | ||
}, | ||
InOut: function InOut(k) { | ||
return -0.5 * (--k * (k - 2) - 1); | ||
} | ||
}, | ||
if ((k *= 2) < 1) { | ||
return 0.5 * k * k; | ||
} | ||
Cubic: { | ||
In: function In(k) { | ||
return -0.5 * (--k * (k - 2) - 1); | ||
} | ||
return k * k * k; | ||
}, | ||
Out: function Out(k) { | ||
Cubic: { | ||
In: function In(k) { | ||
return --k * k * k + 1; | ||
}, | ||
InOut: function InOut(k) { | ||
return k * k * k; | ||
}, | ||
Out: function Out(k) { | ||
if ((k *= 2) < 1) { | ||
return 0.5 * k * k * k; | ||
} | ||
return --k * k * k + 1; | ||
}, | ||
InOut: function InOut(k) { | ||
return 0.5 * ((k -= 2) * k * k + 2); | ||
} | ||
}, | ||
if ((k *= 2) < 1) { | ||
return 0.5 * k * k * k; | ||
} | ||
Quartic: { | ||
In: function In(k) { | ||
return 0.5 * ((k -= 2) * k * k + 2); | ||
} | ||
return k * k * k * k; | ||
}, | ||
Out: function Out(k) { | ||
Quartic: { | ||
In: function In(k) { | ||
return 1 - --k * k * k * k; | ||
}, | ||
InOut: function InOut(k) { | ||
return k * k * k * k; | ||
}, | ||
Out: function Out(k) { | ||
if ((k *= 2) < 1) { | ||
return 0.5 * k * k * k * k; | ||
} | ||
return 1 - --k * k * k * k; | ||
}, | ||
InOut: function InOut(k) { | ||
return -0.5 * ((k -= 2) * k * k * k - 2); | ||
} | ||
}, | ||
if ((k *= 2) < 1) { | ||
return 0.5 * k * k * k * k; | ||
} | ||
Quintic: { | ||
In: function In(k) { | ||
return -0.5 * ((k -= 2) * k * k * k - 2); | ||
} | ||
return k * k * k * k * k; | ||
}, | ||
Out: function Out(k) { | ||
Quintic: { | ||
In: function In(k) { | ||
return --k * k * k * k * k + 1; | ||
}, | ||
InOut: function InOut(k) { | ||
return k * k * k * k * k; | ||
}, | ||
Out: function Out(k) { | ||
if ((k *= 2) < 1) { | ||
return 0.5 * k * k * k * k * k; | ||
} | ||
return --k * k * k * k * k + 1; | ||
}, | ||
InOut: function InOut(k) { | ||
return 0.5 * ((k -= 2) * k * k * k * k + 2); | ||
} | ||
}, | ||
if ((k *= 2) < 1) { | ||
return 0.5 * k * k * k * k * k; | ||
} | ||
Sinusoidal: { | ||
In: function In(k) { | ||
return 0.5 * ((k -= 2) * k * k * k * k + 2); | ||
} | ||
return 1 - Math.cos(k * Math.PI / 2); | ||
}, | ||
Out: function Out(k) { | ||
Sinusoidal: { | ||
In: function In(k) { | ||
return Math.sin(k * Math.PI / 2); | ||
}, | ||
InOut: function InOut(k) { | ||
return 1 - Math.cos(k * Math.PI / 2); | ||
}, | ||
Out: function Out(k) { | ||
return 0.5 * (1 - Math.cos(Math.PI * k)); | ||
} | ||
}, | ||
return Math.sin(k * Math.PI / 2); | ||
}, | ||
InOut: function InOut(k) { | ||
Exponential: { | ||
In: function In(k) { | ||
return 0.5 * (1 - Math.cos(Math.PI * k)); | ||
} | ||
return k === 0 ? 0 : Math.pow(1024, k - 1); | ||
}, | ||
Out: function Out(k) { | ||
Exponential: { | ||
In: function In(k) { | ||
return k === 1 ? 1 : 1 - Math.pow(-10 * k, 2); | ||
}, | ||
InOut: function InOut(k) { | ||
return k === 0 ? 0 : Math.pow(1024, k - 1); | ||
}, | ||
Out: function Out(k) { | ||
if (k === 0) { | ||
return 0; | ||
} | ||
return k === 1 ? 1 : 1 - Math.pow(-10 * k, 2); | ||
}, | ||
InOut: function InOut(k) { | ||
if (k === 1) { | ||
return 1; | ||
} | ||
if (k === 0) { | ||
return 0; | ||
} | ||
if ((k *= 2) < 1) { | ||
return 0.5 * Math.pow(1024, k - 1); | ||
} | ||
if (k === 1) { | ||
return 1; | ||
} | ||
return 0.5 * (-Math.pow(-10 * (k - 1), 2) + 2); | ||
} | ||
}, | ||
if ((k *= 2) < 1) { | ||
return 0.5 * Math.pow(1024, k - 1); | ||
} | ||
Circular: { | ||
In: function In(k) { | ||
return 0.5 * (-Math.pow(-10 * (k - 1), 2) + 2); | ||
} | ||
return 1 - Math.sqrt(1 - k * k); | ||
}, | ||
Out: function Out(k) { | ||
Circular: { | ||
In: function In(k) { | ||
return Math.sqrt(1 - --k * k); | ||
}, | ||
InOut: function InOut(k) { | ||
return 1 - Math.sqrt(1 - k * k); | ||
}, | ||
Out: function Out(k) { | ||
if ((k *= 2) < 1) { | ||
return -0.5 * (Math.sqrt(1 - k * k) - 1); | ||
} | ||
return Math.sqrt(1 - --k * k); | ||
}, | ||
InOut: function InOut(k) { | ||
return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1); | ||
} | ||
}, | ||
if ((k *= 2) < 1) { | ||
return -0.5 * (Math.sqrt(1 - k * k) - 1); | ||
} | ||
Elastic: { | ||
In: function In(k) { | ||
return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1); | ||
} | ||
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) { | ||
Elastic: { | ||
In: function In(k) { | ||
if (k === 0) { | ||
return 0; | ||
} | ||
if (k === 0) { | ||
return 0; | ||
} | ||
if (k === 1) { | ||
return 1; | ||
} | ||
if (k === 1) { | ||
return 1; | ||
} | ||
return Math.pow(-10 * k, 2) * Math.sin((k - 0.1) * 5 * Math.PI) + 1; | ||
}, | ||
InOut: function InOut(k) { | ||
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 === 0) { | ||
return 0; | ||
} | ||
if (k === 1) { | ||
return 1; | ||
} | ||
if (k === 1) { | ||
return 1; | ||
} | ||
k *= 2; | ||
return Math.pow(-10 * k, 2) * Math.sin((k - 0.1) * 5 * Math.PI) + 1; | ||
}, | ||
InOut: function InOut(k) { | ||
if (k < 1) { | ||
return -0.5 * Math.pow(10 * (k - 1), 2) * Math.sin((k - 1.1) * 5 * Math.PI); | ||
} | ||
if (k === 0) { | ||
return 0; | ||
} | ||
return 0.5 * Math.pow(-10 * (k - 1), 2) * Math.sin((k - 1.1) * 5 * Math.PI) + 1; | ||
} | ||
}, | ||
if (k === 1) { | ||
return 1; | ||
} | ||
Back: { | ||
In: function In(k) { | ||
k *= 2; | ||
var s = 1.70158; | ||
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 k * k * ((s + 1) * k - s); | ||
}, | ||
Out: function Out(k) { | ||
Back: { | ||
In: function In(k) { | ||
var s = 1.70158; | ||
var s = 1.70158; | ||
return --k * k * ((s + 1) * k + s) + 1; | ||
}, | ||
InOut: function InOut(k) { | ||
return k * k * ((s + 1) * k - s); | ||
}, | ||
Out: function Out(k) { | ||
var s = 1.70158 * 1.525; | ||
var s = 1.70158; | ||
if ((k *= 2) < 1) { | ||
return 0.5 * (k * k * ((s + 1) * k - s)); | ||
} | ||
return --k * k * ((s + 1) * k + s) + 1; | ||
}, | ||
InOut: function InOut(k) { | ||
return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2); | ||
} | ||
}, | ||
var s = 1.70158 * 1.525; | ||
Bounce: { | ||
In: function In(k) { | ||
if ((k *= 2) < 1) { | ||
return 0.5 * (k * k * ((s + 1) * k - s)); | ||
} | ||
return 1 - Easing.Bounce.Out(1 - k); | ||
}, | ||
Out: function Out(k) { | ||
return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2); | ||
} | ||
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) { | ||
Bounce: { | ||
In: function In(k) { | ||
if (k < 0.5) { | ||
return Easing.Bounce.In(k * 2) * 0.5; | ||
} | ||
return 1 - Easing.Bounce.Out(1 - k); | ||
}, | ||
Out: function Out(k) { | ||
return Easing.Bounce.Out(k * 2 - 1) * 0.5 + 0.5; | ||
} | ||
}, | ||
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) { | ||
Stepped: function Stepped(steps) { | ||
return function (k) { | ||
return Math.floor(k * steps) / steps; | ||
}; | ||
}, | ||
Noisy: function Noisy(randomProportion, easingFunction) { | ||
var normalProportion = 1.0 - randomProportion; | ||
return function (k) { | ||
return randomProportion * Math.random() + normalProportion * easingFunction(k); | ||
}; | ||
}, | ||
if (k < 0.5) { | ||
return Easing.Bounce.In(k * 2) * 0.5; | ||
} | ||
return Easing.Bounce.Out(k * 2 - 1) * 0.5 + 0.5; | ||
} | ||
} | ||
// Adapted from https://github.com/michaelvillar/dynamics.js | ||
get bezier() { | ||
var b, d; | ||
b = function b(_b, d, g, f, h) { | ||
var k = Math.pow(1 - _b, 3), | ||
l = 3 * Math.pow(1 - _b, 2) * _b, | ||
m = 3 * (1 - _b) * Math.pow(_b, 2); | ||
_b = Math.pow(_b, 3); | ||
return { | ||
x: k * d.x + l * g.x + m * f.x + _b * h.x, | ||
y: k * d.y + l * g.y + m * f.y + _b * h.y | ||
}; | ||
}; | ||
d = function d(b, _d) { | ||
var g, | ||
f, | ||
h = 0, | ||
k = 0, | ||
l = _d.length, | ||
m = 0, | ||
q = 1, | ||
w = (q + m) / 2; | ||
for (g = null; k < l;) { | ||
f = _d[k]; | ||
b >= f(0).x && b <= f(1).x && (g = f); | ||
if (null !== g) break; | ||
k++; | ||
} | ||
if (!g) return 1; | ||
for (f = g(w).x; 1E-4 < Math.abs(b - f) && 100 > h;) { | ||
b > f ? m = w : q = w, w = (q + m) / 2, f = g(w).x, h++; | ||
}return g(w).y; | ||
}; | ||
return function (c) { | ||
null == c && (c = {}); | ||
var e = c.points, | ||
g = function () { | ||
var c, | ||
d = 0, | ||
k = e.length; | ||
g = []; | ||
for (c = function c(d, _c) { | ||
return g.push(function (e) { | ||
return b(e, d, d.cp[d.cp.length - 1], _c.cp[0], _c); | ||
}); | ||
}; d < k && !(d >= e.length - 1);) { | ||
c(e[d], e[d + 1]), d++; | ||
}return g; | ||
}(); | ||
return function (b) { | ||
return d(b, g); | ||
}; | ||
}; | ||
}, | ||
easeInOut: function easeInOut(b) { | ||
var d, c; | ||
null == b && (b = {}); | ||
d = null != (c = b.friction) ? c : Easing.easeInOut.defaults.friction; | ||
return Easing.bezier({ | ||
points: [{ | ||
x: 0, | ||
y: 0, | ||
cp: [{ | ||
x: .92 - d / 1E3, | ||
y: 0 | ||
}] | ||
}, { | ||
x: 1, | ||
y: 1, | ||
cp: [{ | ||
x: .08 + d / 1E3, | ||
y: 1 | ||
}] | ||
}] | ||
}); | ||
}, | ||
easeIn: function easeIn(b) { | ||
var d, c; | ||
null == b && (b = {}); | ||
d = null != (c = b.friction) ? c : Easing.easeIn.defaults.friction; | ||
return Easing.bezier({ | ||
points: [{ | ||
x: 0, | ||
y: 0, | ||
cp: [{ | ||
x: .92 - d / 1E3, | ||
y: 0 | ||
}] | ||
}, { | ||
x: 1, | ||
y: 1, | ||
cp: [{ | ||
x: 1, | ||
y: 1 | ||
}] | ||
}] | ||
}); | ||
}, | ||
easeOut: function easeOut(b) { | ||
var d, c; | ||
null == b && (b = {}); | ||
d = null != (c = b.friction) ? c : Easing.easeOut.defaults.friction; | ||
return Easing.bezier({ | ||
points: [{ | ||
x: 0, | ||
y: 0, | ||
cp: [{ | ||
x: 0, | ||
y: 0 | ||
}] | ||
}, { | ||
x: 1, | ||
y: 1, | ||
cp: [{ | ||
x: .08 + d / 1E3, | ||
y: 1 | ||
}] | ||
}] | ||
}); | ||
}, | ||
spring: function spring(b) { | ||
var d, c, e, g, f; | ||
null == b && (b = {}); | ||
Tools.extend(b, Easing.spring.defaults, true); | ||
e = Math.max(1, b.frequency / 20); | ||
g = Math.pow(20, b.friction / 100); | ||
f = b.anticipationSize / 1E3; | ||
d = function d(_d2) { | ||
var c, e; | ||
e = f / (1 - f); | ||
c = (e - 0) / (e - 0); | ||
return (.8 - c) / e * _d2 * b.anticipationStrength / 100 + c; | ||
}; | ||
c = function c(b) { | ||
return Math.pow(g / 10, -b) * (1 - b); | ||
}; | ||
return function (b) { | ||
var g, l, m, q; | ||
q = b / (1 - f) - f / (1 - f); | ||
b < f ? (m = f / (1 - f) - f / (1 - f), g = 0 / (1 - f) - f / (1 - f), m = Math.acos(1 / d(m)), l = (Math.acos(1 / d(g)) - m) / (e * -f), g = d) : (g = c, m = 0, l = 1); | ||
return 1 - g(q) * Math.cos(e * (b - f) * l + m); | ||
}; | ||
}, | ||
bounce: function bounce(b) { | ||
var d, c, e, g; | ||
null == b && (b = {}); | ||
Tools.extend(b, Easing.bounce.defaults); | ||
e = Math.max(1, b.frequency / 20); | ||
g = Math.pow(20, b.friction / 100); | ||
d = function d(b) { | ||
return Math.pow(g / 10, -b) * (1 - b); | ||
}; | ||
c = function c(b) { | ||
return d(b) * Math.cos(e * b * 1 + -1.57); | ||
}; | ||
c.initialForce = !0; | ||
return c; | ||
}, | ||
gravity: function gravity(b) { | ||
var d, c, e, g, f, h; | ||
null == b && (b = {}); | ||
Tools.extend(b, Easing.gravity.defaults); | ||
c = Math.min(b.bounciness / 1250, .8); | ||
g = b.elasticity / 1E3; | ||
e = []; | ||
d = function () { | ||
var e; | ||
e = Math.sqrt(.02); | ||
e = { | ||
a: -e, | ||
b: e, | ||
H: 1 | ||
}; | ||
b.initialForce && (e.a = 0, e.b *= 2); | ||
for (; .001 < e.H;) { | ||
d = e.b - e.a, e = { | ||
a: e.b, | ||
b: e.b + d * c, | ||
H: e.H * c * c | ||
}; | ||
}return e.b; | ||
}(); | ||
h = function h(c, e, f, g) { | ||
d = e - c; | ||
c = 2 / d * g - 1 - 2 * c / d; | ||
f = c * c * f - f + 1; | ||
b.initialForce && (f = 1 - f); | ||
return f; | ||
}; | ||
(function () { | ||
var f, h, m; | ||
f = Math.sqrt(2 / (100 * d * d)); | ||
h = { | ||
a: -f, | ||
b: f, | ||
H: 1 | ||
}; | ||
b.initialForce && (h.a = 0, h.b *= 2); | ||
e.push(h); | ||
for (m = []; 1 > h.b && .001 < h.H;) { | ||
f = h.b - h.a, h = { | ||
a: h.b, | ||
b: h.b + f * c, | ||
H: h.H * g | ||
}, m.push(e.push(h)); | ||
}return m; | ||
})(); | ||
f = function f(c) { | ||
var d, f; | ||
f = 0; | ||
for (d = e[f]; !(c >= d.a && c <= d.b) && (f += 1, d = e[f], d);) {} | ||
return d ? h(d.a, d.b, d.H, c) : b.initialForce ? 0 : 1; | ||
}; | ||
f.initialForce = b.initialForce; | ||
return f; | ||
}, | ||
forceWithGravity: function forceWithGravity(b) { | ||
null == b && (b = {}); | ||
Tools.extend(b, Easing.forceWithGravity.defaults); | ||
b.initialForce = !0; | ||
return Easing.gravity(b); | ||
} | ||
}; | ||
Easing.spring.defaults = { | ||
frequency: 300, | ||
friction: 200, | ||
anticipationSize: 0, | ||
anticipationStrength: 0 | ||
}; | ||
Easing.bounce.defaults = { | ||
frequency: 300, | ||
friction: 200 | ||
}; | ||
Easing.forceWithGravity.defaults = Easing.gravity.defaults = { | ||
bounciness: 400, | ||
elasticity: 200 | ||
}; | ||
Easing.easeInOut.defaults = Easing.easeIn.defaults = Easing.easeOut.defaults = { | ||
friction: 500 | ||
}; | ||
@@ -345,108 +598,108 @@ exports.default = Easing; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
var Interpolation = { | ||
Linear: function Linear(v, k) { | ||
Linear: function Linear(v, k) { | ||
var m = v.length - 1; | ||
var f = m * k; | ||
var i = Math.floor(f); | ||
var fn = Interpolation.Utils.Linear; | ||
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 < 0) { | ||
return fn(v[0], v[1], f); | ||
} | ||
if (k > 1) { | ||
return fn(v[m], v[m - 1], m - 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) { | ||
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; | ||
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); | ||
} | ||
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) { | ||
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; | ||
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 (v[0] === v[m]) { | ||
if (k < 0) { | ||
i = Math.floor(f = m * (1 + k)); | ||
} | ||
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 { | ||
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 < 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]); | ||
} | ||
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); | ||
} | ||
}, | ||
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) { | ||
Utils: { | ||
Linear: function Linear(p0, p1, t) { | ||
return (p1 - p0) * t + p0; | ||
}, | ||
Bernstein: function Bernstein(n, i) { | ||
return (p1 - p0) * t + p0; | ||
}, | ||
Bernstein: function Bernstein(n, i) { | ||
var fc = Interpolation.Utils.Factorial; | ||
var fc = Interpolation.Utils.Factorial; | ||
return fc(n) / fc(i) / fc(n - i); | ||
}, | ||
return fc(n) / fc(i) / fc(n - i); | ||
}, | ||
Factorial: function () { | ||
Factorial: function () { | ||
var a = [1]; | ||
var a = [1]; | ||
return function (n) { | ||
return function (n) { | ||
var s = 1; | ||
var s = 1; | ||
if (a[n]) { | ||
return a[n]; | ||
} | ||
if (a[n]) { | ||
return a[n]; | ||
} | ||
for (var i = n; i > 1; i--) { | ||
s *= i; | ||
} | ||
for (var i = n; i > 1; i--) { | ||
s *= i; | ||
} | ||
a[n] = s; | ||
return s; | ||
}; | ||
}(), | ||
a[n] = s; | ||
return s; | ||
}; | ||
}(), | ||
CatmullRom: function CatmullRom(p0, p1, p2, p3, t) { | ||
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; | ||
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; | ||
} | ||
return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1; | ||
} | ||
} | ||
}; | ||
@@ -899,3 +1152,3 @@ | ||
// we should not set that property in the object | ||
if (object[property] === undefined) { | ||
if (Tween.checkValidness(object[property]) === false) { | ||
continue; | ||
@@ -1151,3 +1404,3 @@ } | ||
value: function checkValidness(valid) { | ||
return valid !== undefined && valid !== null && valid !== ''; | ||
return valid !== undefined && valid !== null && valid !== '' && valid !== NaN && valid !== Infinity; | ||
} | ||
@@ -1154,0 +1407,0 @@ }]); |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.TWEEN=e():t.TWEEN=e()}(this,function(){return function(t){function e(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,e),r.l=!0,r.exports}var n={};return e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=7)}([function(t,e,n){"use strict";Object.defineProperty(e,"__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 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?.5*(t*t*((e+1)*t-e)):.5*((t-=2)*t*((e+1)*t+e)+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}}};e.default=i},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i={Linear:function(t,e){var n=t.length-1,r=n*e,o=Math.floor(r),u=i.Utils.Linear;return e<0?u(t[0],t[1],r):e>1?u(t[n],t[n-1],n-r):u(t[o],t[o+1>n?n:o+1],r-o)},Bezier:function(t,e){for(var n=0,r=t.length-1,o=Math.pow,u=i.Utils.Bernstein,a=0;a<=r;a++)n+=o(1-e,r-a)*o(e,a)*t[a]*u(r,a);return n},CatmullRom:function(t,e){var n=t.length-1,r=n*e,o=Math.floor(r),u=i.Utils.CatmullRom;return t[0]===t[n]?(e<0&&(o=Math.floor(r=n*(1+e))),u(t[(o-1+n)%n],t[o],t[(o+1)%n],t[(o+2)%n],r-o)):e<0?t[0]-(u(t[0],t[0],t[1],t[1],-r)-t[0]):e>1?t[n]-(u(t[n],t[n],t[n-1],t[n-1],r-n)-t[n]):u(t[o?o-1:0],t[o],t[n<o+1?n:o+1],t[n<o+2?n:o+2],r-o)},Utils:{Linear:function(t,e,n){return(e-t)*n+t},Bernstein:function(t,e){var n=i.Utils.Factorial;return n(t)/n(e)/n(t-e)},Factorial:function(){var t=[1];return function(e){var n=1;if(t[e])return t[e];for(var i=e;i>1;i--)n*=i;return t[e]=n,n}}(),CatmullRom:function(t,e,n,i,r){var o=.5*(n-t),u=.5*(i-e),a=r*r,s=r*a;return(2*e-2*n+o+u)*s+(-3*e+3*n-2*o-u)*a+o*r+e}}};e.default=i},function(t,e,n){"use strict";function i(t){g(o)?(o=t,s=requestAnimationFrame(i),v("autostart",t)):(u=!1,cancelAnimationFrame(s),v("stop",t))}Object.defineProperty(e,"__esModule",{value:!0});var r=[],o=0,u=!1,a=!1,s=void 0,c={},l=function(){return r},f=function(t){a=t},h=function(){r=[]},v=function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];void 0!==c[t]&&c[t].map(function(t){return t.apply(void 0,n)})},d=function(t,e){if(void 0!==t&&void 0!==c[t])if(void 0!==e)for(var n=c[name],i=0;i<n.length;)n[i]===e&&n.splice(i,1),i++;else c[name]=[]},p=function(t){r.push(t),a&&!u&&(i(b()),u=!0,v("start")),v("add",t,r)},y=function(t,e){void 0===c[t]&&(c[t]=[]),c[t].push(e)},_=function(t,e){void 0===c[t]&&(c[t]=[]),y(t,function(){e.apply(void 0,arguments),d(t)})},m=function(t){r.filter(function(e){return e!==t});for(var e=0,n=void 0;e<r.length;)n=r[e],n===t&&(v("remove",t,r),r.splice(e,1)),e++},b=function(){return o},g=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:b(),e=arguments[1];if(t=void 0!==t?t:b(),o=t,v("update",t,r),0===r.length)return!1;v("realupdate",t,r);for(var n=0;n<r.length;)r[n].update(t)||e?n++:r.splice(n,1);return!0};e.getAll=l,e.removeAll=h,e.remove=m,e.add=p,e.now=b,e.update=g,e.autoPlay=f,e.on=y,e.once=_,e.off=d,e.emit=v},function(t,e,n){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var o="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},u=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),a=n(2),s=n(0),c=i(s),l=n(1),f=i(l),h=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),this.object=e,this._valuesStart=t.createEmptyConst(e),this._valuesStartRepeat=t.createEmptyConst(e),this._valuesEnd=t.createEmptyConst(e),this._chainedTweens=[],this._duration=1e3,this._easingFunction=c.default.Linear.None,this._interpolationFunction=f.default.None,this._startTime=0,this._delayTime=0,this._repeat=0,this._r=0,this._isPlaying=!1,this._yoyo=!1,this._reversed=!1,this._onStartCallbackFired=!1,this._events={},this._pausedTime=0,this}return u(t,[{key:"isPlaying",value:function(){return this._isPlaying}},{key:"isStarted",value:function(){return this._onStartCallbackFired}},{key:"reverse",value:function(){var t=this._valuesStartRepeat,e=this._yoyo,n=this._valuesEnd,i=this._valuesStart;for(var r in t){if("string"==typeof n[r]&&(t[r]=t[r]+parseFloat(n[r])),e){var o=t[r];t[r]=n[r],n[r]=o}i[r]=t[r]}return this._reversed=!this._reversed,this}},{key:"off",value:function(t,e){if(void 0===this._events[t])return this;if(void 0!==t&&void 0!==e)for(var n=this._events[t],i=0;i<n.length;)n[i]===e&&n.splice(i,1),i++;else void 0!==t&&void 0===e&&(this._events[t]=[]);return this}},{key:"on",value:function(t,e){return void 0===this._events[t]&&(this._events[t]=[]),this._events[t].push(e),this}},{key:"once",value:function(t,e){var n=this;return void 0===this._events[t]&&(this._events[t]=[]),this.on(t,function(){for(var i=arguments.length,r=Array(i),o=0;o<i;o++)r[o]=arguments[o];e.call.apply(e,[n].concat(r)),n.off(t)})}},{key:"emit",value:function(t){for(var e=this,n=arguments.length,i=Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return void 0===this._events[t]?this:(this._events[t].map(function(t){t.call.apply(t,[e].concat(i))}),this)}},{key:"pause",value:function(){return this._isPlaying?(this._isPlaying=!1,(0,a.remove)(this),this._pausedTime=(0,a.now)(),this.emit("pause",this.object)):this}},{key:"play",value:function(){return this._isPlaying?this:(this._isPlaying=!0,this._startTime+=(0,a.now)()-this._pausedTime,(0,a.add)(this),this._pausedTime=(0,a.now)(),this.emit("play",this.object))}},{key:"restart",value:function(t){return this._repeat=this._r,this._startTime=(0,a.now)()+(t?0:this._delayTime),this._isPlaying||(0,a.add)(this),this.emit("restart",this._object)}},{key:"seek",value:function(t,e){return this._startTime=(0,a.now)()+Math.max(0,Math.min(t,this._duration)),this.emit("seek",t,this._object),e?this:this.pause()}},{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]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3;if("number"==typeof t){var n={Number:t};this._valuesEnd=n}else this._valuesEnd=t;if("number"==typeof e)this._duration=e;else if("object"===("undefined"==typeof e?"undefined":o(e)))for(var i in e)this[i](e[i]);return this}},{key:"start",value:function(t){var e=this._startTime,n=this._delayTime,i=this._valuesEnd,r=this._valuesStart,o=(this._valuesStartRepeat,this.object);e=void 0!==t?t:(0,a.now)(),e+=n,this._startTime=e;for(var u in i){if("number"==typeof o[u]&&i[u]instanceof Array){if(0===i[u].length)continue;this._valuesEnd[u]=[o[u]].concat(i[u])}void 0!==o[u]&&(this._valuesStart[u]=o[u],this._valuesStartRepeat[u]=r[u]||0)}return(0,a.add)(this),this._isPlaying=!0,this}},{key:"stop",value:function(){var t=this._isPlaying,e=(this._onStopCallback,this.object);return t?((0,a.remove)(this),this._isPlaying=!1,this.stopChainedTweens(),this.emit("stop",e)):this}},{key:"end",value:function(){var t=this._startTime,e=this._duration;return this.update(t+e)}},{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._r=t,this}},{key:"repeatDelay",value:function(t){return this._repeatDelayTime=t,this}},{key:"reverseDelay",value:function(t){return this._reverseDelayTime=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,e=Array(t),n=0;n<t;n++)e[n]=arguments[n];return this._chainedTweens=e,this}},{key:"get",value:function(t){return this.update(t),this._object}},{key:"update",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:(0,a.now)(),e=this._onStartCallbackFired,n=this._chainedTweens,i=this._easingFunction,r=this._interpolationFunction,o=this._repeat,u=this._repeatDelayTime,s=this._reverseDelayTime,c=this._delayTime,l=this._yoyo,f=this._reversed,h=this._startTime,v=this._duration,d=this._valuesStart,p=(this._valuesStartRepeat,this._valuesEnd),y=this.object,_=void 0,m=void 0,b=void 0;if(t<h)return!0;e===!1&&(this.emit("start",y),this._onStartCallbackFired=!0),m=(t-h)/v,m=m>1?1:m,b=i(m);for(_ in p)if(void 0!==d[_]){var g=d[_],w=p[_];w instanceof Array?y[_]=r(w,b):("string"==typeof w&&(w="+"===w.charAt(0)||"-"===w.charAt(0)?g+parseFloat(w):parseFloat(w)),"number"==typeof w&&(y[_]=g+(w-g)*b))}return this.emit("update",y,m),1!==m||(o>0?(isFinite(o)&&this._repeat--,this.reverse(),this.emit(f?"reverse":"repeat",y),l&&(this._reversed=!f),f||void 0===u?f&&void 0!==s?this._startTime+=v+s:this._startTime+=v+c:this._startTime+=v+u,!0):(this.emit("complete",y),n.map(function(t){return t.start(h+v)}),!1))}}],[{key:"createEmptyConst",value:function(t){return"number"==typeof t?0:Array.isArray(t)?[]:"object"===("undefined"==typeof t?"undefined":o(t))?{}:""}},{key:"checkValidness",value:function(t){return void 0!==t&&null!==t&&""!==t}}]),t}();e.default=h},function(t,e,n){"use strict";void 0===Object.assign&&(Object.assign=function(){for(var t=arguments.length,e=Array(t),n=0;n<t;n++)e[n]=arguments[n];var i=e.shift();return e.map(function(t){for(var e in t)i[e]=t[e]}),i})},function(t,e,n){"use strict";(function(t){var e="undefined"!=typeof window?window:"undefined"!=typeof t?t:void 0,n=["webkit","moz","ms","o"],i="AnimationFrame",r="Request"+i,o="Cancel"+i,u="CancelRequest"+i,a=setTimeout,s=clearTimeout;if(void 0===e.requestAnimationFrame){var c=void 0,l=void 0,f=Date.now(),h=50/3,v=h;n.map(function(t){void 0===(c=e[t+r])&&(c=function(t){return a(function(){l=Date.now(),t(l-f),v=h+(Date.now()-l)},v)})}),void 0!==c&&(e.requestAnimationFrame=c)}if(void 0===e.cancelAnimationFrame&&void 0===(e.cancelAnimationFrame=e.cancelRequestAnimationFrame)){var d=void 0;n.map(function(t){void 0===(d=e[t+o])&&void 0===(d=e[t+u])&&(d=function(t){return s(t)})}),void 0!==d&&(e.cancelAnimationFrame=d)}}).call(e,n(6))},function(t,e,n){"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,e,n){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0}),e.Interpolation=e.Easing=e.Tween=e.now=e.autoPlay=e.update=e.remove=e.removeAll=e.add=e.getAll=void 0,n(4),n(5);var r=n(2),o=n(0),u=i(o),a=n(3),s=i(a),c=n(1),l=i(c);e.getAll=r.getAll,e.add=r.add,e.removeAll=r.removeAll,e.remove=r.remove,e.update=r.update,e.autoPlay=r.autoPlay,e.now=r.now,e.Tween=s.default,e.Easing=u.default,e.Interpolation=l.default}])}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.TWEEN=e():t.TWEEN=e()}(this,function(){return function(t){function e(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,e),r.l=!0,r.exports}var n={};return e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=7)}([function(t,e,n){"use strict";Object.defineProperty(e,"__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 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?.5*(t*t*((e+1)*t-e)):.5*((t-=2)*t*((e+1)*t+e)+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}},Stepped:function(t){return function(e){return Math.floor(e*t)/t}},Noisy:function(t,e){var n=1-t;return function(i){return t*Math.random()+n*e(i)}},get bezier(){var t,e;return t=function(t,e,n,i,r){var o=Math.pow(1-t,3),u=3*Math.pow(1-t,2)*t,a=3*(1-t)*Math.pow(t,2);return t=Math.pow(t,3),{x:o*e.x+u*n.x+a*i.x+t*r.x,y:o*e.y+u*n.y+a*i.y+t*r.y}},e=function(t,e){var n,i,r=0,o=0,u=e.length,a=0,s=1,c=(s+a)/2;for(n=null;o<u&&(i=e[o],t>=i(0).x&&t<=i(1).x&&(n=i),null===n);)o++;if(!n)return 1;for(i=n(c).x;1e-4<Math.abs(t-i)&&100>r;)t>i?a=c:s=c,c=(s+a)/2,i=n(c).x,r++;return n(c).y},function(n){null==n&&(n={});var i=n.points,r=function(){var e,n=0,o=i.length;for(r=[],e=function(e,n){return r.push(function(i){return t(i,e,e.cp[e.cp.length-1],n.cp[0],n)})};n<o&&!(n>=i.length-1);)e(i[n],i[n+1]),n++;return r}();return function(t){return e(t,r)}}},easeInOut:function(t){var e,n;return null==t&&(t={}),e=null!=(n=t.friction)?n:i.easeInOut.defaults.friction,i.bezier({points:[{x:0,y:0,cp:[{x:.92-e/1e3,y:0}]},{x:1,y:1,cp:[{x:.08+e/1e3,y:1}]}]})},easeIn:function(t){var e,n;return null==t&&(t={}),e=null!=(n=t.friction)?n:i.easeIn.defaults.friction,i.bezier({points:[{x:0,y:0,cp:[{x:.92-e/1e3,y:0}]},{x:1,y:1,cp:[{x:1,y:1}]}]})},easeOut:function(t){var e,n;return null==t&&(t={}),e=null!=(n=t.friction)?n:i.easeOut.defaults.friction,i.bezier({points:[{x:0,y:0,cp:[{x:0,y:0}]},{x:1,y:1,cp:[{x:.08+e/1e3,y:1}]}]})},spring:function(t){var e,n,r,o,u;return null==t&&(t={}),Tools.extend(t,i.spring.defaults,!0),r=Math.max(1,t.frequency/20),o=Math.pow(20,t.friction/100),u=t.anticipationSize/1e3,e=function(e){var n,i;return i=u/(1-u),n=(i-0)/(i-0),(.8-n)/i*e*t.anticipationStrength/100+n},n=function(t){return Math.pow(o/10,-t)*(1-t)},function(t){var i,o,a,s;return s=t/(1-u)-u/(1-u),t<u?(a=u/(1-u)-u/(1-u),i=0/(1-u)-u/(1-u),a=Math.acos(1/e(a)),o=(Math.acos(1/e(i))-a)/(r*-u),i=e):(i=n,a=0,o=1),1-i(s)*Math.cos(r*(t-u)*o+a)}},bounce:function(t){var e,n,r,o;return null==t&&(t={}),Tools.extend(t,i.bounce.defaults),r=Math.max(1,t.frequency/20),o=Math.pow(20,t.friction/100),e=function(t){return Math.pow(o/10,-t)*(1-t)},n=function(t){return e(t)*Math.cos(r*t*1+-1.57)},n.initialForce=!0,n},gravity:function(t){var e,n,r,o,u,a;return null==t&&(t={}),Tools.extend(t,i.gravity.defaults),n=Math.min(t.bounciness/1250,.8),o=t.elasticity/1e3,r=[],e=function(){var i;for(i=Math.sqrt(.02),i={a:-i,b:i,H:1},t.initialForce&&(i.a=0,i.b*=2);.001<i.H;)e=i.b-i.a,i={a:i.b,b:i.b+e*n,H:i.H*n*n};return i.b}(),a=function(n,i,r,o){return e=i-n,n=2/e*o-1-2*n/e,r=n*n*r-r+1,t.initialForce&&(r=1-r),r},function(){var i,u,a;for(i=Math.sqrt(2/(100*e*e)),u={a:-i,b:i,H:1},t.initialForce&&(u.a=0,u.b*=2),r.push(u),a=[];1>u.b&&.001<u.H;)i=u.b-u.a,u={a:u.b,b:u.b+i*n,H:u.H*o},a.push(r.push(u));return a}(),u=function e(n){var i,e;for(e=0,i=r[e];!(n>=i.a&&n<=i.b)&&(e+=1,i=r[e]););return i?a(i.a,i.b,i.H,n):t.initialForce?0:1},u.initialForce=t.initialForce,u},forceWithGravity:function(t){return null==t&&(t={}),Tools.extend(t,i.forceWithGravity.defaults),t.initialForce=!0,i.gravity(t)}};i.spring.defaults={frequency:300,friction:200,anticipationSize:0,anticipationStrength:0},i.bounce.defaults={frequency:300,friction:200},i.forceWithGravity.defaults=i.gravity.defaults={bounciness:400,elasticity:200},i.easeInOut.defaults=i.easeIn.defaults=i.easeOut.defaults={friction:500},e.default=i},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i={Linear:function(t,e){var n=t.length-1,r=n*e,o=Math.floor(r),u=i.Utils.Linear;return e<0?u(t[0],t[1],r):e>1?u(t[n],t[n-1],n-r):u(t[o],t[o+1>n?n:o+1],r-o)},Bezier:function(t,e){for(var n=0,r=t.length-1,o=Math.pow,u=i.Utils.Bernstein,a=0;a<=r;a++)n+=o(1-e,r-a)*o(e,a)*t[a]*u(r,a);return n},CatmullRom:function(t,e){var n=t.length-1,r=n*e,o=Math.floor(r),u=i.Utils.CatmullRom;return t[0]===t[n]?(e<0&&(o=Math.floor(r=n*(1+e))),u(t[(o-1+n)%n],t[o],t[(o+1)%n],t[(o+2)%n],r-o)):e<0?t[0]-(u(t[0],t[0],t[1],t[1],-r)-t[0]):e>1?t[n]-(u(t[n],t[n],t[n-1],t[n-1],r-n)-t[n]):u(t[o?o-1:0],t[o],t[n<o+1?n:o+1],t[n<o+2?n:o+2],r-o)},Utils:{Linear:function(t,e,n){return(e-t)*n+t},Bernstein:function(t,e){var n=i.Utils.Factorial;return n(t)/n(e)/n(t-e)},Factorial:function(){var t=[1];return function(e){var n=1;if(t[e])return t[e];for(var i=e;i>1;i--)n*=i;return t[e]=n,n}}(),CatmullRom:function(t,e,n,i,r){var o=.5*(n-t),u=.5*(i-e),a=r*r,s=r*a;return(2*e-2*n+o+u)*s+(-3*e+3*n-2*o-u)*a+o*r+e}}};e.default=i},function(t,e,n){"use strict";function i(t){g(o)?(o=t,s=requestAnimationFrame(i),v("autostart",t)):(u=!1,cancelAnimationFrame(s),v("stop",t))}Object.defineProperty(e,"__esModule",{value:!0});var r=[],o=0,u=!1,a=!1,s=void 0,c={},f=function(){return r},l=function(t){a=t},h=function(){r=[]},v=function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];void 0!==c[t]&&c[t].map(function(t){return t.apply(void 0,n)})},d=function(t,e){if(void 0!==t&&void 0!==c[t])if(void 0!==e)for(var n=c[name],i=0;i<n.length;)n[i]===e&&n.splice(i,1),i++;else c[name]=[]},p=function(t){r.push(t),a&&!u&&(i(b()),u=!0,v("start")),v("add",t,r)},y=function(t,e){void 0===c[t]&&(c[t]=[]),c[t].push(e)},m=function(t,e){void 0===c[t]&&(c[t]=[]),y(t,function(){e.apply(void 0,arguments),d(t)})},_=function(t){r.filter(function(e){return e!==t});for(var e=0,n=void 0;e<r.length;)n=r[e],n===t&&(v("remove",t,r),r.splice(e,1)),e++},b=function(){return o},g=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:b(),e=arguments[1];if(t=void 0!==t?t:b(),o=t,v("update",t,r),0===r.length)return!1;v("realupdate",t,r);for(var n=0;n<r.length;)r[n].update(t)||e?n++:r.splice(n,1);return!0};e.getAll=f,e.removeAll=h,e.remove=_,e.add=p,e.now=b,e.update=g,e.autoPlay=l,e.on=y,e.once=m,e.off=d,e.emit=v},function(t,e,n){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var o="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},u=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),a=n(2),s=n(0),c=i(s),f=n(1),l=i(f),h=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),this.object=e,this._valuesStart=t.createEmptyConst(e),this._valuesStartRepeat=t.createEmptyConst(e),this._valuesEnd=t.createEmptyConst(e),this._chainedTweens=[],this._duration=1e3,this._easingFunction=c.default.Linear.None,this._interpolationFunction=l.default.None,this._startTime=0,this._delayTime=0,this._repeat=0,this._r=0,this._isPlaying=!1,this._yoyo=!1,this._reversed=!1,this._onStartCallbackFired=!1,this._events={},this._pausedTime=0,this}return u(t,[{key:"isPlaying",value:function(){return this._isPlaying}},{key:"isStarted",value:function(){return this._onStartCallbackFired}},{key:"reverse",value:function(){var t=this._valuesStartRepeat,e=this._yoyo,n=this._valuesEnd,i=this._valuesStart;for(var r in t){if("string"==typeof n[r]&&(t[r]=t[r]+parseFloat(n[r])),e){var o=t[r];t[r]=n[r],n[r]=o}i[r]=t[r]}return this._reversed=!this._reversed,this}},{key:"off",value:function(t,e){if(void 0===this._events[t])return this;if(void 0!==t&&void 0!==e)for(var n=this._events[t],i=0;i<n.length;)n[i]===e&&n.splice(i,1),i++;else void 0!==t&&void 0===e&&(this._events[t]=[]);return this}},{key:"on",value:function(t,e){return void 0===this._events[t]&&(this._events[t]=[]),this._events[t].push(e),this}},{key:"once",value:function(t,e){var n=this;return void 0===this._events[t]&&(this._events[t]=[]),this.on(t,function(){for(var i=arguments.length,r=Array(i),o=0;o<i;o++)r[o]=arguments[o];e.call.apply(e,[n].concat(r)),n.off(t)})}},{key:"emit",value:function(t){for(var e=this,n=arguments.length,i=Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return void 0===this._events[t]?this:(this._events[t].map(function(t){t.call.apply(t,[e].concat(i))}),this)}},{key:"pause",value:function(){return this._isPlaying?(this._isPlaying=!1,(0,a.remove)(this),this._pausedTime=(0,a.now)(),this.emit("pause",this.object)):this}},{key:"play",value:function(){return this._isPlaying?this:(this._isPlaying=!0,this._startTime+=(0,a.now)()-this._pausedTime,(0,a.add)(this),this._pausedTime=(0,a.now)(),this.emit("play",this.object))}},{key:"restart",value:function(t){return this._repeat=this._r,this._startTime=(0,a.now)()+(t?0:this._delayTime),this._isPlaying||(0,a.add)(this),this.emit("restart",this._object)}},{key:"seek",value:function(t,e){return this._startTime=(0,a.now)()+Math.max(0,Math.min(t,this._duration)),this.emit("seek",t,this._object),e?this:this.pause()}},{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]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3;if("number"==typeof t){var n={Number:t};this._valuesEnd=n}else this._valuesEnd=t;if("number"==typeof e)this._duration=e;else if("object"===("undefined"==typeof e?"undefined":o(e)))for(var i in e)this[i](e[i]);return this}},{key:"start",value:function(e){var n=this._startTime,i=this._delayTime,r=this._valuesEnd,o=this._valuesStart,u=(this._valuesStartRepeat,this.object);n=void 0!==e?e:(0,a.now)(),n+=i,this._startTime=n;for(var s in r){if("number"==typeof u[s]&&r[s]instanceof Array){if(0===r[s].length)continue;this._valuesEnd[s]=[u[s]].concat(r[s])}t.checkValidness(u[s])!==!1&&(this._valuesStart[s]=u[s],this._valuesStartRepeat[s]=o[s]||0)}return(0,a.add)(this),this._isPlaying=!0,this}},{key:"stop",value:function(){var t=this._isPlaying,e=(this._onStopCallback,this.object);return t?((0,a.remove)(this),this._isPlaying=!1,this.stopChainedTweens(),this.emit("stop",e)):this}},{key:"end",value:function(){var t=this._startTime,e=this._duration;return this.update(t+e)}},{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._r=t,this}},{key:"repeatDelay",value:function(t){return this._repeatDelayTime=t,this}},{key:"reverseDelay",value:function(t){return this._reverseDelayTime=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,e=Array(t),n=0;n<t;n++)e[n]=arguments[n];return this._chainedTweens=e,this}},{key:"get",value:function(t){return this.update(t),this._object}},{key:"update",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:(0,a.now)(),e=this._onStartCallbackFired,n=this._chainedTweens,i=this._easingFunction,r=this._interpolationFunction,o=this._repeat,u=this._repeatDelayTime,s=this._reverseDelayTime,c=this._delayTime,f=this._yoyo,l=this._reversed,h=this._startTime,v=this._duration,d=this._valuesStart,p=(this._valuesStartRepeat,this._valuesEnd),y=this.object,m=void 0,_=void 0,b=void 0;if(t<h)return!0;e===!1&&(this.emit("start",y),this._onStartCallbackFired=!0),_=(t-h)/v,_=_>1?1:_,b=i(_);for(m in p)if(void 0!==d[m]){var g=d[m],M=p[m];M instanceof Array?y[m]=r(M,b):("string"==typeof M&&(M="+"===M.charAt(0)||"-"===M.charAt(0)?g+parseFloat(M):parseFloat(M)),"number"==typeof M&&(y[m]=g+(M-g)*b))}return this.emit("update",y,_),1!==_||(o>0?(isFinite(o)&&this._repeat--,this.reverse(),this.emit(l?"reverse":"repeat",y),f&&(this._reversed=!l),l||void 0===u?l&&void 0!==s?this._startTime+=v+s:this._startTime+=v+c:this._startTime+=v+u,!0):(this.emit("complete",y),n.map(function(t){return t.start(h+v)}),!1))}}],[{key:"createEmptyConst",value:function(t){return"number"==typeof t?0:Array.isArray(t)?[]:"object"===("undefined"==typeof t?"undefined":o(t))?{}:""}},{key:"checkValidness",value:function(t){return void 0!==t&&null!==t&&""!==t&&NaN!==t&&t!==1/0}}]),t}();e.default=h},function(t,e,n){"use strict";void 0===Object.assign&&(Object.assign=function(){for(var t=arguments.length,e=Array(t),n=0;n<t;n++)e[n]=arguments[n];var i=e.shift();return e.map(function(t){for(var e in t)i[e]=t[e]}),i})},function(t,e,n){"use strict";(function(t){var e="undefined"!=typeof window?window:"undefined"!=typeof t?t:void 0,n=["webkit","moz","ms","o"],i="AnimationFrame",r="Request"+i,o="Cancel"+i,u="CancelRequest"+i,a=setTimeout,s=clearTimeout;if(void 0===e.requestAnimationFrame){var c=void 0,f=void 0,l=Date.now(),h=50/3,v=h;n.map(function(t){void 0===(c=e[t+r])&&(c=function(t){return a(function(){f=Date.now(),t(f-l),v=h+(Date.now()-f)},v)})}),void 0!==c&&(e.requestAnimationFrame=c)}if(void 0===e.cancelAnimationFrame&&void 0===(e.cancelAnimationFrame=e.cancelRequestAnimationFrame)){var d=void 0;n.map(function(t){void 0===(d=e[t+o])&&void 0===(d=e[t+u])&&(d=function(t){return s(t)})}),void 0!==d&&(e.cancelAnimationFrame=d)}}).call(e,n(6))},function(t,e,n){"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,e,n){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0}),e.Interpolation=e.Easing=e.Tween=e.now=e.autoPlay=e.update=e.remove=e.removeAll=e.add=e.getAll=void 0,n(4),n(5);var r=n(2),o=n(0),u=i(o),a=n(3),s=i(a),c=n(1),f=i(c);e.getAll=r.getAll,e.add=r.add,e.removeAll=r.removeAll,e.remove=r.remove,e.update=r.update,e.autoPlay=r.autoPlay,e.now=r.now,e.Tween=s.default,e.Easing=u.default,e.Interpolation=f.default}])}); |
116
package.json
{ | ||
"name": "es6-tween", | ||
"version": "1.0.3", | ||
"description": "ES6 implementation of amazing tween.js", | ||
"main": "dist/Tween.js", | ||
"directories": { | ||
"example": "examples" | ||
}, | ||
"scripts": { | ||
"build": "webpack --env build", | ||
"source": "webpack --progress --colors --env dev", | ||
"dev": "webpack --progress --colors --watch --env dev", | ||
"dist": "npm run source && npm run build", | ||
"dist_test": "npm run dist && npm run test", | ||
"test": "npm run test-unit && npm run test-correctness && npm run test-style", | ||
"test-unit": "nodeunit test/unit/nodeunitheadless.js", | ||
"test-correctness": "jshint --config test/jshintrc src/Tween.js", | ||
"test-style": "jscs --config test/jscs.json src/Tween.js", | ||
"semantic-release": "semantic-release pre && npm publish && semantic-release post" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/tweenjs/es6-tween.git" | ||
}, | ||
"keywords": [ | ||
"tween", | ||
"tweening", | ||
"es6", | ||
"numeric", | ||
"interpolation", | ||
"easing", | ||
"emit" | ||
], | ||
"author": "sole, dalisoft", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/tweenjs/es6-tween/issues" | ||
}, | ||
"homepage": "https://github.com/tweenjs/es6-tween#readme", | ||
"devDependencies": { | ||
"babel": "6.5.2", | ||
"babel-core": "6.22.1", | ||
"babel-eslint": "7.1.1", | ||
"babel-loader": "6.2.10", | ||
"babel-plugin-add-module-exports": "0.1.2", | ||
"babel-plugin-transform-es2015-classes": "latest", | ||
"babel-plugin-transform-proto-to-assign": "latest", | ||
"babel-plugin-transform-react-jsx": "latest", | ||
"babel-preset-es2015": "6.22.0", | ||
"eslint": "1.7.2", | ||
"eslint-loader": "1.6.1", | ||
"webpack": "2.2.1", | ||
"yargs": "6.6.0", | ||
"jscs": "^2.2.0", | ||
"jshint": "^2.8.0", | ||
"nodeunit": "^0.9.1", | ||
"semantic-release": "^6.3.2" | ||
}, | ||
"dependencies": {} | ||
"name": "es6-tween", | ||
"version": "1.0.4", | ||
"description": "ES6 implementation of amazing tween.js", | ||
"main": "dist/Tween.js", | ||
"directories": { | ||
"example": "examples" | ||
}, | ||
"scripts": { | ||
"build": "webpack --env build", | ||
"source": "webpack --progress --colors --env dev", | ||
"dev": "webpack --progress --colors --watch --env dev", | ||
"dist": "npm run source && npm run build", | ||
"dist_test": "npm run dist && npm run test", | ||
"test": "npm run test-unit && npm run test-correctness && npm run test-style", | ||
"test-unit": "nodeunit test/unit/nodeunitheadless.js", | ||
"test-correctness": "jshint --config test/jshintrc src/Tween.js", | ||
"test-style": "jscs --config test/jscs.json src/Tween.js", | ||
"semantic-release": "semantic-release pre && npm publish && semantic-release post" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/tweenjs/es6-tween.git" | ||
}, | ||
"keywords": [ | ||
"tween", | ||
"tweening", | ||
"es6", | ||
"numeric", | ||
"interpolation", | ||
"easing", | ||
"emit" | ||
], | ||
"author": "sole, dalisoft", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/tweenjs/es6-tween/issues" | ||
}, | ||
"homepage": "https://github.com/tweenjs/es6-tween#readme", | ||
"devDependencies": { | ||
"babel": "6.5.2", | ||
"babel-core": "6.22.1", | ||
"babel-eslint": "7.1.1", | ||
"babel-loader": "6.2.10", | ||
"babel-plugin-add-module-exports": "0.1.2", | ||
"babel-plugin-transform-es2015-classes": "latest", | ||
"babel-plugin-transform-proto-to-assign": "latest", | ||
"babel-plugin-transform-react-jsx": "latest", | ||
"babel-preset-es2015": "6.22.0", | ||
"eslint": "1.7.2", | ||
"eslint-loader": "1.6.1", | ||
"webpack": "2.2.1", | ||
"yargs": "6.6.0", | ||
"jscs": "^2.2.0", | ||
"jshint": "^2.8.0", | ||
"nodeunit": "^0.9.1", | ||
"semantic-release": "^6.3.2" | ||
}, | ||
"dependencies": {} | ||
} |
@@ -143,3 +143,3 @@ const Easing = { | ||
return k === 0 ? 0 : Math.pow(1024, ( k - 1 )); | ||
return k === 0 ? 0 : Math.pow( 1024, ( k - 1 ) ); | ||
@@ -150,3 +150,3 @@ }, | ||
return k === 1 ? 1 : 1 - Math.pow(-10 * k, 2); | ||
return k === 1 ? 1 : 1 - Math.pow( -10 * k, 2 ); | ||
@@ -166,6 +166,6 @@ }, | ||
if ( ( k *= 2 ) < 1 ) { | ||
return 0.5 * Math.pow(1024, ( k - 1 ) ); | ||
return 0.5 * Math.pow( 1024, ( k - 1 ) ); | ||
} | ||
return 0.5 * ( -Math.pow( -10 * ( k - 1 ), 2) + 2 ); | ||
return 0.5 * ( -Math.pow( -10 * ( k - 1 ), 2 ) + 2 ); | ||
@@ -214,3 +214,3 @@ } | ||
return -Math.pow(( 10 * ( k - 1 ) ), 2 ) * Math.sin( ( k - 1.1 ) * 5 * Math.PI ); | ||
return -Math.pow( ( 10 * ( k - 1 ) ), 2 ) * Math.sin( ( k - 1.1 ) * 5 * Math.PI ); | ||
@@ -246,3 +246,3 @@ }, | ||
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 ); | ||
} | ||
@@ -320,6 +320,306 @@ | ||
}, | ||
Stepped( steps ) { | ||
return function( k ) { | ||
return Math.floor( k * steps ) / steps; | ||
} | ||
}, | ||
Noisy( randomProportion, easingFunction ) { | ||
var normalProportion = 1.0 - randomProportion; | ||
return function( k ) { | ||
return randomProportion * Math.random() + normalProportion * easingFunction( k ); | ||
} | ||
}, | ||
// Adapted from https://github.com/michaelvillar/dynamics.js | ||
get bezier() { | ||
var b | ||
, d; | ||
b = function( b, d, g, f, h ) { | ||
var k = Math.pow( 1 - b, 3 ) | ||
, l = 3 * Math.pow( 1 - b, 2 ) * b | ||
, m = 3 * ( 1 - b ) * Math.pow( b, 2 ); | ||
b = Math.pow( b, 3 ); | ||
return { | ||
x: k * d.x + l * g.x + m * f.x + b * h.x | ||
, y: k * d.y + l * g.y + m * f.y + b * h.y | ||
} | ||
}; | ||
d = function( b, d ) { | ||
var g | ||
, f | ||
, h = 0 | ||
, k = 0 | ||
, l = d.length | ||
, m = 0 | ||
, q = 1 | ||
, w = ( q + m ) / 2; | ||
for ( g = null; k < l; ) { | ||
f = d[ k ]; | ||
b >= f( 0 ) | ||
.x && b <= f( 1 ) | ||
.x && ( g = f ); | ||
if ( null !== g ) | ||
break; | ||
k++ | ||
} | ||
if ( !g ) | ||
return 1; | ||
for ( f = g( w ) | ||
.x; 1E-4 < Math.abs( b - f ) && 100 > h; ) | ||
b > f ? m = w : q = w, w = ( q + m ) / 2, f = g( w ) | ||
.x, h++; | ||
return g( w ) | ||
.y | ||
}; | ||
return function( c ) { | ||
null == c && ( c = {} ); | ||
var e = c.points | ||
, g = function() { | ||
var c | ||
, d = 0 | ||
, k = e.length; | ||
g = []; | ||
for ( c = function( d, c ) { | ||
return g.push( function( e ) { | ||
return b( e, d, d.cp[ d.cp.length - 1 ], c.cp[ 0 ], c ) | ||
} ) | ||
}; d < k && !( d >= e.length - 1 ); ) | ||
c( e[ d ], e[ d + 1 ] ), d++; | ||
return g | ||
} | ||
(); | ||
return function( b ) { | ||
return d( b, g ) | ||
} | ||
} | ||
} | ||
, easeInOut( b ) { | ||
var d | ||
, c; | ||
null == b && ( b = {} ); | ||
d = null != ( c = b.friction ) ? c : Easing.easeInOut.defaults.friction; | ||
return Easing.bezier( { | ||
points: [ { | ||
x: 0 | ||
, y: 0 | ||
, cp: [ { | ||
x: .92 - d / 1E3 | ||
, y: 0 | ||
} | ||
] | ||
}, { | ||
x: 1 | ||
, y: 1 | ||
, cp: [ { | ||
x: .08 + d / 1E3 | ||
, y: 1 | ||
} | ||
] | ||
} | ||
] | ||
} ) | ||
} | ||
, easeIn( b ) { | ||
var d | ||
, c; | ||
null == b && ( b = {} ); | ||
d = null != ( c = b.friction ) ? c : Easing.easeIn.defaults.friction; | ||
return Easing.bezier( { | ||
points: [ { | ||
x: 0 | ||
, y: 0 | ||
, cp: [ { | ||
x: .92 - d / 1E3 | ||
, y: 0 | ||
} | ||
] | ||
}, { | ||
x: 1 | ||
, y: 1 | ||
, cp: [ { | ||
x: 1 | ||
, y: 1 | ||
} | ||
] | ||
} | ||
] | ||
} ) | ||
} | ||
, easeOut( b ) { | ||
var d | ||
, c; | ||
null == b && ( b = {} ); | ||
d = null != ( c = b.friction ) ? c : Easing.easeOut.defaults.friction; | ||
return Easing.bezier( { | ||
points: [ { | ||
x: 0 | ||
, y: 0 | ||
, cp: [ { | ||
x: 0 | ||
, y: 0 | ||
} | ||
] | ||
}, { | ||
x: 1 | ||
, y: 1 | ||
, cp: [ { | ||
x: .08 + d / 1E3 | ||
, y: 1 | ||
} | ||
] | ||
} | ||
] | ||
} ) | ||
} | ||
, spring( b ) { | ||
var d | ||
, c | ||
, e | ||
, g | ||
, f; | ||
null == b && ( b = {} ); | ||
Tools.extend( b, Easing.spring.defaults, true ); | ||
e = Math.max( 1, b.frequency / 20 ); | ||
g = Math.pow( 20, b.friction / 100 ); | ||
f = b.anticipationSize / 1E3; | ||
d = function( d ) { | ||
var c | ||
, e; | ||
e = f / ( 1 - f ); | ||
c = ( e - 0 ) / ( e - 0 ); | ||
return ( .8 - c ) / e * d * b.anticipationStrength / 100 + c | ||
}; | ||
c = function( b ) { | ||
return Math.pow( g / 10, -b ) * ( 1 - b ) | ||
}; | ||
return function( b ) { | ||
var g | ||
, l | ||
, m | ||
, q; | ||
q = b / ( 1 - f ) - f / ( 1 - f ); | ||
b < f ? ( m = f / ( 1 - f ) - f / ( 1 - f ), g = 0 / ( 1 - f ) - f / ( | ||
1 - f ), m = Math.acos( | ||
1 / d( m ) ), l = ( Math.acos( 1 / d( g ) ) - m ) / ( e * -f ), g = | ||
d ) : ( g = c, m = 0, l = 1 ); | ||
return 1 - g( q ) * Math.cos( e * ( b - f ) * l + m ) | ||
} | ||
} | ||
, bounce( b ) { | ||
var d | ||
, c | ||
, e | ||
, g; | ||
null == b && ( b = {} ); | ||
Tools.extend( b, Easing.bounce.defaults ); | ||
e = Math.max( 1, b.frequency / 20 ); | ||
g = Math.pow( 20, b.friction / 100 ); | ||
d = function( b ) { | ||
return Math.pow( g / 10, -b ) * ( 1 - b ) | ||
}; | ||
c = function( b ) { | ||
return d( b ) * Math.cos( e * b * 1 + -1.57 ) | ||
}; | ||
c.initialForce = !0; | ||
return c | ||
} | ||
, gravity( b ) { | ||
var d | ||
, c | ||
, e | ||
, g | ||
, f | ||
, h; | ||
null == b && ( b = {} ); | ||
Tools.extend( b, Easing.gravity.defaults ); | ||
c = Math.min( b.bounciness / 1250, .8 ); | ||
g = b.elasticity / 1E3; | ||
e = []; | ||
d = function() { | ||
var e; | ||
e = Math.sqrt( .02 ); | ||
e = { | ||
a: -e | ||
, b: e | ||
, H: 1 | ||
}; | ||
b.initialForce && ( e.a = 0, e.b *= 2 ); | ||
for ( ; .001 < e.H; ) | ||
d = e.b - e.a, e = { | ||
a: e.b | ||
, b: e.b + d * c | ||
, H: e.H * c * c | ||
}; | ||
return e.b | ||
} | ||
(); | ||
h = function( c, e, f, g ) { | ||
d = e - c; | ||
c = 2 / d * g - 1 - 2 * c / d; | ||
f = c * c * f - f + 1; | ||
b.initialForce && ( f = 1 - f ); | ||
return f | ||
}; | ||
( function() { | ||
var f | ||
, h | ||
, m; | ||
f = Math.sqrt( 2 / ( 100 * d * d ) ); | ||
h = { | ||
a: -f | ||
, b: f | ||
, H: 1 | ||
}; | ||
b.initialForce && ( h.a = 0, h.b *= 2 ); | ||
e.push( h ); | ||
for ( m = []; 1 > h.b && .001 < h.H; ) | ||
f = h.b - h.a, h = { | ||
a: h.b | ||
, b: h.b + f * c | ||
, H: h.H * g | ||
} | ||
, m.push( e.push( h ) ); | ||
return m | ||
} )(); | ||
f = function( c ) { | ||
var d | ||
, f; | ||
f = 0; | ||
for ( d = e[ f ]; !( c >= d.a && c <= d.b ) && ( f += 1, d = e[ f ], d ); ); | ||
return d ? h( d.a, d.b, d.H, c ) : b.initialForce ? 0 : 1 | ||
}; | ||
f.initialForce = b.initialForce; | ||
return f | ||
} | ||
, forceWithGravity( b ) { | ||
null == b && ( b = {} ); | ||
Tools.extend( b, Easing.forceWithGravity.defaults ); | ||
b.initialForce = !0; | ||
return Easing.gravity( b ) | ||
} | ||
} | ||
}; | ||
Easing.spring.defaults = { | ||
frequency: 300 | ||
, friction: 200 | ||
, anticipationSize: 0 | ||
, anticipationStrength: 0 | ||
}; | ||
Easing.bounce.defaults = { | ||
frequency: 300 | ||
, friction: 200 | ||
}; | ||
Easing.forceWithGravity.defaults = Easing.gravity.defaults = { | ||
bounciness: 400 | ||
, elasticity: 200 | ||
}; | ||
Easing.easeInOut.defaults = Easing.easeIn.defaults = Easing.easeOut.defaults = { | ||
friction: 500 | ||
}; | ||
export default Easing; |
@@ -42,3 +42,3 @@ import { | ||
static checkValidness ( valid ) { | ||
return valid !== undefined && valid !== null && valid !== ''; | ||
return valid !== undefined && valid !== null && valid !== '' && valid !== NaN && valid !== Infinity; | ||
} | ||
@@ -233,3 +233,3 @@ isPlaying() { | ||
// we should not set that property in the object | ||
if (Tween.checkValidness(object[property])) { | ||
if (Tween.checkValidness(object[property]) === false) { | ||
continue; | ||
@@ -236,0 +236,0 @@ } |
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
387103
2357