es6-tween
Advanced tools
Comparing version 2.2.5 to 2.2.6
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(factory((global.TWEEN = global.TWEEN || {}))); | ||
(factory((global.Tween = global.Tween || {}))); | ||
}(this, (function (exports) { 'use strict'; | ||
if ( Object.assign === undefined ) { | ||
Object.assign = function () { | ||
var args = [], len = arguments.length; | ||
while ( len-- ) args[ len ] = arguments[ len ]; | ||
if (Object.assign === undefined) { | ||
Object.assign = function (first) { | ||
var args = [], len = arguments.length - 1; | ||
while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ]; | ||
var first = args.shift(); | ||
args.map(function (obj) { | ||
for ( var p in obj ) { | ||
first[p] = obj[p]; | ||
} | ||
}); | ||
return first; | ||
}; | ||
args.map(function (obj) { | ||
for (var p in obj) { | ||
first[p] = obj[p]; | ||
} | ||
}); | ||
return first | ||
}; | ||
} | ||
var ROOT = typeof(window) !== "undefined" ? window : typeof(global) !== "undefined" ? global : {}; | ||
var ROOT = typeof (window) !== 'undefined' ? window : typeof (global) !== 'undefined' ? global : typeof exports !== 'undefined' ? exports : {}; | ||
var _vendor = ['webkit', 'moz', 'ms', 'o']; | ||
@@ -28,46 +27,49 @@ var animFrame = 'AnimationFrame'; | ||
var cafSuffixForVendor2 = 'CancelRequest' + animFrame; | ||
var _timeout = setTimeout; | ||
var _clearTimeout = clearTimeout; | ||
var _timeout = ROOT.setTimeout; | ||
var _clearTimeout = ROOT.clearTimeout; | ||
if ( ROOT.requestAnimationFrame === undefined ) { | ||
if (_timeout && ROOT.requestAnimationFrame === undefined) { | ||
var _raf; | ||
var now; | ||
var lastTime = Date.now(); | ||
var frameMs = (50 / 3); | ||
var fpsSec = frameMs; | ||
var _raf, now, lastTime = Date.now(), frameMs = (50 / 3), fpsSec = frameMs; | ||
_vendor.map(function (vendor) { | ||
if ((_raf = ROOT[vendor + rafSuffixForVendor]) === undefined) { | ||
_raf = function (fn) { | ||
return _timeout(function () { | ||
now = Date.now(); | ||
fn(now - lastTime); | ||
fpsSec = frameMs + (Date.now() - now); | ||
}, fpsSec) | ||
}; | ||
} | ||
}); | ||
_vendor.map(function (vendor) { | ||
if ((_raf = ROOT[vendor + rafSuffixForVendor]) === undefined) { | ||
_raf = function (fn) { | ||
return _timeout(function () { | ||
now = Date.now(); | ||
fn(now - lastTime); | ||
fpsSec = frameMs + (Date.now() - now); | ||
}, fpsSec); | ||
}; | ||
} | ||
}); | ||
if (_raf !== undefined) { | ||
ROOT.requestAnimationFrame = _raf; | ||
} | ||
if (_raf !== undefined) { | ||
ROOT.requestAnimationFrame = _raf; | ||
} | ||
} | ||
if ( ROOT.cancelAnimationFrame === undefined && (ROOT.cancelAnimationFrame = ROOT.cancelRequestAnimationFrame) === undefined ) { | ||
var _caf; | ||
if (_clearTimeout && ROOT.cancelAnimationFrame === undefined && (ROOT.cancelAnimationFrame = ROOT.cancelRequestAnimationFrame) === undefined) { | ||
var _caf; | ||
_vendor.map(function (vendor) { | ||
if ((_caf = ROOT[vendor + cafSuffixForVendor]) === undefined && (_caf = ROOT[vendor + cafSuffixForVendor2]) === undefined) { | ||
_caf = function (fn) { | ||
return _clearTimeout(fn); | ||
}; | ||
} | ||
}); | ||
_vendor.map(function (vendor) { | ||
if ((_caf = ROOT[vendor + cafSuffixForVendor]) === undefined && (_caf = ROOT[vendor + cafSuffixForVendor2]) === undefined) { | ||
_caf = function (fn) { | ||
return _clearTimeout(fn) | ||
}; | ||
} | ||
}); | ||
if (_caf !== undefined) { | ||
ROOT.cancelAnimationFrame = _caf; | ||
} | ||
if (_caf !== undefined) { | ||
ROOT.cancelAnimationFrame = _caf; | ||
} | ||
} | ||
if ( Array.isArray === undefined ) { | ||
Array.isArray = function (arrayLike) { | ||
return arrayLike !== undefined && typeof arrayLike === "object" && arrayLike.length && arrayLike.push !== undefined && arrayLike.splice !== undefined; | ||
}; | ||
if (Array.isArray === undefined) { | ||
Array.isArray = function (arrayLike) { | ||
return arrayLike !== undefined && typeof arrayLike === 'object' && arrayLike.length && arrayLike.push !== undefined && arrayLike.splice !== undefined | ||
}; | ||
} | ||
@@ -251,3 +253,3 @@ | ||
None: function None( k ) { | ||
None: function None(k) { | ||
@@ -262,3 +264,3 @@ return k; | ||
In: function In( k ) { | ||
In: function In(k) { | ||
@@ -269,15 +271,15 @@ return k * k; | ||
Out: function Out( k ) { | ||
Out: function Out(k) { | ||
return k * ( 2 - k ); | ||
return k * (2 - k); | ||
}, | ||
InOut: function InOut( k ) { | ||
InOut: function InOut(k) { | ||
if ( ( k *= 2 ) < 1 ) { | ||
if ((k *= 2) < 1) { | ||
return 0.5 * k * k; | ||
} | ||
return -0.5 * ( --k * ( k - 2 ) - 1 ); | ||
return - 0.5 * (--k * (k - 2) - 1); | ||
@@ -290,3 +292,3 @@ } | ||
In: function In( k ) { | ||
In: function In(k) { | ||
@@ -297,3 +299,3 @@ return k * k * k; | ||
Out: function Out( k ) { | ||
Out: function Out(k) { | ||
@@ -304,9 +306,9 @@ return --k * k * k + 1; | ||
InOut: function InOut( k ) { | ||
InOut: function InOut(k) { | ||
if ( ( k *= 2 ) < 1 ) { | ||
if ((k *= 2) < 1) { | ||
return 0.5 * k * k * k; | ||
} | ||
return 0.5 * ( ( k -= 2 ) * k * k + 2 ); | ||
return 0.5 * ((k -= 2) * k * k + 2); | ||
@@ -319,3 +321,3 @@ } | ||
In: function In( k ) { | ||
In: function In(k) { | ||
@@ -326,15 +328,15 @@ return k * k * k * k; | ||
Out: function Out( k ) { | ||
Out: function Out(k) { | ||
return 1 - ( --k * k * k * k ); | ||
return 1 - (--k * k * k * k); | ||
}, | ||
InOut: function InOut( k ) { | ||
InOut: function InOut(k) { | ||
if ( ( k *= 2 ) < 1 ) { | ||
if ((k *= 2) < 1) { | ||
return 0.5 * k * k * k * k; | ||
} | ||
return -0.5 * ( ( k -= 2 ) * k * k * k - 2 ); | ||
return - 0.5 * ((k -= 2) * k * k * k - 2); | ||
@@ -347,3 +349,3 @@ } | ||
In: function In( k ) { | ||
In: function In(k) { | ||
@@ -354,3 +356,3 @@ return k * k * k * k * k; | ||
Out: function Out( k ) { | ||
Out: function Out(k) { | ||
@@ -361,9 +363,9 @@ return --k * k * k * k * k + 1; | ||
InOut: function InOut( k ) { | ||
InOut: function InOut(k) { | ||
if ( ( k *= 2 ) < 1 ) { | ||
if ((k *= 2) < 1) { | ||
return 0.5 * k * k * k * k * k; | ||
} | ||
return 0.5 * ( ( k -= 2 ) * k * k * k * k + 2 ); | ||
return 0.5 * ((k -= 2) * k * k * k * k + 2); | ||
@@ -376,17 +378,17 @@ } | ||
In: function In( k ) { | ||
In: function In(k) { | ||
return 1 - Math.cos( k * Math.PI / 2 ); | ||
return 1 - Math.cos(k * Math.PI / 2); | ||
}, | ||
Out: function Out( k ) { | ||
Out: function Out(k) { | ||
return Math.sin( k * Math.PI / 2 ); | ||
return Math.sin(k * Math.PI / 2); | ||
}, | ||
InOut: function InOut( k ) { | ||
InOut: function InOut(k) { | ||
return 0.5 * ( 1 - Math.cos( Math.PI * k ) ); | ||
return 0.5 * (1 - Math.cos(Math.PI * k)); | ||
@@ -399,29 +401,29 @@ } | ||
In: function In( k ) { | ||
In: function In(k) { | ||
return k === 0 ? 0 : Math.pow( 1024, ( k - 1 ) ); | ||
return k === 0 ? 0 : Math.pow(1024, k - 1); | ||
}, | ||
Out: function Out( k ) { | ||
Out: function Out(k) { | ||
return k === 1 ? 1 : 1 - Math.pow( -10 * k, 2 ); | ||
return k === 1 ? 1 : 1 - Math.pow(2, - 10 * k); | ||
}, | ||
InOut: function InOut( k ) { | ||
InOut: function InOut(k) { | ||
if ( k === 0 ) { | ||
if (k === 0) { | ||
return 0; | ||
} | ||
if ( k === 1 ) { | ||
if (k === 1) { | ||
return 1; | ||
} | ||
if ( ( k *= 2 ) < 1 ) { | ||
return 0.5 * Math.pow( 1024, ( k - 1 ) ); | ||
if ((k *= 2) < 1) { | ||
return 0.5 * Math.pow(1024, k - 1); | ||
} | ||
return 0.5 * ( -Math.pow( -10 * ( k - 1 ), 2 ) + 2 ); | ||
return 0.5 * (- Math.pow(2, - 10 * (k - 1)) + 2); | ||
@@ -434,21 +436,21 @@ } | ||
In: function In( k ) { | ||
In: function In(k) { | ||
return 1 - Math.sqrt( 1 - k * k ); | ||
return 1 - Math.sqrt(1 - k * k); | ||
}, | ||
Out: function Out( k ) { | ||
Out: function Out(k) { | ||
return Math.sqrt( 1 - ( --k * k ) ); | ||
return Math.sqrt(1 - (--k * k)); | ||
}, | ||
InOut: function InOut( k ) { | ||
InOut: function InOut(k) { | ||
if ( ( k *= 2 ) < 1 ) { | ||
return -0.5 * ( Math.sqrt( 1 - k * k ) - 1 ); | ||
if ((k *= 2) < 1) { | ||
return - 0.5 * (Math.sqrt(1 - k * k) - 1); | ||
} | ||
return 0.5 * ( Math.sqrt( 1 - ( k -= 2 ) * k ) + 1 ); | ||
return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1); | ||
@@ -461,37 +463,37 @@ } | ||
In: function In( k ) { | ||
In: function In(k) { | ||
if ( k === 0 ) { | ||
if (k === 0) { | ||
return 0; | ||
} | ||
if ( k === 1 ) { | ||
if (k === 1) { | ||
return 1; | ||
} | ||
return -Math.pow( ( 10 * ( k - 1 ) ), 2 ) * Math.sin( ( k - 1.1 ) * 5 * Math.PI ); | ||
return -Math.pow(2, 10 * (k - 1)) * Math.sin((k - 1.1) * 5 * Math.PI); | ||
}, | ||
Out: function Out( k ) { | ||
Out: function Out(k) { | ||
if ( k === 0 ) { | ||
if (k === 0) { | ||
return 0; | ||
} | ||
if ( k === 1 ) { | ||
if (k === 1) { | ||
return 1; | ||
} | ||
return Math.pow( -10 * k, 2 ) * Math.sin( ( k - 0.1 ) * 5 * Math.PI ) + 1; | ||
return Math.pow(2, -10 * k) * Math.sin((k - 0.1) * 5 * Math.PI) + 1; | ||
}, | ||
InOut: function InOut( k ) { | ||
InOut: function InOut(k) { | ||
if ( k === 0 ) { | ||
if (k === 0) { | ||
return 0; | ||
} | ||
if ( k === 1 ) { | ||
if (k === 1) { | ||
return 1; | ||
@@ -502,7 +504,7 @@ } | ||
if ( k < 1 ) { | ||
return -0.5 * Math.pow( ( 10 * ( k - 1 ) ), 2 ) * Math.sin( ( k - 1.1 ) * 5 * Math.PI ); | ||
if (k < 1) { | ||
return -0.5 * Math.pow(2, 10 * (k - 1)) * 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 0.5 * Math.pow(2, -10 * (k - 1)) * Math.sin((k - 1.1) * 5 * Math.PI) + 1; | ||
@@ -515,27 +517,27 @@ } | ||
In: function In( k ) { | ||
In: function In(k) { | ||
var s = 1.70158; | ||
return k * k * ( ( s + 1 ) * k - s ); | ||
return k * k * ((s + 1) * k - s); | ||
}, | ||
Out: function Out( k ) { | ||
Out: function Out(k) { | ||
var s = 1.70158; | ||
return --k * k * ( ( s + 1 ) * k + s ) + 1; | ||
return --k * k * ((s + 1) * k + s) + 1; | ||
}, | ||
InOut: function InOut( k ) { | ||
InOut: function InOut(k) { | ||
var s = 1.70158 * 1.525; | ||
if ( ( k *= 2 ) < 1 ) { | ||
return 0.5 * ( k * k * ( ( s + 1 ) * k - s ) ); | ||
if ((k *= 2) < 1) { | ||
return 0.5 * (k * k * ((s + 1) * k - s)); | ||
} | ||
return 0.5 * ( ( k -= 2 ) * k * ( ( s + 1 ) * k + s ) + 2 ); | ||
return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2); | ||
@@ -548,18 +550,18 @@ } | ||
In: function In( k ) { | ||
In: function In(k) { | ||
return 1 - Easing.Bounce.Out( 1 - k ); | ||
return 1 - Easing.Bounce.Out(1 - k); | ||
}, | ||
Out: function Out( k ) { | ||
Out: function Out(k) { | ||
if ( k < ( 1 / 2.75 ) ) { | ||
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 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; | ||
return 7.5625 * (k -= (2.625 / 2.75)) * k + 0.984375; | ||
} | ||
@@ -569,340 +571,38 @@ | ||
InOut: function InOut( k ) { | ||
InOut: function InOut(k) { | ||
if ( k < 0.5 ) { | ||
return Easing.Bounce.In( k * 2 ) * 0.5; | ||
if (k < 0.5) { | ||
return Easing.Bounce.In(k * 2) * 0.5; | ||
} | ||
return Easing.Bounce.Out( k * 2 - 1 ) * 0.5 + 0.5; | ||
return Easing.Bounce.Out(k * 2 - 1) * 0.5 + 0.5; | ||
} | ||
}, | ||
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 ); | ||
} | ||
}, | ||
// Credits: | ||
// @michaelvillar for dynamics.js easing/physics | ||
// Adapted by @dalisoft | ||
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: 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 ) { | ||
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: 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( 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: 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( 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: 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 | ||
}; | ||
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 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 ); | ||
return fn(v[i], v[i + 1 > m ? m : i + 1], f - i); | ||
}, | ||
Bezier: function Bezier( v, k ) { | ||
Bezier: function Bezier(v, k) { | ||
@@ -914,4 +614,4 @@ var b = 0; | ||
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); | ||
} | ||
@@ -923,28 +623,28 @@ | ||
CatmullRom: function CatmullRom( v, k ) { | ||
CatmullRom: function CatmullRom(v, k) { | ||
var m = v.length - 1; | ||
var f = m * k; | ||
var i = Math.floor( f ); | ||
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 ); | ||
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); | ||
@@ -957,19 +657,19 @@ } | ||
Linear: function Linear( p0, p1, t ) { | ||
Linear: function Linear(p0, p1, t) { | ||
return ( p1 - p0 ) * t + p0; | ||
return (p1 - p0) * t + p0; | ||
}, | ||
Bernstein: function Bernstein( n, i ) { | ||
Bernstein: function Bernstein(n, i) { | ||
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]; | ||
@@ -980,11 +680,11 @@ return function (n) { | ||
if ( a[ n ] ) { | ||
return a[ n ]; | ||
if (a[n]) { | ||
return a[n]; | ||
} | ||
for ( var i = n; i > 1; i-- ) { | ||
for (var i = n; i > 1; i--) { | ||
s *= i; | ||
} | ||
a[ n ] = s; | ||
a[n] = s; | ||
return s; | ||
@@ -994,12 +694,12 @@ | ||
} ) )(), | ||
})(), | ||
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 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; | ||
@@ -1009,2 +709,3 @@ } | ||
} | ||
}; | ||
@@ -1011,0 +712,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(t.TWEEN=t.TWEEN||{})}(this,function(t){"use strict";function n(t,n,e){void 0===t&&(t={}),void 0===n&&(n={}),void 0===e&&(e=R);var i=new e;for(var r in t)void 0!==n[r]?i[r]=n[r]:i[r]=t[r];return i}function e(t){for(var n="",e=0,i=t.length;e<i;e++)n+=t[e];return n}function i(t){var n=parseFloat(t);return"number"!=typeof n||isNaN(n)?t:n}function r(t){var n=t.from,e=t.to,i=t.duration;void 0===i&&(i=1e3);var r=t.easing;void 0===r&&(r=G);var o=t.events,a=t.instance,u=new R(n,a).to(e,i).easing(G);o&&(u._events=o),t.start=u.start.bind(u)}void 0===Object.assign&&(Object.assign=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var e=t.shift();return t.map(function(t){for(var n in t)e[n]=t[n]}),e});var o="undefined"!=typeof window?window:"undefined"!=typeof global?global:{},a=["webkit","moz","ms","o"],u="AnimationFrame",s="Request"+u,f="Cancel"+u,c="CancelRequest"+u,h=setTimeout,p=clearTimeout;if(void 0===o.requestAnimationFrame){var l,v,d=Date.now(),y=50/3,m=y;a.map(function(t){void 0===(l=o[t+s])&&(l=function(t){return h(function(){v=Date.now(),t(v-d),m=y+(Date.now()-v)},m)})}),void 0!==l&&(o.requestAnimationFrame=l)}if(void 0===o.cancelAnimationFrame&&void 0===(o.cancelAnimationFrame=o.cancelRequestAnimationFrame)){var _;a.map(function(t){void 0===(_=o[t+f])&&void 0===(_=o[t+c])&&(_=function(t){return p(t)})}),void 0!==_&&(o.cancelAnimationFrame=_)}void 0===Array.isArray&&(Array.isArray=function(t){return void 0!==t&&"object"==typeof t&&t.length&&void 0!==t.push&&void 0!==t.splice});var b,g=[],M=!1,w=!1,T={},x="undefined"!=typeof window?window:"undefined"!=typeof global?global:{},F=function(){return g},I=function(t){w=t},O=function(){g=[]},j=function(t,n,e,i,r,o){var a=this,u=T[t];if(u)for(var s=u.length;s--;)u[s].call(a,n,e,i,r,o)},A=function(t,n){if(void 0!==t&&void 0!==T[t])if(void 0!==n)for(var e=T[name],i=0;i<e.length;)e[i]===n&&e.splice(i,1),i++;else T[name]=[]},E=function(t){g.push(t),w&&!M&&(q(),M=!0,j("start")),j("add",t,g)},P=function(t,n){void 0===T[t]&&(T[t]=[]),T[t].push(n)},S=function(t,n){void 0===T[t]&&(T[t]=[]),P(t,function(){for(var e=[],i=arguments.length;i--;)e[i]=arguments[i];n.apply(void 0,e),A(t)})},C=function(t){g.filter(function(n){return n!==t});for(var n,e=0;e<g.length;)n=g[e],n===t&&(j("remove",t,g),g.splice(e,1)),e++},N=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!==x.performance&&void 0!==x.performance.now)return x.performance.now.bind(x.performance);var t=x.performance&&x.performance.timing&&x.performance.timing.navigationStart?x.performance.timing.navigationStart:Date.now();return function(){return Date.now()-t}}(),q=function(t,n){if(t=void 0!==t?t:N(),w&&(b=requestAnimationFrame(q)),j("update",t,g),0===g.length)return M=!1,cancelAnimationFrame(b),j("stop",t),!1;for(var e=0;e<g.length;)g[e].update(t)||n?e++:g.splice(e,1);return!0};if(x.document){var k=x.document,D=0,z=0;k.addEventListener("visibilitychange",function(t){return 0!==g.length&&(document.hidden?z=N():(D=N()-z,g.map(function(t){return t._startTime+=D})),!0)})}var H={Linear:{None:function(t){return t}},Quadratic:{In:function(t){return t*t},Out:function(t){return t*(2-t)},InOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}},Cubic:{In:function(t){return t*t*t},Out:function(t){return--t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}},Quartic:{In:function(t){return t*t*t*t},Out:function(t){return 1- --t*t*t*t},InOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}},Quintic:{In:function(t){return t*t*t*t*t},Out:function(t){return--t*t*t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},Sinusoidal:{In:function(t){return 1-Math.cos(t*Math.PI/2)},Out:function(t){return Math.sin(t*Math.PI/2)},InOut:function(t){return.5*(1-Math.cos(Math.PI*t))}},Exponential:{In:function(t){return 0===t?0:Math.pow(1024,t-1)},Out:function(t){return 1===t?1:1-Math.pow(-10*t,2)},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(-Math.pow(-10*(t-1),2)+2)}},Circular:{In:function(t){return 1-Math.sqrt(1-t*t)},Out:function(t){return Math.sqrt(1- --t*t)},InOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},Elastic:{In:function(t){return 0===t?0:1===t?1:-Math.pow(10*(t-1),2)*Math.sin(5*(t-1.1)*Math.PI)},Out:function(t){return 0===t?0:1===t?1:Math.pow(-10*t,2)*Math.sin(5*(t-.1)*Math.PI)+1},InOut:function(t){return 0===t?0:1===t?1:(t*=2,t<1?-.5*Math.pow(10*(t-1),2)*Math.sin(5*(t-1.1)*Math.PI):.5*Math.pow(-10*(t-1),2)*Math.sin(5*(t-1.1)*Math.PI)+1)}},Back:{In:function(t){var n=1.70158;return t*t*((n+1)*t-n)},Out:function(t){var n=1.70158;return--t*t*((n+1)*t+n)+1},InOut:function(t){var n=2.5949095;return(t*=2)<1?.5*(t*t*((n+1)*t-n)):.5*((t-=2)*t*((n+1)*t+n)+2)}},Bounce:{In:function(t){return 1-H.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*H.Bounce.In(2*t):.5*H.Bounce.Out(2*t-1)+.5}},Stepped:function(t){return function(n){return Math.floor(n*t)/t}},Noisy:function(t,n){var e=1-t;return function(i){return t*Math.random()+e*n(i)}},get bezier(){var t,n;return t=function(t,n,e,i,r){var o=Math.pow(1-t,3),a=3*Math.pow(1-t,2)*t,u=3*(1-t)*Math.pow(t,2);return t=Math.pow(t,3),{x:o*n.x+a*e.x+u*i.x+t*r.x,y:o*n.y+a*e.y+u*i.y+t*r.y}},n=function(t,n){var e,i,r=0,o=0,a=n.length,u=0,s=1,f=(s+u)/2;for(e=null;o<a&&(i=n[o],t>=i(0).x&&t<=i(1).x&&(e=i),null===e);)o++;if(!e)return 1;for(i=e(f).x;1e-4<Math.abs(t-i)&&100>r;)t>i?u=f:s=f,f=(s+u)/2,i=e(f).x,r++;return e(f).y},function(e){null==e&&(e={});var i=e.points,r=function(){var n,e=0,o=i.length;for(r=[],n=function(n,e){return r.push(function(i){return t(i,n,n.cp[n.cp.length-1],e.cp[0],e)})};e<o&&!(e>=i.length-1);)n(i[e],i[e+1]),e++;return r}();return function(t){return n(t,r)}}},easeInOut:function(t){var n,e;return null==t&&(t={}),n=null!=(e=t.friction)?e:H.easeInOut.defaults.friction,H.bezier({points:[{x:0,y:0,cp:[{x:.92-n/1e3,y:0}]},{x:1,y:1,cp:[{x:.08+n/1e3,y:1}]}]})},easeIn:function(t){var n,e;return null==t&&(t={}),n=null!=(e=t.friction)?e:H.easeIn.defaults.friction,H.bezier({points:[{x:0,y:0,cp:[{x:.92-n/1e3,y:0}]},{x:1,y:1,cp:[{x:1,y:1}]}]})},easeOut:function(t){var n,e;return null==t&&(t={}),n=null!=(e=t.friction)?e:H.easeOut.defaults.friction,H.bezier({points:[{x:0,y:0,cp:[{x:0,y:0}]},{x:1,y:1,cp:[{x:.08+n/1e3,y:1}]}]})},spring:function(t){var n,e,i,r,o;return null==t&&(t={}),Tools.extend(t,H.spring.defaults,!0),i=Math.max(1,t.frequency/20),r=Math.pow(20,t.friction/100),o=t.anticipationSize/1e3,n=function(n){var e,i;return i=o/(1-o),e=(i-0)/(i-0),(.8-e)/i*n*t.anticipationStrength/100+e},e=function(t){return Math.pow(r/10,-t)*(1-t)},function(t){var r,a,u,s;return s=t/(1-o)-o/(1-o),t<o?(u=o/(1-o)-o/(1-o),r=0/(1-o)-o/(1-o),u=Math.acos(1/n(u)),a=(Math.acos(1/n(r))-u)/(i*-o),r=n):(r=e,u=0,a=1),1-r(s)*Math.cos(i*(t-o)*a+u)}},bounce:function(t){var n,e,i,r;return null==t&&(t={}),Tools.extend(t,H.bounce.defaults),i=Math.max(1,t.frequency/20),r=Math.pow(20,t.friction/100),n=function(t){return Math.pow(r/10,-t)*(1-t)},e=function(t){return n(t)*Math.cos(i*t*1+-1.57)},e.initialForce=!0,e},gravity:function(t){var n,e,i,r,o,a;return null==t&&(t={}),Tools.extend(t,H.gravity.defaults),e=Math.min(t.bounciness/1250,.8),r=t.elasticity/1e3,i=[],n=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;)n=i.b-i.a,i={a:i.b,b:i.b+n*e,H:i.H*e*e};return i.b}(),a=function(e,i,r,o){return n=i-e,e=2/n*o-1-2*e/n,r=e*e*r-r+1,t.initialForce&&(r=1-r),r},function(){var o,a,u;for(o=Math.sqrt(2/(100*n*n)),a={a:-o,b:o,H:1},t.initialForce&&(a.a=0,a.b*=2),i.push(a),u=[];1>a.b&&.001<a.H;)o=a.b-a.a,a={a:a.b,b:a.b+o*e,H:a.H*r},u.push(i.push(a));return u}(),o=function(n){var e,r;for(r=0,e=i[r];!(n>=e.a&&n<=e.b)&&(r+=1,e=i[r]););return e?a(e.a,e.b,e.H,n):t.initialForce?0:1},o.initialForce=t.initialForce,o},forceWithGravity:function(t){return null==t&&(t={}),Tools.extend(t,H.forceWithGravity.defaults),t.initialForce=!0,H.gravity(t)}};H.spring.defaults={frequency:300,friction:200,anticipationSize:0,anticipationStrength:0},H.bounce.defaults={frequency:300,friction:200},H.forceWithGravity.defaults=H.gravity.defaults={bounciness:400,elasticity:200},H.easeInOut.defaults=H.easeIn.defaults=H.easeOut.defaults={friction:500};var B={Linear:function(t,n){var e=t.length-1,i=e*n,r=Math.floor(i),o=B.Utils.Linear;return n<0?o(t[0],t[1],i):n>1?o(t[e],t[e-1],e-i):o(t[r],t[r+1>e?e:r+1],i-r)},Bezier:function(t,n){for(var e=0,i=t.length-1,r=Math.pow,o=B.Utils.Bernstein,a=0;a<=i;a++)e+=r(1-n,i-a)*r(n,a)*t[a]*o(i,a);return e},CatmullRom:function(t,n){var e=t.length-1,i=e*n,r=Math.floor(i),o=B.Utils.CatmullRom;return t[0]===t[e]?(n<0&&(r=Math.floor(i=e*(1+n))),o(t[(r-1+e)%e],t[r],t[(r+1)%e],t[(r+2)%e],i-r)):n<0?t[0]-(o(t[0],t[0],t[1],t[1],-i)-t[0]):n>1?t[e]-(o(t[e],t[e],t[e-1],t[e-1],i-e)-t[e]):o(t[r?r-1:0],t[r],t[e<r+1?e:r+1],t[e<r+2?e:r+2],i-r)},Utils:{Linear:function(t,n,e){return(n-t)*e+t},Bernstein:function(t,n){var e=B.Utils.Factorial;return e(t)/e(n)/e(t-n)},Factorial:function(){var t=[1];return function(n){var e=1;if(t[n])return t[n];for(var i=n;i>1;i--)e*=i;return t[n]=e,e}}(),CatmullRom:function(t,n,e,i,r){var o=.5*(e-t),a=.5*(i-n),u=r*r,s=r*u;return(2*n-2*e+o+a)*s+(-3*n+3*e-2*o-a)*u+o*r+n}}},L=/\s+|([A-Za-z?().,{}:""\[\]#]+)|([-+\/*%]+=)?([-+*\/%]+)?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/gi,R=function t(n,e){return void 0===n&&(n={}),this.object=n,this._valuesStart=t.createEmptyConst(n),this._valuesEnd=t.createEmptyConst(n),this._duration=1e3,this._easingFunction=H.Linear.None,this._interpolationFunction=B.None,this._startTime=0,this._delayTime=0,this._repeat=0,this._r=null,this._isPlaying=!1,this._yoyo=!1,this._reversed=null,this._onStartCallbackFired=!1,this._pausedTime=null,e&&e.to?new t(n).to(e.to,e):this};R.createEmptyConst=function(t){return"number"==typeof t?0:Array.isArray(t)?[]:"object"==typeof t?{}:""},R.checkValidness=function(t){return void 0!==t&&null!==t&&""!==t&&NaN!==t&&t!==1/0},R.prototype.isPlaying=function(){return this._isPlaying},R.prototype.isStarted=function(){return this._onStartCallbackFired},R.prototype.reverse=function(){var t=this,n=t._reversed;return this._reversed=!n,this},R.prototype.reversed=function(){return this._reversed},R.prototype.off=function(t,n){if(!this._events||void 0===this._events[t])return this;if(void 0!==t&&void 0!==n)for(var e=this._events[t],i=0;i<e.length;)e[i]===n&&e.splice(i,1),i++;else void 0!==t&&void 0===n&&(this._events[t]=[]);return this},R.prototype.on=function(t,n){return this._events&&void 0!==this._events[t]||(this._events||(this._events={}),this._events[t]=[]),this._events[t].push(n),this},R.prototype.once=function(t,n){var e=this;return this._events&&void 0!==this._events[t]||(this._events||(this._events={}),this._events[t]=[]),this.on(t,function(){for(var i=[],r=arguments.length;r--;)i[r]=arguments[r];n.call.apply(n,[e].concat(i)),e.off(t)})},R.prototype.emit=function(t,n,e,i,r,o){var a=this,u=this,s=u._events;if(!s)return this;var f=s[t];if(!f)return this;for(var c=f.length;c--;)f[c].call(a,n,e,i,r,o);return this},R.prototype.pause=function(){return this._isPlaying?(this._isPlaying=!1,C(this),this._pausedTime=N(),this.emit("pause",this.object)):this},R.prototype.play=function(){return this._isPlaying?this:(this._isPlaying=!0,this._startTime+=N()-this._pausedTime,E(this),this._pausedTime=N(),this.emit("play",this.object))},R.prototype.restart=function(t){return this._repeat=this._r,this._startTime=N()+(t?0:this._delayTime),this._isPlaying||E(this),this.emit("restart",this._object)},R.prototype.seek=function(t,n){return this._startTime=N()+Math.max(0,Math.min(t,this._duration)),this.emit("seek",t,this._object),n?this:this.pause()},R.prototype.duration=function(t){return this._duration="function"==typeof t?t(this._duration):t,this},R.prototype.to=function(t,n){var e=this;if(void 0===t&&(t={}),void 0===n&&(n=1e3),"number"==typeof t){var i={Number:t};this._valuesEnd=i}else this._valuesEnd=t;if("number"==typeof n)this._duration="function"==typeof n?n(this._duration):n;else if("object"==typeof n)for(var r in n)e[r]&&e[r]("function"==typeof n[r]?n[r](e._duration):n);return this},R.prototype.start=function(t){var e=this,r=this,o=r._startTime,a=r._delayTime,u=r._valuesEnd,s=(r._valuesStart,r.object);o=void 0!==t?t:N(),o+=a,this._startTime=o;for(var f in u){if("object"==typeof u[f])if(Array.isArray(u[f]))if("number"==typeof s[f])e._valuesEnd[f]=[s[f]].concat(u[f]);else{var c=n(e,{object:s[f],_valuesEnd:u[f],_events:void 0}).start().stop();e._valuesEnd[f]=c}else{var h=n(e,{object:s[f],_valuesEnd:u[f],_events:void 0}).start().stop();e._valuesStart[f]=1,e._valuesEnd[f]=h}else if("string"==typeof u[f]&&"string"==typeof s[f]&&L.test(s[f])&&L.test(u[f])){var p=s[f].match(L);p=p.map(i);var l=u[f].match(L);l=l.map(i);var v=n(e,{object:p,_valuesEnd:l,_events:{}}).start().stop();v.join=!0,e._valuesStart[f]=1,e._valuesEnd[f]=v}"function"==typeof s[f]&&(s[f]=e.object[f]=s[f](e)),"function"==typeof u[f]&&(e._valuesEnd[f]=u[f](e)),R.checkValidness(s[f])!==!1&&s[f]!==u[f]&&(e._valuesStart[f]=s[f])}return E(this),this._isPlaying=!0,this},R.prototype.stop=function(){var t=this,n=t._isPlaying,e=t.object;return n?(C(this),this._isPlaying=!1,this.stopChainedTweens(),this.emit("stop",e)):this},R.prototype.end=function(){var t=this,n=t._startTime,e=t._duration;return this.update(n+e)},R.prototype.stopChainedTweens=function(){var t=this,n=t._chainedTweens;return void 0===n&&(n=[]),n.map(function(t){return t.stop()}),this},R.prototype.delay=function(t){return this._delayTime="function"==typeof t?t(this._delayTime):t,this},R.prototype.repeat=function(t){return this._repeat="function"==typeof t?t(this._repeat):t,this._r=this._repeat,this},R.prototype.repeatDelay=function(t){return this._repeatDelayTime="function"==typeof t?t(this._repeatDelayTime):t,this},R.prototype.reverseDelay=function(t){return this._reverseDelayTime="function"==typeof t?t(this._reverseDelayTime):t,this},R.prototype.yoyo=function(t){return this._yoyo="function"==typeof t?t(this._yoyo):t,this},R.prototype.easing=function(t){return this._easingFunction=t,this},R.prototype.interpolation=function(t){return this._interpolationFunction=t,this},R.prototype.chain=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];return this._chainedTweens=t,this},R.prototype.get=function(t){return this.update(t),this.object},R.prototype.update=function(t){var n,i,r,o=this,a=this,u=a._onStartCallbackFired,s=a._chainedTweens,f=a._easingFunction,c=a._interpolationFunction,h=a._repeat,p=a._repeatDelayTime,l=a._reverseDelayTime,v=(a._delayTime,a._yoyo),d=a._reversed,y=a._startTime,m=a._duration,_=a._valuesStart,b=a._valuesEnd,g=a.object;if(t=void 0!==t?t:N(),t<y)return!0;u||(this.emit("start",g),this._onStartCallbackFired=!0),i=(t-y)/m,i=i>1?1:i,i=d?1-i:i,r=f(i);for(n in b)if(void 0!==_[n]){var M=_[n],w=b[n];if(w instanceof R){var T=w.get(t);w.join?g[n]=e(T):g[n]=T}else Array.isArray(w)?g[n]=c(w,r):"string"==typeof w?(w="+"===w.charAt(0)||"-"===w.charAt(0)?M+parseFloat(w):parseFloat(w),"number"==typeof w&&(g[n]=M+(w-M)*r)):"number"==typeof w&&(g[n]=M+(w-M)*r)}if(this.emit("update",g,r,i),1===i||d&&0===i){if(h){isFinite(h)&&this._repeat--;for(n in b)"string"==typeof b[n]&&"number"==typeof _[n]&&(o._valuesStart[n]=_[n]+parseFloat(b[n]));return this.emit(d?"reverse":"repeat",g),v&&(this._reversed=!d),!d&&p?this._startTime+=m+p:d&&l?this._startTime+=m+l:this._startTime+=m,!0}return this.emit("complete",g),s&&s.map(function(t){return t.start(y+m)}),!1}return!0};var U={filter:{grayscale:1,brightness:1,sepia:1,invert:1,saturate:1,contrast:1,blur:1,hueRotate:1,dropShadow:1},transform:{translate:1,translateX:1,translateY:1,translateZ:1,rotate:1,rotateX:1,rotateY:1,rotateZ:1,scale:1,scaleX:1,scaleY:1,scaleZ:1,skew:1,skewX:1,skewY:1}},W=function(){};W.DOM=function(t){var n=t.domNode,e=n.style;return{update:function(t,n){for(var i in n)e[i]=n[i]}}},W.Transform=function(t){var n=t.domNode,e=n.style;return{update:function(t,n){var i="";for(var r in n)"x"===r||"y"===r||"z"===r?i+=" translate3d( "+(n.x||"0px")+", "+(n.y||"0px")+", "+(n.z||"0px")+")":U.transform[r]&&(i+=" "+r+"( "+n[r]+")");i&&(e.transform=i)}}},W.Filter=function(t){var n=t.domNode,e=n.style;return{update:function(t,n){var i="";for(var r in n)U.filter[r]&&(i+=" "+r+"( "+n[r]+")");i&&(e.webkitFilter=e.filter=i)}}},W.Scroll=function(t){var n=t.domNode;return{update:function(t,e){for(var i in e)n[i]=e[i]}}};var X=function(t){this.domNode=t,this.plugins={};var n=this.plugins;return this.render=function(t){var e=this;for(var i in n)n[i]&&n[i].update&&n[i].update(e,t);return this},this.fetch=function(){var t=this;if(Object.keys(this.object).length)return this;for(var e in n)n[e]&&n[e].fetch&&n[e].fetch(t);return this},this.init=function(t){var e=this;for(var i in n)n[i]&&n[i].init&&n[i].init(e,t);return this},this},Y={object:{}};X.prototype.applyPlugin=function(t){return void 0!==W[t]&&(this.plugins[t]=W[t](this)),this},Y.object.set=function(t){return this.render(t)},X.prototype.cloneLayer=function(){return n(this,{},X)},X.prototype.appendTo=function(t){return t.appendChild(this.domNode),this},Object.defineProperties(X.prototype,Y);var Z=function(){return this._private={tweens:[],fullTime:0},this};Z.prototype.add=function(t){var n=this;if(t instanceof R)this._private.tweens.push(t);else if(Array.isArray(t)||"object"!=typeof t)"object"==typeof t&&t.map(function(t){n.add(t)});else{var e=new R({x:0});for(var i in t)e[i](t[i]);this.add(e)}return this},Z.prototype.start=function(){var t=this;return this._private.tweens.map(function(n){n.start(t._private.fullTime)}),this._private.fullTime=Math.max.apply(0,this._private.tweens.reduce(function(t,n){return n._duration>t?n._duration:t},0)),this};var G=function(t){return t};t.TweenInit=r,t.getAll=F,t.removeAll=O,t.remove=C,t.add=E,t.now=N,t.update=q,t.autoPlay=I,t.on=P,t.once=S,t.off=A,t.emit=j,t.Tween=R,t.Easing=H,t.Interpolation=B,t.Composite=X,t.Timeline=Z,t.Plugins=W,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=t.Tween||{})}(this,function(t){"use strict";function e(t,e,n){void 0===t&&(t={}),void 0===e&&(e={}),void 0===n&&(n=U);var i=new n;for(var r in t)void 0!==e[r]?i[r]=e[r]:i[r]=t[r];return i}function n(t){for(var e="",n=0,i=t.length;n<i;n++)e+=t[n];return e}function i(t){var e=parseFloat(t);return"number"!=typeof e||isNaN(e)?t:e}function r(t){var e=t.from,n=t.to,i=t.duration;void 0===i&&(i=1e3);var r=t.easing;void 0===r&&(r=G);var o=t.events,a=t.instance,s=new U(e,a).to(n,i).easing(G);o&&(s._events=o),t.start=s.start.bind(s)}void 0===Object.assign&&(Object.assign=function(t){for(var e=[],n=arguments.length-1;n-- >0;)e[n]=arguments[n+1];return e.map(function(e){for(var n in e)t[n]=e[n]}),t});var o="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof t?t:{},a=["webkit","moz","ms","o"],s="AnimationFrame",u="Request"+s,f="Cancel"+s,c="CancelRequest"+s,h=o.setTimeout,p=o.clearTimeout;if(h&&void 0===o.requestAnimationFrame){var l,v,d=Date.now(),y=50/3,m=y;a.map(function(t){void 0===(l=o[t+u])&&(l=function(t){return h(function(){v=Date.now(),t(v-d),m=y+(Date.now()-v)},m)})}),void 0!==l&&(o.requestAnimationFrame=l)}if(p&&void 0===o.cancelAnimationFrame&&void 0===(o.cancelAnimationFrame=o.cancelRequestAnimationFrame)){var _;a.map(function(t){void 0===(_=o[t+f])&&void 0===(_=o[t+c])&&(_=function(t){return p(t)})}),void 0!==_&&(o.cancelAnimationFrame=_)}void 0===Array.isArray&&(Array.isArray=function(t){return void 0!==t&&"object"==typeof t&&t.length&&void 0!==t.push&&void 0!==t.splice});var g,b=[],w=!1,T=!1,M={},j="undefined"!=typeof window?window:"undefined"!=typeof global?global:{},I=function(){return b},F=function(t){T=t},O=function(){b=[]},A=function(t,e,n,i,r,o){var a=this,s=M[t];if(s)for(var u=s.length;u--;)s[u].call(a,e,n,i,r,o)},P=function(t,e){if(void 0!==t&&void 0!==M[t])if(void 0!==e)for(var n=M[name],i=0;i<n.length;)n[i]===e&&n.splice(i,1),i++;else M[name]=[]},E=function(t){b.push(t),T&&!w&&(N(),w=!0,A("start")),A("add",t,b)},C=function(t,e){void 0===M[t]&&(M[t]=[]),M[t].push(e)},S=function(t,e){void 0===M[t]&&(M[t]=[]),C(t,function(){for(var n=[],i=arguments.length;i--;)n[i]=arguments[i];e.apply(void 0,n),P(t)})},k=function(t){b.filter(function(e){return e!==t});for(var e,n=0;n<b.length;)e=b[n],e===t&&(A("remove",t,b),b.splice(n,1)),n++},D=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!==j.performance&&void 0!==j.performance.now)return j.performance.now.bind(j.performance);var t=j.performance&&j.performance.timing&&j.performance.timing.navigationStart?j.performance.timing.navigationStart:Date.now();return function(){return Date.now()-t}}(),N=function(t,e){if(t=void 0!==t?t:D(),T&&(g=requestAnimationFrame(N)),A("update",t,b),0===b.length)return w=!1,cancelAnimationFrame(g),A("stop",t),!1;for(var n=0;n<b.length;)b[n].update(t)||e?n++:b.splice(n,1);return!0};if(j.document){var x=j.document,q=0,B=0;x.addEventListener("visibilitychange",function(t){return 0!==b.length&&(document.hidden?B=D():(q=D()-B,b.map(function(t){return t._startTime+=q})),!0)})}var L={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*(-Math.pow(2,-10*(t-1))+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(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,t<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?.5*(t*t*((e+1)*t-e)):.5*((t-=2)*t*((e+1)*t+e)+2)}},Bounce:{In:function(t){return 1-L.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*L.Bounce.In(2*t):.5*L.Bounce.Out(2*t-1)+.5}}},R={Linear:function(t,e){var n=t.length-1,i=n*e,r=Math.floor(i),o=R.Utils.Linear;return e<0?o(t[0],t[1],i):e>1?o(t[n],t[n-1],n-i):o(t[r],t[r+1>n?n:r+1],i-r)},Bezier:function(t,e){for(var n=0,i=t.length-1,r=Math.pow,o=R.Utils.Bernstein,a=0;a<=i;a++)n+=r(1-e,i-a)*r(e,a)*t[a]*o(i,a);return n},CatmullRom:function(t,e){var n=t.length-1,i=n*e,r=Math.floor(i),o=R.Utils.CatmullRom;return t[0]===t[n]?(e<0&&(r=Math.floor(i=n*(1+e))),o(t[(r-1+n)%n],t[r],t[(r+1)%n],t[(r+2)%n],i-r)):e<0?t[0]-(o(t[0],t[0],t[1],t[1],-i)-t[0]):e>1?t[n]-(o(t[n],t[n],t[n-1],t[n-1],i-n)-t[n]):o(t[r?r-1:0],t[r],t[n<r+1?n:r+1],t[n<r+2?n:r+2],i-r)},Utils:{Linear:function(t,e,n){return(e-t)*n+t},Bernstein:function(t,e){var n=R.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),a=.5*(i-e),s=r*r,u=r*s;return(2*e-2*n+o+a)*u+(-3*e+3*n-2*o-a)*s+o*r+e}}},z=/\s+|([A-Za-z?().,{}:""\[\]#]+)|([-+\/*%]+=)?([-+*\/%]+)?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/gi,U=function t(e,n){return void 0===e&&(e={}),this.object=e,this._valuesStart=t.createEmptyConst(e),this._valuesEnd=t.createEmptyConst(e),this._duration=1e3,this._easingFunction=L.Linear.None,this._interpolationFunction=R.None,this._startTime=0,this._delayTime=0,this._repeat=0,this._r=null,this._isPlaying=!1,this._yoyo=!1,this._reversed=null,this._onStartCallbackFired=!1,this._pausedTime=null,n&&n.to?new t(e).to(n.to,n):this};U.createEmptyConst=function(t){return"number"==typeof t?0:Array.isArray(t)?[]:"object"==typeof t?{}:""},U.checkValidness=function(t){return void 0!==t&&null!==t&&""!==t&&NaN!==t&&t!==1/0},U.prototype.isPlaying=function(){return this._isPlaying},U.prototype.isStarted=function(){return this._onStartCallbackFired},U.prototype.reverse=function(){var t=this,e=t._reversed;return this._reversed=!e,this},U.prototype.reversed=function(){return this._reversed},U.prototype.off=function(t,e){if(!this._events||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},U.prototype.on=function(t,e){return this._events&&void 0!==this._events[t]||(this._events||(this._events={}),this._events[t]=[]),this._events[t].push(e),this},U.prototype.once=function(t,e){var n=this;return this._events&&void 0!==this._events[t]||(this._events||(this._events={}),this._events[t]=[]),this.on(t,function(){for(var i=[],r=arguments.length;r--;)i[r]=arguments[r];e.call.apply(e,[n].concat(i)),n.off(t)})},U.prototype.emit=function(t,e,n,i,r,o){var a=this,s=this,u=s._events;if(!u)return this;var f=u[t];if(!f)return this;for(var c=f.length;c--;)f[c].call(a,e,n,i,r,o);return this},U.prototype.pause=function(){return this._isPlaying?(this._isPlaying=!1,k(this),this._pausedTime=D(),this.emit("pause",this.object)):this},U.prototype.play=function(){return this._isPlaying?this:(this._isPlaying=!0,this._startTime+=D()-this._pausedTime,E(this),this._pausedTime=D(),this.emit("play",this.object))},U.prototype.restart=function(t){return this._repeat=this._r,this._startTime=D()+(t?0:this._delayTime),this._isPlaying||E(this),this.emit("restart",this._object)},U.prototype.seek=function(t,e){return this._startTime=D()+Math.max(0,Math.min(t,this._duration)),this.emit("seek",t,this._object),e?this:this.pause()},U.prototype.duration=function(t){return this._duration="function"==typeof t?t(this._duration):t,this},U.prototype.to=function(t,e){var n=this;if(void 0===t&&(t={}),void 0===e&&(e=1e3),"number"==typeof t){var i={Number:t};this._valuesEnd=i}else this._valuesEnd=t;if("number"==typeof e)this._duration="function"==typeof e?e(this._duration):e;else if("object"==typeof e)for(var r in e)n[r]&&n[r]("function"==typeof e[r]?e[r](n._duration):e);return this},U.prototype.start=function(t){var n=this,r=this,o=r._startTime,a=r._delayTime,s=r._valuesEnd,u=(r._valuesStart,r.object);o=void 0!==t?t:D(),o+=a,this._startTime=o;for(var f in s){if("object"==typeof s[f])if(Array.isArray(s[f]))if("number"==typeof u[f])n._valuesEnd[f]=[u[f]].concat(s[f]);else{var c=e(n,{object:u[f],_valuesEnd:s[f],_events:void 0}).start().stop();n._valuesEnd[f]=c}else{var h=e(n,{object:u[f],_valuesEnd:s[f],_events:void 0}).start().stop();n._valuesStart[f]=1,n._valuesEnd[f]=h}else if("string"==typeof s[f]&&"string"==typeof u[f]&&z.test(u[f])&&z.test(s[f])){var p=u[f].match(z);p=p.map(i);var l=s[f].match(z);l=l.map(i);var v=e(n,{object:p,_valuesEnd:l,_events:{}}).start().stop();v.join=!0,n._valuesStart[f]=1,n._valuesEnd[f]=v}"function"==typeof u[f]&&(u[f]=n.object[f]=u[f](n)),"function"==typeof s[f]&&(n._valuesEnd[f]=s[f](n)),U.checkValidness(u[f])!==!1&&u[f]!==s[f]&&(n._valuesStart[f]=u[f])}return E(this),this._isPlaying=!0,this},U.prototype.stop=function(){var t=this,e=t._isPlaying,n=t.object;return e?(k(this),this._isPlaying=!1,this.stopChainedTweens(),this.emit("stop",n)):this},U.prototype.end=function(){var t=this,e=t._startTime,n=t._duration;return this.update(e+n)},U.prototype.stopChainedTweens=function(){var t=this,e=t._chainedTweens;return void 0===e&&(e=[]),e.map(function(t){return t.stop()}),this},U.prototype.delay=function(t){return this._delayTime="function"==typeof t?t(this._delayTime):t,this},U.prototype.repeat=function(t){return this._repeat="function"==typeof t?t(this._repeat):t,this._r=this._repeat,this},U.prototype.repeatDelay=function(t){return this._repeatDelayTime="function"==typeof t?t(this._repeatDelayTime):t,this},U.prototype.reverseDelay=function(t){return this._reverseDelayTime="function"==typeof t?t(this._reverseDelayTime):t,this},U.prototype.yoyo=function(t){return this._yoyo="function"==typeof t?t(this._yoyo):t,this},U.prototype.easing=function(t){return this._easingFunction=t,this},U.prototype.interpolation=function(t){return this._interpolationFunction=t,this},U.prototype.chain=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return this._chainedTweens=t,this},U.prototype.get=function(t){return this.update(t),this.object},U.prototype.update=function(t){var e,i,r,o=this,a=this,s=a._onStartCallbackFired,u=a._chainedTweens,f=a._easingFunction,c=a._interpolationFunction,h=a._repeat,p=a._repeatDelayTime,l=a._reverseDelayTime,v=(a._delayTime,a._yoyo),d=a._reversed,y=a._startTime,m=a._duration,_=a._valuesStart,g=a._valuesEnd,b=a.object;if(t=void 0!==t?t:D(),t<y)return!0;s||(this.emit("start",b),this._onStartCallbackFired=!0),i=(t-y)/m,i=i>1?1:i,i=d?1-i:i,r=f(i);for(e in g)if(void 0!==_[e]){var w=_[e],T=g[e];if(T instanceof U){var M=T.get(t);T.join?b[e]=n(M):b[e]=M}else Array.isArray(T)?b[e]=c(T,r):"string"==typeof T?(T="+"===T.charAt(0)||"-"===T.charAt(0)?w+parseFloat(T):parseFloat(T),"number"==typeof T&&(b[e]=w+(T-w)*r)):"number"==typeof T&&(b[e]=w+(T-w)*r)}if(this.emit("update",b,r,i),1===i||d&&0===i){if(h){isFinite(h)&&this._repeat--;for(e in g)"string"==typeof g[e]&&"number"==typeof _[e]&&(o._valuesStart[e]=_[e]+parseFloat(g[e]));return this.emit(d?"reverse":"repeat",b),v&&(this._reversed=!d),!d&&p?this._startTime+=m+p:d&&l?this._startTime+=m+l:this._startTime+=m,!0}return this.emit("complete",b),u&&u.map(function(t){return t.start(y+m)}),!1}return!0};var X={filter:{grayscale:1,brightness:1,sepia:1,invert:1,saturate:1,contrast:1,blur:1,hueRotate:1,dropShadow:1},transform:{translate:1,translateX:1,translateY:1,translateZ:1,rotate:1,rotateX:1,rotateY:1,rotateZ:1,scale:1,scaleX:1,scaleY:1,scaleZ:1,skew:1,skewX:1,skewY:1}},Y=function(){};Y.DOM=function(t){var e=t.domNode,n=e.style;return{update:function(t,e){for(var i in e)n[i]=e[i]}}},Y.Transform=function(t){var e=t.domNode,n=e.style;return{update:function(t,e){var i="";for(var r in e)"x"===r||"y"===r||"z"===r?i+=" translate3d( "+(e.x||"0px")+", "+(e.y||"0px")+", "+(e.z||"0px")+")":X.transform[r]&&(i+=" "+r+"( "+e[r]+")");i&&(n.transform=i)}}},Y.Filter=function(t){var e=t.domNode,n=e.style;return{update:function(t,e){var i="";for(var r in e)X.filter[r]&&(i+=" "+r+"( "+e[r]+")");i&&(n.webkitFilter=n.filter=i)}}},Y.Scroll=function(t){var e=t.domNode;return{update:function(t,n){for(var i in n)e[i]=n[i]}}};var Z=function(t){this.domNode=t,this.plugins={};var e=this.plugins;return this.render=function(t){var n=this;for(var i in e)e[i]&&e[i].update&&e[i].update(n,t);return this},this.fetch=function(){var t=this;if(Object.keys(this.object).length)return this;for(var n in e)e[n]&&e[n].fetch&&e[n].fetch(t);return this},this.init=function(t){var n=this;for(var i in e)e[i]&&e[i].init&&e[i].init(n,t);return this},this},Q={object:{}};Z.prototype.applyPlugin=function(t){return void 0!==Y[t]&&(this.plugins[t]=Y[t](this)),this},Q.object.set=function(t){return this.render(t)},Z.prototype.cloneLayer=function(){return e(this,{},Z)},Z.prototype.appendTo=function(t){return t.appendChild(this.domNode),this},Object.defineProperties(Z.prototype,Q);var V=function(){return this._private={tweens:[],fullTime:0},this};V.prototype.add=function(t){var e=this;if(t instanceof U)this._private.tweens.push(t);else if(Array.isArray(t)||"object"!=typeof t)"object"==typeof t&&t.map(function(t){e.add(t)});else{var n=new U({x:0});for(var i in t)n[i](t[i]);this.add(n)}return this},V.prototype.start=function(){var t=this;return this._private.tweens.map(function(e){e.start(t._private.fullTime)}),this._private.fullTime=Math.max.apply(0,this._private.tweens.reduce(function(t,e){return e._duration>t?e._duration:t},0)),this};var G=function(t){return t};t.TweenInit=r,t.getAll=I,t.removeAll=O,t.remove=k,t.add=E,t.now=D,t.update=N,t.autoPlay=F,t.on=C,t.once=S,t.off=P,t.emit=A,t.Tween=U,t.Easing=L,t.Interpolation=R,t.Composite=Z,t.Timeline=V,t.Plugins=Y,Object.defineProperty(t,"__esModule",{value:!0})}); |
{ | ||
"standard": { | ||
"ignore": [ | ||
"/dist/", | ||
"/test/" | ||
] | ||
}, | ||
"name": "es6-tween", | ||
"version": "2.2.5", | ||
"version": "2.2.6", | ||
"description": "ES6 implementation of amazing tween.js", | ||
"jsdelivr": "dist/Tween.min.js", | ||
"browser": "dist/Tween.min.js", | ||
@@ -15,8 +20,8 @@ "cdn": "dist/Tween.min.js", | ||
"source": "rollup -c --sourcemap", | ||
"prepublishOnly": "npm run source && npm run build", | ||
"bundle": "npm run source && npm run build", | ||
"dev": "rollup -c -w --sourcemap", | ||
"test": "npm run test-unit && npm run test-correctness && npm run test-style", | ||
"test": "npm run test-unit && npm run lint", | ||
"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", | ||
"fix": "standard --fix", | ||
"lint": "standard --verbose | snazzy", | ||
"semantic-release": "semantic-release pre && npm publish && semantic-release post --owner=sole --user=dalisoft" | ||
@@ -47,2 +52,3 @@ }, | ||
"devDependencies": { | ||
"nodeunit": "^0.9.1", | ||
"rollup": "^0.41.6", | ||
@@ -53,8 +59,7 @@ "rollup-plugin-buble": "^0.15.0", | ||
"semantic-release": "latest", | ||
"uglify-js-harmony": "^2.7.7", | ||
"jscs": "^2.2.0", | ||
"jshint": "^2.8.0", | ||
"nodeunit": "^0.9.1" | ||
"snazzy": "^7.0.0", | ||
"standard": "^10.0.2", | ||
"uglify-js-harmony": "^2.7.7" | ||
}, | ||
"dependencies": {} | ||
} |
@@ -36,5 +36,6 @@ # es6-tween | ||
* See [cdnjs-hosted version](cdnjs.com/libraries/es6-tween) for get which result you want | ||
* NOTE: `@latest` suffix sometimes saves life by loading latest, because sometimes CDN services will not load the latest | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/es6-tween@latest/dist/Tween.min.js" defer></script> | ||
<script src="https://cdn.jsdelivr.net/npm/es6-tween@latest" defer></script> | ||
<!-- or may you want --> | ||
@@ -41,0 +42,0 @@ <script src="https://unpkg.com/es6-tween@latest" defer></script> |
@@ -1,18 +0,18 @@ | ||
import buble from 'rollup-plugin-buble'; | ||
import uglify from 'rollup-plugin-uglify'; | ||
import { minify } from 'uglify-js-harmony'; | ||
import buble from 'rollup-plugin-buble' | ||
import uglify from 'rollup-plugin-uglify' | ||
import { minify } from 'uglify-js-harmony' | ||
const { BUILD } = process.env; | ||
const { BUILD } = process.env | ||
const plugins = [ buble() ]; | ||
const plugins = [ buble() ] | ||
let moduleName = 'Tween'; | ||
let destFile = 'dist/' + moduleName; | ||
let moduleName = 'Tween' | ||
let destFile = 'dist/' + moduleName | ||
if ( BUILD === 'prod' ) { | ||
plugins.push(uglify({}, minify)); | ||
destFile = 'dist/' + moduleName + '.min'; | ||
if (BUILD === 'prod') { | ||
plugins.push(uglify({}, minify)) | ||
destFile = 'dist/' + moduleName + '.min' | ||
} | ||
destFile = destFile + '.js'; | ||
destFile = destFile + '.js' | ||
@@ -25,2 +25,2 @@ export default { | ||
plugins: plugins | ||
} | ||
} |
@@ -5,3 +5,3 @@ const Easing = { | ||
None( k ) { | ||
None(k) { | ||
@@ -16,3 +16,3 @@ return k; | ||
In( k ) { | ||
In(k) { | ||
@@ -23,15 +23,15 @@ return k * k; | ||
Out( k ) { | ||
Out(k) { | ||
return k * ( 2 - k ); | ||
return k * (2 - k); | ||
}, | ||
InOut( k ) { | ||
InOut(k) { | ||
if ( ( k *= 2 ) < 1 ) { | ||
if ((k *= 2) < 1) { | ||
return 0.5 * k * k; | ||
} | ||
return -0.5 * ( --k * ( k - 2 ) - 1 ); | ||
return - 0.5 * (--k * (k - 2) - 1); | ||
@@ -44,3 +44,3 @@ } | ||
In( k ) { | ||
In(k) { | ||
@@ -51,3 +51,3 @@ return k * k * k; | ||
Out( k ) { | ||
Out(k) { | ||
@@ -58,9 +58,9 @@ return --k * k * k + 1; | ||
InOut( k ) { | ||
InOut(k) { | ||
if ( ( k *= 2 ) < 1 ) { | ||
if ((k *= 2) < 1) { | ||
return 0.5 * k * k * k; | ||
} | ||
return 0.5 * ( ( k -= 2 ) * k * k + 2 ); | ||
return 0.5 * ((k -= 2) * k * k + 2); | ||
@@ -73,3 +73,3 @@ } | ||
In( k ) { | ||
In(k) { | ||
@@ -80,15 +80,15 @@ return k * k * k * k; | ||
Out( k ) { | ||
Out(k) { | ||
return 1 - ( --k * k * k * k ); | ||
return 1 - (--k * k * k * k); | ||
}, | ||
InOut( k ) { | ||
InOut(k) { | ||
if ( ( k *= 2 ) < 1 ) { | ||
if ((k *= 2) < 1) { | ||
return 0.5 * k * k * k * k; | ||
} | ||
return -0.5 * ( ( k -= 2 ) * k * k * k - 2 ); | ||
return - 0.5 * ((k -= 2) * k * k * k - 2); | ||
@@ -101,3 +101,3 @@ } | ||
In( k ) { | ||
In(k) { | ||
@@ -108,3 +108,3 @@ return k * k * k * k * k; | ||
Out( k ) { | ||
Out(k) { | ||
@@ -115,9 +115,9 @@ return --k * k * k * k * k + 1; | ||
InOut( k ) { | ||
InOut(k) { | ||
if ( ( k *= 2 ) < 1 ) { | ||
if ((k *= 2) < 1) { | ||
return 0.5 * k * k * k * k * k; | ||
} | ||
return 0.5 * ( ( k -= 2 ) * k * k * k * k + 2 ); | ||
return 0.5 * ((k -= 2) * k * k * k * k + 2); | ||
@@ -130,17 +130,17 @@ } | ||
In( k ) { | ||
In(k) { | ||
return 1 - Math.cos( k * Math.PI / 2 ); | ||
return 1 - Math.cos(k * Math.PI / 2); | ||
}, | ||
Out( k ) { | ||
Out(k) { | ||
return Math.sin( k * Math.PI / 2 ); | ||
return Math.sin(k * Math.PI / 2); | ||
}, | ||
InOut( k ) { | ||
InOut(k) { | ||
return 0.5 * ( 1 - Math.cos( Math.PI * k ) ); | ||
return 0.5 * (1 - Math.cos(Math.PI * k)); | ||
@@ -153,29 +153,29 @@ } | ||
In( k ) { | ||
In(k) { | ||
return k === 0 ? 0 : Math.pow( 1024, ( k - 1 ) ); | ||
return k === 0 ? 0 : Math.pow(1024, k - 1); | ||
}, | ||
Out( k ) { | ||
Out(k) { | ||
return k === 1 ? 1 : 1 - Math.pow( -10 * k, 2 ); | ||
return k === 1 ? 1 : 1 - Math.pow(2, - 10 * k); | ||
}, | ||
InOut( k ) { | ||
InOut(k) { | ||
if ( k === 0 ) { | ||
if (k === 0) { | ||
return 0; | ||
} | ||
if ( k === 1 ) { | ||
if (k === 1) { | ||
return 1; | ||
} | ||
if ( ( k *= 2 ) < 1 ) { | ||
return 0.5 * Math.pow( 1024, ( k - 1 ) ); | ||
if ((k *= 2) < 1) { | ||
return 0.5 * Math.pow(1024, k - 1); | ||
} | ||
return 0.5 * ( -Math.pow( -10 * ( k - 1 ), 2 ) + 2 ); | ||
return 0.5 * (- Math.pow(2, - 10 * (k - 1)) + 2); | ||
@@ -188,21 +188,21 @@ } | ||
In( k ) { | ||
In(k) { | ||
return 1 - Math.sqrt( 1 - k * k ); | ||
return 1 - Math.sqrt(1 - k * k); | ||
}, | ||
Out( k ) { | ||
Out(k) { | ||
return Math.sqrt( 1 - ( --k * k ) ); | ||
return Math.sqrt(1 - (--k * k)); | ||
}, | ||
InOut( k ) { | ||
InOut(k) { | ||
if ( ( k *= 2 ) < 1 ) { | ||
return -0.5 * ( Math.sqrt( 1 - k * k ) - 1 ); | ||
if ((k *= 2) < 1) { | ||
return - 0.5 * (Math.sqrt(1 - k * k) - 1); | ||
} | ||
return 0.5 * ( Math.sqrt( 1 - ( k -= 2 ) * k ) + 1 ); | ||
return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1); | ||
@@ -215,37 +215,37 @@ } | ||
In( k ) { | ||
In(k) { | ||
if ( k === 0 ) { | ||
if (k === 0) { | ||
return 0; | ||
} | ||
if ( k === 1 ) { | ||
if (k === 1) { | ||
return 1; | ||
} | ||
return -Math.pow( ( 10 * ( k - 1 ) ), 2 ) * Math.sin( ( k - 1.1 ) * 5 * Math.PI ); | ||
return -Math.pow(2, 10 * (k - 1)) * Math.sin((k - 1.1) * 5 * Math.PI); | ||
}, | ||
Out( k ) { | ||
Out(k) { | ||
if ( k === 0 ) { | ||
if (k === 0) { | ||
return 0; | ||
} | ||
if ( k === 1 ) { | ||
if (k === 1) { | ||
return 1; | ||
} | ||
return Math.pow( -10 * k, 2 ) * Math.sin( ( k - 0.1 ) * 5 * Math.PI ) + 1; | ||
return Math.pow(2, -10 * k) * Math.sin((k - 0.1) * 5 * Math.PI) + 1; | ||
}, | ||
InOut( k ) { | ||
InOut(k) { | ||
if ( k === 0 ) { | ||
if (k === 0) { | ||
return 0; | ||
} | ||
if ( k === 1 ) { | ||
if (k === 1) { | ||
return 1; | ||
@@ -256,7 +256,7 @@ } | ||
if ( k < 1 ) { | ||
return -0.5 * Math.pow( ( 10 * ( k - 1 ) ), 2 ) * Math.sin( ( k - 1.1 ) * 5 * Math.PI ); | ||
if (k < 1) { | ||
return -0.5 * Math.pow(2, 10 * (k - 1)) * 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 0.5 * Math.pow(2, -10 * (k - 1)) * Math.sin((k - 1.1) * 5 * Math.PI) + 1; | ||
@@ -269,27 +269,27 @@ } | ||
In( k ) { | ||
In(k) { | ||
const s = 1.70158; | ||
let s = 1.70158; | ||
return k * k * ( ( s + 1 ) * k - s ); | ||
return k * k * ((s + 1) * k - s); | ||
}, | ||
Out( k ) { | ||
Out(k) { | ||
const s = 1.70158; | ||
let s = 1.70158; | ||
return --k * k * ( ( s + 1 ) * k + s ) + 1; | ||
return --k * k * ((s + 1) * k + s) + 1; | ||
}, | ||
InOut( k ) { | ||
InOut(k) { | ||
const s = 1.70158 * 1.525; | ||
let s = 1.70158 * 1.525; | ||
if ( ( k *= 2 ) < 1 ) { | ||
return 0.5 * ( k * k * ( ( s + 1 ) * k - s ) ); | ||
if ((k *= 2) < 1) { | ||
return 0.5 * (k * k * ((s + 1) * k - s)); | ||
} | ||
return 0.5 * ( ( k -= 2 ) * k * ( ( s + 1 ) * k + s ) + 2 ); | ||
return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2); | ||
@@ -302,18 +302,18 @@ } | ||
In( k ) { | ||
In(k) { | ||
return 1 - Easing.Bounce.Out( 1 - k ); | ||
return 1 - Easing.Bounce.Out(1 - k); | ||
}, | ||
Out( k ) { | ||
Out(k) { | ||
if ( k < ( 1 / 2.75 ) ) { | ||
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 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; | ||
return 7.5625 * (k -= (2.625 / 2.75)) * k + 0.984375; | ||
} | ||
@@ -323,318 +323,16 @@ | ||
InOut( k ) { | ||
InOut(k) { | ||
if ( k < 0.5 ) { | ||
return Easing.Bounce.In( k * 2 ) * 0.5; | ||
if (k < 0.5) { | ||
return Easing.Bounce.In(k * 2) * 0.5; | ||
} | ||
return Easing.Bounce.Out( k * 2 - 1 ) * 0.5 + 0.5; | ||
return Easing.Bounce.Out(k * 2 - 1) * 0.5 + 0.5; | ||
} | ||
}, | ||
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 ); | ||
} | ||
}, | ||
// Credits: | ||
// @michaelvillar for dynamics.js easing/physics | ||
// Adapted by @dalisoft | ||
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; |
const Interpolation = { | ||
Linear( v, k ) { | ||
Linear(v, k) { | ||
const m = v.length - 1; | ||
const f = m * k; | ||
const i = Math.floor( f ); | ||
const fn = Interpolation.Utils.Linear; | ||
let m = v.length - 1; | ||
let f = m * k; | ||
let i = Math.floor(f); | ||
let 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 ); | ||
return fn(v[i], v[i + 1 > m ? m : i + 1], f - i); | ||
}, | ||
Bezier( v, k ) { | ||
Bezier(v, k) { | ||
let b = 0; | ||
const n = v.length - 1; | ||
const pw = Math.pow; | ||
const bn = Interpolation.Utils.Bernstein; | ||
let n = v.length - 1; | ||
let pw = Math.pow; | ||
let bn = Interpolation.Utils.Bernstein; | ||
for ( let i = 0; i <= n; i++ ) { | ||
b += pw( 1 - k, n - i ) * pw( k, i ) * v[ i ] * bn( n, i ); | ||
for (let i = 0; i <= n; i++) { | ||
b += pw(1 - k, n - i) * pw(k, i) * v[i] * bn(n, i); | ||
} | ||
@@ -37,28 +37,28 @@ | ||
CatmullRom( v, k ) { | ||
CatmullRom(v, k) { | ||
const m = v.length - 1; | ||
let m = v.length - 1; | ||
let f = m * k; | ||
let i = Math.floor( f ); | ||
const fn = Interpolation.Utils.CatmullRom; | ||
let i = Math.floor(f); | ||
let 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 ); | ||
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); | ||
@@ -71,19 +71,19 @@ } | ||
Linear( p0, p1, t ) { | ||
Linear(p0, p1, t) { | ||
return ( p1 - p0 ) * t + p0; | ||
return (p1 - p0) * t + p0; | ||
}, | ||
Bernstein( n, i ) { | ||
Bernstein(n, i) { | ||
const fc = Interpolation.Utils.Factorial; | ||
let fc = Interpolation.Utils.Factorial; | ||
return fc( n ) / fc( i ) / fc( n - i ); | ||
return fc(n) / fc(i) / fc(n - i); | ||
}, | ||
Factorial: ( ( () => { | ||
Factorial: (function() { | ||
const a = [ 1 ]; | ||
let a = [1]; | ||
@@ -94,11 +94,11 @@ return n => { | ||
if ( a[ n ] ) { | ||
return a[ n ]; | ||
if (a[n]) { | ||
return a[n]; | ||
} | ||
for ( let i = n; i > 1; i-- ) { | ||
for (let i = n; i > 1; i--) { | ||
s *= i; | ||
} | ||
a[ n ] = s; | ||
a[n] = s; | ||
return s; | ||
@@ -108,12 +108,12 @@ | ||
} ) )(), | ||
})(), | ||
CatmullRom( p0, p1, p2, p3, t ) { | ||
CatmullRom(p0, p1, p2, p3, t) { | ||
const v0 = ( p2 - p0 ) * 0.5; | ||
const v1 = ( p3 - p1 ) * 0.5; | ||
const t2 = t * t; | ||
const t3 = t * t2; | ||
let v0 = (p2 - p0) * 0.5; | ||
let v1 = (p3 - p1) * 0.5; | ||
let t2 = t * t; | ||
let 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; | ||
@@ -123,4 +123,5 @@ } | ||
} | ||
} | ||
export default Interpolation; |
@@ -1,5 +0,5 @@ | ||
if ( Array.isArray === undefined ) { | ||
Array.isArray = (arrayLike) => { | ||
return arrayLike !== undefined && typeof arrayLike === "object" && arrayLike.length && arrayLike.push !== undefined && arrayLike.splice !== undefined; | ||
} | ||
} | ||
if (Array.isArray === undefined) { | ||
Array.isArray = (arrayLike) => { | ||
return arrayLike !== undefined && typeof arrayLike === 'object' && arrayLike.length && arrayLike.push !== undefined && arrayLike.splice !== undefined | ||
} | ||
} |
@@ -1,10 +0,10 @@ | ||
if ( Object.assign === undefined ) { | ||
Object.assign = (first, ...args) => { | ||
args.map(obj => { | ||
for ( let p in obj ) { | ||
first[p] = obj[p]; | ||
} | ||
}); | ||
return first; | ||
} | ||
if (Object.assign === undefined) { | ||
Object.assign = (first, ...args) => { | ||
args.map(obj => { | ||
for (let p in obj) { | ||
first[p] = obj[p] | ||
} | ||
}) | ||
return first | ||
} | ||
} |
@@ -1,45 +0,48 @@ | ||
let ROOT = typeof(window) !== "undefined" ? window : typeof(global) !== "undefined" ? global : new Function('return this')(); | ||
let _vendor = ['webkit', 'moz', 'ms', 'o']; | ||
let animFrame = 'AnimationFrame'; | ||
let rafSuffixForVendor = 'Request' + animFrame; | ||
let cafSuffixForVendor = 'Cancel' + animFrame; | ||
let cafSuffixForVendor2 = 'CancelRequest' + animFrame; | ||
let _timeout = ROOT.setTimeout; | ||
let _clearTimeout = ROOT.clearTimeout; | ||
let ROOT = typeof (window) !== 'undefined' ? window : typeof (global) !== 'undefined' ? global : typeof exports !== 'undefined' ? exports : {} | ||
let _vendor = ['webkit', 'moz', 'ms', 'o'] | ||
let animFrame = 'AnimationFrame' | ||
let rafSuffixForVendor = 'Request' + animFrame | ||
let cafSuffixForVendor = 'Cancel' + animFrame | ||
let cafSuffixForVendor2 = 'CancelRequest' + animFrame | ||
let _timeout = ROOT.setTimeout | ||
let _clearTimeout = ROOT.clearTimeout | ||
if ( _timeout && ROOT.requestAnimationFrame === undefined ) { | ||
if (_timeout && ROOT.requestAnimationFrame === undefined) { | ||
let _raf | ||
let now | ||
let lastTime = Date.now() | ||
let frameMs = (50 / 3) | ||
let fpsSec = frameMs | ||
let _raf, now, lastTime = Date.now(), frameMs = (50 / 3), fpsSec = frameMs; | ||
_vendor.map(vendor => { | ||
if ((_raf = ROOT[vendor + rafSuffixForVendor]) === undefined) { | ||
_raf = (fn) => { | ||
return _timeout(() => { | ||
now = Date.now() | ||
fn(now - lastTime) | ||
fpsSec = frameMs + (Date.now() - now) | ||
}, fpsSec) | ||
} | ||
} | ||
}) | ||
_vendor.map(vendor => { | ||
if ((_raf = ROOT[vendor + rafSuffixForVendor]) === undefined) { | ||
_raf = (fn) => { | ||
return _timeout(() => { | ||
now = Date.now(); | ||
fn(now - lastTime); | ||
fpsSec = frameMs + (Date.now() - now); | ||
}, fpsSec); | ||
} | ||
} | ||
}); | ||
if (_raf !== undefined) { | ||
ROOT.requestAnimationFrame = _raf; | ||
} | ||
if (_raf !== undefined) { | ||
ROOT.requestAnimationFrame = _raf | ||
} | ||
} | ||
if ( _clearTimeout && ROOT.cancelAnimationFrame === undefined && (ROOT.cancelAnimationFrame = ROOT.cancelRequestAnimationFrame) === undefined ) { | ||
let _caf; | ||
if (_clearTimeout && ROOT.cancelAnimationFrame === undefined && (ROOT.cancelAnimationFrame = ROOT.cancelRequestAnimationFrame) === undefined) { | ||
let _caf | ||
_vendor.map(vendor => { | ||
if ((_caf = ROOT[vendor + cafSuffixForVendor]) === undefined && (_caf = ROOT[vendor + cafSuffixForVendor2]) === undefined) { | ||
_caf = (fn) => { | ||
return _clearTimeout(fn); | ||
} | ||
} | ||
}); | ||
_vendor.map(vendor => { | ||
if ((_caf = ROOT[vendor + cafSuffixForVendor]) === undefined && (_caf = ROOT[vendor + cafSuffixForVendor2]) === undefined) { | ||
_caf = (fn) => { | ||
return _clearTimeout(fn) | ||
} | ||
} | ||
}) | ||
if (_caf !== undefined) { | ||
ROOT.cancelAnimationFrame = _caf; | ||
} | ||
if (_caf !== undefined) { | ||
ROOT.cancelAnimationFrame = _caf | ||
} | ||
} |
/* Shims will be deprecated in next update, please update browser */ | ||
import './shim/object_assign'; | ||
import './shim/object_assign' | ||
import './shim/raf'; | ||
import './shim/raf' | ||
import './shim/isArray'; | ||
import './shim/isArray' | ||
import { getAll, removeAll, remove, add, now, update, autoPlay, on, once, off, emit } from './dist/core'; | ||
import { getAll, removeAll, remove, add, now, update, autoPlay, on, once, off, emit } from './dist/core' | ||
import Easing from './dist/Easing'; | ||
import Easing from './dist/Easing' | ||
import Tween from './dist/Tween'; | ||
import Tween from './dist/Tween' | ||
import Interpolation from './dist/Interpolation'; | ||
import Interpolation from './dist/Interpolation' | ||
import Composite from './dist/Composite'; | ||
import Composite from './dist/Composite' | ||
import Timeline from './dist/Timeline'; | ||
import Timeline from './dist/Timeline' | ||
import Plugins from './dist/Plugins'; | ||
import Plugins from './dist/Plugins' | ||
import { TweenInit } from './dist/Decorators'; | ||
import { TweenInit } from './dist/Decorators' | ||
export { TweenInit, getAll, removeAll, remove, add, now, update, autoPlay, on, once, off, emit, Tween, Easing, Interpolation, Composite, Timeline, Plugins }; | ||
export { TweenInit, getAll, removeAll, remove, add, now, update, autoPlay, on, once, off, emit, Tween, Easing, Interpolation, Composite, Timeline, Plugins } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
190
273591
27
2260