es6-tween
Advanced tools
Comparing version 2.2.7 to 2.2.8
@@ -282,3 +282,3 @@ (function (global, factory) { | ||
tween._startTime += timeDiff; | ||
_tweens[tween]._startTime += timeDiff; | ||
@@ -731,18 +731,2 @@ } | ||
function cloneTween(obj, configs, Constructor_Ex) { | ||
if ( obj === void 0 ) obj = {}; | ||
if ( configs === void 0 ) configs = {}; | ||
if ( Constructor_Ex === void 0 ) Constructor_Ex = Tween; | ||
var copyTween = new Constructor_Ex(); | ||
for ( var config in obj ) { | ||
if (configs[config] !== undefined) { | ||
copyTween[config] = configs[config]; | ||
} else { | ||
copyTween[config] = obj[config]; | ||
} | ||
} | ||
return copyTween; | ||
} | ||
function joinToString (__array__like) { | ||
@@ -761,2 +745,53 @@ var str = ''; | ||
var SubTween = function (start, end, roundv) { | ||
if ( roundv === void 0 ) roundv = 100000; | ||
if (Array.isArray(start)) { | ||
end = end.map(function (v, i) { return v === start[i] ? null : typeof v === "number" ? v - start[i] : typeof v === "string" ? v : SubTween(start[i], v); }); | ||
var map = [].concat( start ); | ||
return function (t) { | ||
for ( var i = 0, length = end.length; i < length; i++ ) { | ||
var v = end[i]; | ||
if ( typeof v === "function" ) { | ||
map[i] = v(t); | ||
} else if (typeof v === "number") { | ||
map[i] = (((start[i] + v * t) * roundv) | 0) / roundv; | ||
} | ||
} | ||
return map; | ||
} | ||
} else if (typeof start === "object") { | ||
for ( var property in end ) { | ||
if (end[property] === start[property]) { | ||
end[property] = null; | ||
} else if ( typeof end[property] === "object" ) { | ||
end[property] = SubTween(start[property], end[property]); | ||
} else if (typeof start[property] === "number") { | ||
end[property] -= start[property]; | ||
} | ||
} | ||
var map$1 = Object.assign({}, start); | ||
return function (t) { | ||
for ( var property in end ) { | ||
var to = end[property]; | ||
if ( typeof to === "function" ) { | ||
map$1[property] = to(t); | ||
} else if (typeof to === "number") { | ||
map$1[property] = (((start[property] + to * t) * roundv) | 0) / roundv; | ||
} | ||
} | ||
return map$1; | ||
} | ||
} else if (typeof start === "number") { | ||
end -= start; | ||
var isSame = start === end; | ||
return function (t) { | ||
return isSame ? end : (((start + end * t) * roundv) | 0) / roundv; | ||
} | ||
} else { | ||
var isSame$1 = start === end; | ||
return function (t) { return isSame$1 ? start : t >= 0.5 ? end : start; }; | ||
} | ||
}; | ||
// Credits: | ||
@@ -768,5 +803,7 @@ // @jkroso for string parse library | ||
var Tween = function Tween(object, instate) { | ||
if ( object === void 0 ) object = {}; | ||
if ( object === void 0 ) object = {}; | ||
this.isJoinToString = typeof object === "string" && Number_Match_RegEx.test(object); | ||
object = this.isJoinToString ? object.match(Number_Match_RegEx).map(toNumber) : object; | ||
this.object = object; | ||
@@ -962,3 +999,3 @@ this._valuesStart = Tween.createEmptyConst(object); | ||
} else { | ||
this._valuesEnd = properties; | ||
this._valuesEnd = this.isJoinToString ? SubTween(this.object, properties.match(Number_Match_RegEx).map(toNumber)) : properties; | ||
} | ||
@@ -995,31 +1032,10 @@ | ||
if (typeof _valuesEnd === "object") { | ||
for (var property in _valuesEnd) { | ||
if (typeof _valuesEnd[property] === "object") { | ||
if (Array.isArray(_valuesEnd[property])) { | ||
if (typeof object[property] === "number") { | ||
this$1._valuesEnd[property] = [object[property]].concat(_valuesEnd[property]); | ||
} else { | ||
var clonedTween = cloneTween(this$1, { | ||
object: object[property], | ||
_valuesEnd: _valuesEnd[property], | ||
_events: undefined | ||
}) | ||
.start() | ||
.stop(); | ||
if (typeof _valuesEnd[property] === "object" && _valuesEnd[property]) { | ||
this$1._valuesEnd[property] = clonedTween; | ||
} | ||
} else { | ||
var clonedTween$1 = cloneTween(this$1, { | ||
object: object[property], | ||
_valuesEnd: _valuesEnd[property], | ||
_events: undefined | ||
}) | ||
.start() | ||
.stop(); | ||
this$1._valuesEnd[property] = SubTween(object[property], _valuesEnd[property]); | ||
this$1._valuesStart[property] = 1; | ||
this$1._valuesEnd[property] = clonedTween$1; | ||
} | ||
} else if (typeof _valuesEnd[property] === "string" && typeof object[property] === "string" && Number_Match_RegEx.test(object[property]) && Number_Match_RegEx.test(_valuesEnd[property])) { | ||
@@ -1031,26 +1047,8 @@ | ||
_get__End = _get__End.map(toNumber); | ||
var clonedTween$2 = cloneTween(this$1, { | ||
object: _get__Start, | ||
_valuesEnd: _get__End, | ||
_events: {} | ||
}) | ||
.start() | ||
.stop(); | ||
clonedTween$2.join = true; // For string tweening | ||
this$1._valuesStart[property] = 1; | ||
this$1._valuesEnd[property] = clonedTween$2; | ||
this$1._valuesEnd[property] = SubTween(_get__Start, _get__End); | ||
this$1._valuesEnd[property].join = true; | ||
} | ||
// If value presented as function, | ||
// we should convert to value again by passing function | ||
if (typeof object[property] === "function") { | ||
object[property] = this$1.object[property] = object[property](this$1); | ||
} | ||
if (typeof _valuesEnd[property] === "function") { | ||
this$1._valuesEnd[property] = _valuesEnd[property](this$1); | ||
} | ||
// If `to()` specifies a property that doesn't exist in the source object, | ||
@@ -1072,2 +1070,4 @@ // we should not set that property in the object | ||
} | ||
add(this); | ||
@@ -1178,2 +1178,3 @@ | ||
var object = ref.object; | ||
var isJoinToString = ref.isJoinToString; | ||
@@ -1203,2 +1204,16 @@ var property; | ||
if (typeof _valuesEnd === "function") { | ||
var get$$1 = _valuesEnd(value); | ||
if (isJoinToString) { | ||
get$$1 = joinToString(get$$1); | ||
} | ||
object = get$$1; | ||
} else { | ||
for (property in _valuesEnd) { | ||
@@ -1214,16 +1229,14 @@ | ||
if (end instanceof Tween) { | ||
if (typeof end === "function") { | ||
var getValue = end.get(time); | ||
var get$1 = end(value); | ||
if (end.join) { | ||
if (end.join) { | ||
object[property] = joinToString(getValue); | ||
get$1 = joinToString(get$1); | ||
} else { | ||
} | ||
object[property] = getValue; | ||
object[property] = get$1; | ||
} | ||
} else if (Array.isArray(end)) { | ||
@@ -1245,3 +1258,3 @@ | ||
} | ||
} else if (typeof(end) === 'number') { | ||
} else if (typeof(start) === 'number') { | ||
object[property] = start + (end - start) * value; | ||
@@ -1252,2 +1265,4 @@ } | ||
} | ||
this.emit('update', object, value, elapsed); | ||
@@ -1456,5 +1471,2 @@ | ||
}; | ||
Composite.prototype.cloneLayer = function cloneLayer () { | ||
return cloneTween(this, {}, Composite) | ||
}; | ||
Composite.prototype.appendTo = function appendTo (node) { | ||
@@ -1461,0 +1473,0 @@ node.appendChild(this.domNode); |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.TWEEN=t.TWEEN||{})}(this,function(t){"use strict";function e(t,e,n){void 0===t&&(t={}),void 0===e&&(e={}),void 0===n&&(n=Q);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=K);var o=t.events,a=t.instance,s=new Q(e,a).to(n,i).easing(K);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=0;Object.defineProperty(b,"length",{enumerable:!1,writable:!0,value:0});var O=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)},F=function(t,e){void 0===M[t]&&(M[t]=[]),M[t].push(e)},A=function(t,e){void 0===M[t]&&(M[t]=[]),F(t,function(){for(var n=[],i=arguments.length;i--;)n[i]=arguments[i];e.apply(void 0,n),E(t)})},E=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]=[]},P=function(t){var e=t.id;b[e]=t,b.length++,T&&!w&&(L(),w=!0,O("start")),O("add",t,b)},S=function(){var t=I;return I++,t},C=function(){return b},N=function(t){T=t},k=function(){b={},Object.defineProperty(b,"length",{enumerable:!1,writable:!0,value:0})},D=function(t){for(var e in b)if(t.id===+e)return b[+e];return null},x=function(t){return null!==D(t)},q=function(t){for(var e in b)t.id===+e&&(delete b[+e],b.length--)},B=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}}(),L=function(t,e){if(t=void 0!==t?t:B(),T&&(g=requestAnimationFrame(L)),O("update",t,b),0===b.length)return w=!1,cancelAnimationFrame(g),O("stop",t),!1;for(var n in b)b[n].update(t)||e?n++:(delete b[+n],b.length--);return!0};if(j.document){var R=j.document,z=0,U=0;R.addEventListener("visibilitychange",function(t){if(0===b.length)return!1;if(document.hidden)U=B();else{z=B()-U;for(var e in b)e._startTime+=z}return!0})}var X={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-X.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*X.Bounce.In(2*t):.5*X.Bounce.Out(2*t-1)+.5}}},Y={Linear:function(t,e){var n=t.length-1,i=n*e,r=Math.floor(i),o=Y.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=Y.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=Y.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=Y.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,Q=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=X.Linear.None,this._interpolationFunction=Y.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,this.id=S(),n&&n.to?new t(e).to(n.to,n):this};Q.createEmptyConst=function(t){return"number"==typeof t?0:Array.isArray(t)?[]:"object"==typeof t?{}:""},Q.checkValidness=function(t){return void 0!==t&&null!==t&&""!==t&&NaN!==t&&t!==1/0},Q.prototype.isPlaying=function(){return this._isPlaying},Q.prototype.isStarted=function(){return this._onStartCallbackFired},Q.prototype.reverse=function(){var t=this,e=t._reversed;return this._reversed=!e,this},Q.prototype.reversed=function(){return this._reversed},Q.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},Q.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},Q.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)})},Q.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},Q.prototype.pause=function(){return this._isPlaying?(this._isPlaying=!1,q(this),this._pausedTime=B(),this.emit("pause",this.object)):this},Q.prototype.play=function(){return this._isPlaying?this:(this._isPlaying=!0,this._startTime+=B()-this._pausedTime,P(this),this._pausedTime=B(),this.emit("play",this.object))},Q.prototype.restart=function(t){return this._repeat=this._r,this._startTime=B()+(t?0:this._delayTime),this._isPlaying||P(this),this.emit("restart",this._object)},Q.prototype.seek=function(t,e){return this._startTime=B()+Math.max(0,Math.min(t,this._duration)),this.emit("seek",t,this._object),e?this:this.pause()},Q.prototype.duration=function(t){return this._duration="function"==typeof t?t(this._duration):t,this},Q.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},Q.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:B(),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)),Q.checkValidness(u[f])!==!1&&u[f]!==s[f]&&(n._valuesStart[f]=u[f])}return P(this),this._isPlaying=!0,this},Q.prototype.stop=function(){var t=this,e=t._isPlaying,n=t.object;return e?(q(this),this._isPlaying=!1,this.emit("stop",n)):this},Q.prototype.end=function(){var t=this,e=t._startTime,n=t._duration;return this.update(e+n)},Q.prototype.delay=function(t){return this._delayTime="function"==typeof t?t(this._delayTime):t,this},Q.prototype.repeat=function(t){return this._repeat="function"==typeof t?t(this._repeat):t,this._r=this._repeat,this},Q.prototype.repeatDelay=function(t){return this._repeatDelayTime="function"==typeof t?t(this._repeatDelayTime):t,this},Q.prototype.reverseDelay=function(t){return this._reverseDelayTime="function"==typeof t?t(this._reverseDelayTime):t,this},Q.prototype.yoyo=function(t){return this._yoyo="function"==typeof t?t(this._yoyo):t,this},Q.prototype.easing=function(t){return this._easingFunction=t,this},Q.prototype.interpolation=function(t){return this._interpolationFunction=t,this},Q.prototype.get=function(t){return this.update(t),this.object},Q.prototype.update=function(t){var e,i,r,o=this,a=this,s=a._onStartCallbackFired,u=a._easingFunction,f=a._interpolationFunction,c=a._repeat,h=a._repeatDelayTime,p=a._reverseDelayTime,l=(a._delayTime,a._yoyo),v=a._reversed,d=a._startTime,y=a._duration,m=a._valuesStart,_=a._valuesEnd,g=a.object;if(t=void 0!==t?t:B(),t<d)return!0;s||(this.emit("start",g),this._onStartCallbackFired=!0),i=(t-d)/y,i=i>1?1:i,i=v?1-i:i,r=u(i);for(e in _)if(void 0!==m[e]){var b=m[e],w=_[e];if(w instanceof Q){var T=w.get(t);w.join?g[e]=n(T):g[e]=T}else Array.isArray(w)?g[e]=f(w,r):"string"==typeof w?(w="+"===w.charAt(0)||"-"===w.charAt(0)?b+parseFloat(w):parseFloat(w),"number"==typeof w&&(g[e]=b+(w-b)*r)):"number"==typeof w&&(g[e]=b+(w-b)*r)}if(this.emit("update",g,r,i),1===i||v&&0===i){if(c){isFinite(c)&&this._repeat--;for(e in _)"string"==typeof _[e]&&"number"==typeof m[e]&&(o._valuesStart[e]=m[e]+parseFloat(_[e]));return this.emit(v?"reverse":"repeat",g),l&&(this._reversed=!v),!v&&h?this._startTime+=y+h:v&&p?this._startTime+=y+p:this._startTime+=y,!0}return this.emit("complete",g),!1}return!0};var V={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 e=t.domNode,n=e.style;return{update:function(t,e){for(var i in e)n[i]=e[i]}}},W.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")+")":V.transform[r]&&(i+=" "+r+"( "+e[r]+")");i&&(n.transform=i)}}},W.Filter=function(t){var e=t.domNode,n=e.style;return{update:function(t,e){var i="";for(var r in e)V.filter[r]&&(i+=" "+r+"( "+e[r]+")");i&&(n.webkitFilter=n.filter=i)}}},W.Scroll=function(t){var e=t.domNode;return{update:function(t,n){for(var i in n)e[i]=n[i]}}};var G=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},H={object:{}};G.prototype.applyPlugin=function(t){return void 0!==W[t]&&(this.plugins[t]=W[t](this)),this},H.object.set=function(t){return this.render(t)},G.prototype.cloneLayer=function(){return e(this,{},G)},G.prototype.appendTo=function(t){return t.appendChild(this.domNode),this},Object.defineProperties(G.prototype,H);var J=function(){return this._private={tweens:[],fullTime:0},this};J.prototype.add=function(t){var e=this;if(t instanceof Q)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 Q({x:0});for(var i in t)n[i](t[i]);this.add(n)}return this},J.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 K=function(t){return t};t.TweenInit=r,t.has=x,t.get=D,t.getAll=C,t.removeAll=k,t.remove=q,t.add=P,t.now=B,t.update=L,t.autoPlay=N,t.on=F,t.once=A,t.off=E,t.emit=O,t.Tween=Q,t.Easing=X,t.Interpolation=Y,t.Composite=G,t.Timeline=J,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){for(var e="",n=0,i=t.length;n<i;n++)e+=t[n];return e}function n(t){var e=parseFloat(t);return"number"!=typeof e||isNaN(e)?t:e}function i(t){var e=t.from,n=t.to,i=t.duration;void 0===i&&(i=1e3);var r=t.easing;void 0===r&&(r=K);var o=t.events,a=t.instance,u=new Z(e,a).to(n,i).easing(K);o&&(u._events=o),t.start=u.start.bind(u)}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 r="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof t?t:{},o=["webkit","moz","ms","o"],a="AnimationFrame",u="Request"+a,s="Cancel"+a,f="CancelRequest"+a,c=r.setTimeout,h=r.clearTimeout;if(c&&void 0===r.requestAnimationFrame){var p,l,v=Date.now(),d=50/3,y=d;o.map(function(t){void 0===(p=r[t+u])&&(p=function(t){return c(function(){l=Date.now(),t(l-v),y=d+(Date.now()-l)},y)})}),void 0!==p&&(r.requestAnimationFrame=p)}if(h&&void 0===r.cancelAnimationFrame&&void 0===(r.cancelAnimationFrame=r.cancelRequestAnimationFrame)){var m;o.map(function(t){void 0===(m=r[t+s])&&void 0===(m=r[t+f])&&(m=function(t){return h(t)})}),void 0!==m&&(r.cancelAnimationFrame=m)}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=!1,T=!1,w={},M="undefined"!=typeof window?window:"undefined"!=typeof global?global:{},j=0;Object.defineProperty(g,"length",{enumerable:!1,writable:!0,value:0});var O=function(t,e,n,i,r,o){var a=this,u=w[t];if(u)for(var s=u.length;s--;)u[s].call(a,e,n,i,r,o)},I=function(t,e){void 0===w[t]&&(w[t]=[]),w[t].push(e)},F=function(t,e){void 0===w[t]&&(w[t]=[]),I(t,function(){for(var n=[],i=arguments.length;i--;)n[i]=arguments[i];e.apply(void 0,n),A(t)})},A=function(t,e){if(void 0!==t&&void 0!==w[t])if(void 0!==e)for(var n=w[name],i=0;i<n.length;)n[i]===e&&n.splice(i,1),i++;else w[name]=[]},P=function(t){var e=t.id;g[e]=t,g.length++,T&&!b&&(B(),b=!0,O("start")),O("add",t,g)},E=function(){var t=j;return j++,t},S=function(){return g},C=function(t){T=t},N=function(){g={},Object.defineProperty(g,"length",{enumerable:!1,writable:!0,value:0})},k=function(t){for(var e in g)if(t.id===+e)return g[+e];return null},D=function(t){return null!==k(t)},x=function(t){for(var e in g)t.id===+e&&(delete g[+e],g.length--)},q=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!==M.performance&&void 0!==M.performance.now)return M.performance.now.bind(M.performance);var t=M.performance&&M.performance.timing&&M.performance.timing.navigationStart?M.performance.timing.navigationStart:Date.now();return function(){return Date.now()-t}}(),B=function(t,e){if(t=void 0!==t?t:q(),T&&(_=requestAnimationFrame(B)),O("update",t,g),0===g.length)return b=!1,cancelAnimationFrame(_),O("stop",t),!1;for(var n in g)g[n].update(t)||e?n++:(delete g[+n],g.length--);return!0};if(M.document){var R=M.document,L=0,z=0;R.addEventListener("visibilitychange",function(t){if(0===g.length)return!1;if(document.hidden)z=q();else{L=q()-z;for(var e in g)g[e]._startTime+=L}return!0})}var U={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-U.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*U.Bounce.In(2*t):.5*U.Bounce.Out(2*t-1)+.5}}},J={Linear:function(t,e){var n=t.length-1,i=n*e,r=Math.floor(i),o=J.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=J.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=J.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=J.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),u=r*r,s=r*u;return(2*e-2*n+o+a)*s+(-3*e+3*n-2*o-a)*u+o*r+e}}},X=function(t,e,n){if(void 0===n&&(n=1e5),Array.isArray(t)){e=e.map(function(e,n){return e===t[n]?null:"number"==typeof e?e-t[n]:"string"==typeof e?e:X(t[n],e)});var i=[].concat(t);return function(r){for(var o=0,a=e.length;o<a;o++){var u=e[o];"function"==typeof u?i[o]=u(r):"number"==typeof u&&(i[o]=((t[o]+u*r)*n|0)/n)}return i}}if("object"==typeof t){for(var r in e)e[r]===t[r]?e[r]=null:"object"==typeof e[r]?e[r]=X(t[r],e[r]):"number"==typeof t[r]&&(e[r]-=t[r]);var o=Object.assign({},t);return function(i){for(var r in e){var a=e[r];"function"==typeof a?o[r]=a(i):"number"==typeof a&&(o[r]=((t[r]+a*i)*n|0)/n)}return o}}if("number"==typeof t){e-=t;var a=t===e;return function(i){return a?e:((t+e*i)*n|0)/n}}var u=t===e;return function(n){return u?t:n>=.5?e:t}},Y=/\s+|([A-Za-z?().,{}:""\[\]#]+)|([-+\/*%]+=)?([-+*\/%]+)?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/gi,Z=function t(e,i){return void 0===e&&(e={}),this.isJoinToString="string"==typeof e&&Y.test(e),e=this.isJoinToString?e.match(Y).map(n):e,this.object=e,this._valuesStart=t.createEmptyConst(e),this._valuesEnd=t.createEmptyConst(e),this._duration=1e3,this._easingFunction=U.Linear.None,this._interpolationFunction=J.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,this.id=E(),i&&i.to?new t(e).to(i.to,i):this};Z.createEmptyConst=function(t){return"number"==typeof t?0:Array.isArray(t)?[]:"object"==typeof t?{}:""},Z.checkValidness=function(t){return void 0!==t&&null!==t&&""!==t&&NaN!==t&&t!==1/0},Z.prototype.isPlaying=function(){return this._isPlaying},Z.prototype.isStarted=function(){return this._onStartCallbackFired},Z.prototype.reverse=function(){var t=this,e=t._reversed;return this._reversed=!e,this},Z.prototype.reversed=function(){return this._reversed},Z.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},Z.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},Z.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)})},Z.prototype.emit=function(t,e,n,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,e,n,i,r,o);return this},Z.prototype.pause=function(){return this._isPlaying?(this._isPlaying=!1,x(this),this._pausedTime=q(),this.emit("pause",this.object)):this},Z.prototype.play=function(){return this._isPlaying?this:(this._isPlaying=!0,this._startTime+=q()-this._pausedTime,P(this),this._pausedTime=q(),this.emit("play",this.object))},Z.prototype.restart=function(t){return this._repeat=this._r,this._startTime=q()+(t?0:this._delayTime),this._isPlaying||P(this),this.emit("restart",this._object)},Z.prototype.seek=function(t,e){return this._startTime=q()+Math.max(0,Math.min(t,this._duration)),this.emit("seek",t,this._object),e?this:this.pause()},Z.prototype.duration=function(t){return this._duration="function"==typeof t?t(this._duration):t,this},Z.prototype.to=function(t,e){var i=this;if(void 0===t&&(t={}),void 0===e&&(e=1e3),"number"==typeof t){var r={Number:t};this._valuesEnd=r}else this._valuesEnd=this.isJoinToString?X(this.object,t.match(Y).map(n)):t;if("number"==typeof e)this._duration="function"==typeof e?e(this._duration):e;else if("object"==typeof e)for(var o in e)i[o]&&i[o]("function"==typeof e[o]?e[o](i._duration):e);return this},Z.prototype.start=function(t){var e=this,i=this,r=i._startTime,o=i._delayTime,a=i._valuesEnd,u=(i._valuesStart,i.object);if(r=void 0!==t?t:q(),r+=o,this._startTime=r,"object"==typeof a)for(var s in a){if("object"==typeof a[s]&&a[s])e._valuesEnd[s]=X(u[s],a[s]);else if("string"==typeof a[s]&&"string"==typeof u[s]&&Y.test(u[s])&&Y.test(a[s])){var f=u[s].match(Y);f=f.map(n);var c=a[s].match(Y);c=c.map(n),e._valuesEnd[s]=X(f,c),e._valuesEnd[s].join=!0}Z.checkValidness(u[s])!==!1&&u[s]!==a[s]&&(e._valuesStart[s]=u[s])}return P(this),this._isPlaying=!0,this},Z.prototype.stop=function(){var t=this,e=t._isPlaying,n=t.object;return e?(x(this),this._isPlaying=!1,this.emit("stop",n)):this},Z.prototype.end=function(){var t=this,e=t._startTime,n=t._duration;return this.update(e+n)},Z.prototype.delay=function(t){return this._delayTime="function"==typeof t?t(this._delayTime):t,this},Z.prototype.repeat=function(t){return this._repeat="function"==typeof t?t(this._repeat):t,this._r=this._repeat,this},Z.prototype.repeatDelay=function(t){return this._repeatDelayTime="function"==typeof t?t(this._repeatDelayTime):t,this},Z.prototype.reverseDelay=function(t){return this._reverseDelayTime="function"==typeof t?t(this._reverseDelayTime):t,this},Z.prototype.yoyo=function(t){return this._yoyo="function"==typeof t?t(this._yoyo):t,this},Z.prototype.easing=function(t){return this._easingFunction=t,this},Z.prototype.interpolation=function(t){return this._interpolationFunction=t,this},Z.prototype.get=function(t){return this.update(t),this.object},Z.prototype.update=function(t){var n,i,r,o=this,a=this,u=a._onStartCallbackFired,s=a._easingFunction,f=a._interpolationFunction,c=a._repeat,h=a._repeatDelayTime,p=a._reverseDelayTime,l=(a._delayTime,a._yoyo),v=a._reversed,d=a._startTime,y=a._duration,m=a._valuesStart,_=a._valuesEnd,g=a.object,b=a.isJoinToString;if(t=void 0!==t?t:q(),t<d)return!0;if(u||(this.emit("start",g),this._onStartCallbackFired=!0),i=(t-d)/y,i=i>1?1:i,i=v?1-i:i,r=s(i),"function"==typeof _){var T=_(r);b&&(T=e(T)),g=T}else for(n in _)if(void 0!==m[n]){var w=m[n],M=_[n];if("function"==typeof M){var j=M(r);M.join&&(j=e(j)),g[n]=j}else Array.isArray(M)?g[n]=f(M,r):"string"==typeof M?(M="+"===M.charAt(0)||"-"===M.charAt(0)?w+parseFloat(M):parseFloat(M),"number"==typeof M&&(g[n]=w+(M-w)*r)):"number"==typeof w&&(g[n]=w+(M-w)*r)}if(this.emit("update",g,r,i),1===i||v&&0===i){if(c){isFinite(c)&&this._repeat--;for(n in _)"string"==typeof _[n]&&"number"==typeof m[n]&&(o._valuesStart[n]=m[n]+parseFloat(_[n]));return this.emit(v?"reverse":"repeat",g),l&&(this._reversed=!v),!v&&h?this._startTime+=y+h:v&&p?this._startTime+=y+p:this._startTime+=y,!0}return this.emit("complete",g),!1}return!0};var Q={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}},V=function(){};V.DOM=function(t){var e=t.domNode,n=e.style;return{update:function(t,e){for(var i in e)n[i]=e[i]}}},V.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")+")":Q.transform[r]&&(i+=" "+r+"( "+e[r]+")");i&&(n.transform=i)}}},V.Filter=function(t){var e=t.domNode,n=e.style;return{update:function(t,e){var i="";for(var r in e)Q.filter[r]&&(i+=" "+r+"( "+e[r]+")");i&&(n.webkitFilter=n.filter=i)}}},V.Scroll=function(t){var e=t.domNode;return{update:function(t,n){for(var i in n)e[i]=n[i]}}};var W=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},G={object:{}};W.prototype.applyPlugin=function(t){return void 0!==V[t]&&(this.plugins[t]=V[t](this)),this},G.object.set=function(t){return this.render(t)},W.prototype.appendTo=function(t){return t.appendChild(this.domNode),this},Object.defineProperties(W.prototype,G);var H=function(){return this._private={tweens:[],fullTime:0},this};H.prototype.add=function(t){var e=this;if(t instanceof Z)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 Z({x:0});for(var i in t)n[i](t[i]);this.add(n)}return this},H.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 K=function(t){return t};t.TweenInit=i,t.has=D,t.get=k,t.getAll=S,t.removeAll=N,t.remove=x,t.add=P,t.now=q,t.update=B,t.autoPlay=C,t.on=I,t.once=F,t.off=A,t.emit=O,t.Tween=Z,t.Easing=U,t.Interpolation=J,t.Composite=W,t.Timeline=H,t.Plugins=V,Object.defineProperty(t,"__esModule",{value:!0})}); |
@@ -9,3 +9,3 @@ { | ||
"name": "es6-tween", | ||
"version": "2.2.7", | ||
"version": "2.2.8", | ||
"description": "ES6 implementation of amazing tween.js", | ||
@@ -12,0 +12,0 @@ "browser": "dist/Tween.min.js", |
@@ -35,11 +35,11 @@ # es6-tween | ||
* See [cdnjs-hosted version](cdnjs.com/libraries/es6-tween) for get which result you want | ||
* See [cdnjs-hosted version](https://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" defer></script> | ||
<script src="https://cdn.jsdelivr.net/npm/es6-tween"></script> | ||
<!-- or may you want --> | ||
<script src="https://unpkg.com/es6-tween@latest" defer></script> | ||
<script src="https://unpkg.com/es6-tween"></script> | ||
<!-- or like this --> | ||
<script src="https://npmcdn.com/es6-tween@latest" defer></script> | ||
<script src="https://npmcdn.com/es6-tween"></script> | ||
``` | ||
@@ -126,4 +126,4 @@ | ||
* Does one thing and one thing only: tween properties | ||
* Takes care of CSS units (e.g. appending `px`) | ||
* Tweens everything you give them, string (numbers only), number, number of arrays, number of object, etc... | ||
* Can use CSS units (e.g. appending `px`) | ||
* Can interpolate colours (partially) | ||
@@ -130,0 +130,0 @@ * Easing functions are reusable outside of Tween |
@@ -7,3 +7,5 @@ import buble from 'rollup-plugin-buble' | ||
const plugins = [ buble() ] | ||
const plugins = [ buble({ | ||
objectAssign: 'Object.assign' | ||
}) ] | ||
@@ -10,0 +12,0 @@ let moduleName = 'Tween' |
@@ -1,3 +0,1 @@ | ||
import cloneTween from './clone'; | ||
import Plugins from './Plugins'; | ||
@@ -64,5 +62,2 @@ | ||
} | ||
cloneLayer() { | ||
return cloneTween(this, {}, Composite) | ||
} | ||
appendTo(node) { | ||
@@ -69,0 +64,0 @@ node.appendChild(this.domNode); |
@@ -204,3 +204,3 @@ | ||
tween._startTime += timeDiff | ||
_tweens[tween]._startTime += timeDiff | ||
@@ -207,0 +207,0 @@ } |
@@ -10,5 +10,5 @@ import { | ||
import Interpolation from './Interpolation'; | ||
import cloneTween from './clone'; | ||
import joinToString from './joinToString'; | ||
import toNumber from './toNumber'; | ||
import SubTween from './SubTween'; | ||
@@ -23,2 +23,4 @@ // Credits: | ||
this.isJoinToString = typeof object === "string" && Number_Match_RegEx.test(object); | ||
object = this.isJoinToString ? object.match(Number_Match_RegEx).map(toNumber) : object; | ||
this.object = object; | ||
@@ -205,3 +207,3 @@ this._valuesStart = Tween.createEmptyConst(object); | ||
} else { | ||
this._valuesEnd = properties; | ||
this._valuesEnd = this.isJoinToString ? SubTween(this.object, properties.match(Number_Match_RegEx).map(toNumber)) : properties; | ||
} | ||
@@ -237,31 +239,10 @@ | ||
if (typeof _valuesEnd === "object") { | ||
for (let property in _valuesEnd) { | ||
if (typeof _valuesEnd[property] === "object") { | ||
if (Array.isArray(_valuesEnd[property])) { | ||
if (typeof object[property] === "number") { | ||
this._valuesEnd[property] = [object[property]].concat(_valuesEnd[property]); | ||
} else { | ||
let clonedTween = cloneTween(this, { | ||
object: object[property], | ||
_valuesEnd: _valuesEnd[property], | ||
_events: undefined | ||
}) | ||
.start() | ||
.stop(); | ||
if (typeof _valuesEnd[property] === "object" && _valuesEnd[property]) { | ||
this._valuesEnd[property] = clonedTween; | ||
} | ||
} else { | ||
let clonedTween = cloneTween(this, { | ||
object: object[property], | ||
_valuesEnd: _valuesEnd[property], | ||
_events: undefined | ||
}) | ||
.start() | ||
.stop(); | ||
this._valuesEnd[property] = SubTween(object[property], _valuesEnd[property]); | ||
this._valuesStart[property] = 1; | ||
this._valuesEnd[property] = clonedTween; | ||
} | ||
} else if (typeof _valuesEnd[property] === "string" && typeof object[property] === "string" && Number_Match_RegEx.test(object[property]) && Number_Match_RegEx.test(_valuesEnd[property])) { | ||
@@ -273,26 +254,8 @@ | ||
__get__End = __get__End.map(toNumber); | ||
let clonedTween = cloneTween(this, { | ||
object: __get__Start, | ||
_valuesEnd: __get__End, | ||
_events: {} | ||
}) | ||
.start() | ||
.stop(); | ||
clonedTween.join = true; // For string tweening | ||
this._valuesStart[property] = 1; | ||
this._valuesEnd[property] = clonedTween; | ||
this._valuesEnd[property] = SubTween(__get__Start, __get__End); | ||
this._valuesEnd[property].join = true; | ||
} | ||
// If value presented as function, | ||
// we should convert to value again by passing function | ||
if (typeof object[property] === "function") { | ||
object[property] = this.object[property] = object[property](this); | ||
} | ||
if (typeof _valuesEnd[property] === "function") { | ||
this._valuesEnd[property] = _valuesEnd[property](this); | ||
} | ||
// If `to()` specifies a property that doesn't exist in the source object, | ||
@@ -314,2 +277,4 @@ // we should not set that property in the object | ||
} | ||
add(this); | ||
@@ -419,3 +384,4 @@ | ||
_valuesEnd, | ||
object | ||
object, | ||
isJoinToString | ||
} = this; | ||
@@ -446,2 +412,16 @@ | ||
if (typeof _valuesEnd === "function") { | ||
let get = _valuesEnd(value); | ||
if (isJoinToString) { | ||
get = joinToString(get); | ||
} | ||
object = get; | ||
} else { | ||
for (property in _valuesEnd) { | ||
@@ -457,16 +437,14 @@ | ||
if (end instanceof Tween) { | ||
if (typeof end === "function") { | ||
let getValue = end.get(time); | ||
let get = end(value); | ||
if (end.join) { | ||
if (end.join) { | ||
object[property] = joinToString(getValue); | ||
get = joinToString(get); | ||
} else { | ||
} | ||
object[property] = getValue; | ||
object[property] = get; | ||
} | ||
} else if (Array.isArray(end)) { | ||
@@ -488,3 +466,3 @@ | ||
} | ||
} else if (typeof(end) === 'number') { | ||
} else if (typeof(start) === 'number') { | ||
object[property] = start + (end - start) * value; | ||
@@ -495,2 +473,4 @@ } | ||
} | ||
this.emit('update', object, value, elapsed); | ||
@@ -497,0 +477,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
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
274157
2298