es6-tween
Advanced tools
Comparing version 3.8.11 to 3.8.12
@@ -1,3 +0,3 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.TWEEN={})}(this,function(t){"use strict";var e,n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},r=function(t,e){return e={exports:{}},t(e,e.exports),e.exports}(function(t){!function(e,n){t.exports?t.exports=n():e.InterTween=n()}("undefined"!=typeof window?window:n,function(){function t(t){var e=parseFloat(t);return"number"!=typeof e||isNaN(e)?t:e}function e(t,e){var n,r,i;3===e.length&&(e=(n=e[0])+n+(r=e[1])+r+(i=e[2])+i);var o=parseInt(e,16);return n=o>>16&m,r=o>>8&m,i=o&m,"rgb("+n+","+r+","+i+")"}function n(t){return"string"==typeof t?t.replace(v,"").replace(_,","):t}function r(t,e){if("number"==typeof e)return e;var n=M[e.substr(0,2)],r=e.substr(2);if(1===n){var i=e[0]+r;return t+parseFloat(i)}return 2===n?t*+r:3===n?t/+r:4===n?t*(+r/100):e}function i(e){var n=x(e);return"string"==typeof n?n.match(d).map(t):e}function o(t,e,n,o){if(n=null!==n&&void 0!==n?n:1e4,!d.test(e))return e;var u=i(t),s=i(e),a=f(u,s,n,o);if(a)return a;a=null;for(var p=null,h=null,y=[],v=0,_=s.length;v<_;v++){var m=s[v],g=u[v];y[v]="string"==typeof m&&1===m.indexOf("=")?e:null,c.test(m)?(p=v+2,h=v+11):l.test(m)&&(p=v,h=v+9),s[v]=g===m?null:null!==y[v]?r(g,m):m}return function(t,e,i){i||(i=o),e=void 0!==e?e:t;var a="";for(v=0;v<_;v++){var f=u[v],l=s[v],c=y[v],d="function"==typeof i?i(t):t;a+="number"==typeof l?null!==p&&v>p&&v<h?f+(l-f)*d|0:((f+(l-f)*d)*n|0)/n:f,1===e&&null!==c&&(u[v]=l,s[v]=r(l,c))}return a}}function u(t,e,n,r){for(var i=[],u=0,s=t.length;u<s;u++){var f=t[u];i[u]=g(f)?a(f,e,n,r&&r[u]||r):"object"==typeof f?p(f,e,n,r&&r[u]||r):"string"==typeof f?o(f,e,n,r&&r[u]||r):f}return function(n,o,u){o=void 0!==o?o:n,u||(u=r);for(var s=0,a=i.length;s<a;s++){var f=f="function"==typeof u?u:u&&"function"==typeof u[s]?u[s]:null,p=f(n);t[s]="function"==typeof i[s]?i[s](f?n:p,o,u):"number"==typeof i[s]?i[s]+(e-i[s])*p:i[s]}return t}}function s(t,e,n,r){for(var i=[],o=0,u=e.length;o<u;o++){var s=e[o];i[o]=h(0===o?t:e[o-1],s,n,r&&r[o]||r)}var a=e[e.length-1];i.push(h(a,a,n,r&&r[e.length-1]||r));var f=i.length-1;return function(t){var e=t*f,n=Math.max(0,Math.floor(e)),r=e-n,o=i[n];return"function"==typeof o?o(r):o}}function a(t,e,n,i){n=null!==n&&void 0!==n?n:1e4,w(e),w(t);for(var f=t.slice(),h=[],l=Math.min(t.length,e.length),c=0;c<l;c++){var d=f[c],y=e[c];void 0!==d&&null!==d?(h[c]="string"==typeof y&&1===y.indexOf("=")?y:null,f[c]=y.nodeType||y.update?y.update:d===y?null:g(y)?g(d)&&y.length===d.length?a(d,y,n,i&&i[c]||i):s(d,y,n,i&&i[c]||i):g(d)?u(d,y,n,i&&i[c]||i):"object"==typeof d?p(d,y,n,i&&i[c]||i):"string"==typeof d?o(d,y,n,i&&i[c]||i):void 0!==d?d:y,e[c]=null!==h[c]?r(d,y):y):("function"==typeof y||y&&y.update)&&(f[c]=y)}return function(o,u,s){s||(s=i);for(var a=0;a<l;a++){var p=f[a],c=e[a],d=h[a];if(null!==p&&void 0!==p){var y=y="function"==typeof s?s:s&&"function"==typeof s[a]?s[a]:null,v=y?y(o):o;t[a]="number"==typeof p?((p+(c-p)*v)*n|0)/n:"function"==typeof p?p(y?o:v,u,y):p.update?p.update(v,u,y):c&&c.update?c.update(v,u,y):c,d&&1===u&&(f[a]=c,e[a]=r(f[a],d))}}return t}}function f(t,e,n,i){if(n=null!==n&&void 0!==n?n:1e4,2===e.length&&2===t.length&&-1!==I.indexOf(e[1])){var o=+t[0],u=+e[0],s=e[1],a="string"==typeof e[0]&&1===e[0].indexOf("=")?e[0]:null;return a&&(u=r(o,u)),o===u&&e[0]===s?e:function(t,e,f){f||(f=i);var p="function"==typeof f?f(t):t,h=((o+(u-o)*p)*n|0)/n+s;return a&&1===e&&(u=r(o=u,a)),h}}return!1}function p(t,e,n,i){n=null!==n&&void 0!==n?n:1e4;var f,h={},l={};w(e),w(t),w(i);for(var c in e){l[c]=t&&t[c];var d=l[c],y=e[c];if(void 0!==d&&null!==d){var v=P(t,c);h[c]="string"==typeof y&&1===y.indexOf("=")?y:null,v&&!1===v.writable&&!v.set&&(f||(f={}),f[c]=!0),l[c]=y.nodeType?y:y.update?y:d===y?null:g(y)?g(d)&&y.length===d.length?a(d,y,n,i&&i[c]||i):s(d,y,n,i&&i[c]||i):g(d)?u(d,y,n,i&&i[c]||i):"object"==typeof d?p(d,y,n,i&&i[c]||i):"string"==typeof d?o(d,y,n,i&&i[c]||i):void 0!==d?d:y,e[c]=null!==h[c]?r(d,y):y}else("function"==typeof y||y&&y.update)&&(l[c]=y)}return function(o,u,s){s||(s=i),u=void 0!==u?u:o;for(var a in l){var p=l[a],c=e[a],d=h[a],y="function"==typeof s?s:s&&"function"==typeof s[a]?s[a]:null,v=y?y(o):o,_="number"==typeof p?((p+(c-p)*v)*n|0)/n:"function"==typeof p?p(y?o:v,u,y):p&&p.update?p.update(v,u,y):c&&c.update?c.update(v,u,y):c;f&&f[a]||(t[a]=_),d&&1===u&&(l[a]=c,e[a]=r(l[a],d))}return t}}function h(t,e,n,i){w(i),n=null!==n&&void 0!==n?n:1e4;var f="string"==typeof e&&"number"==typeof t&&1===e.indexOf("=")?e:null;return f&&(e=r(t,f)),e.nodeType?e:t.nodeType?t:g(e)?g(t)&&t.length===e.length?a(t,e,n,i):s(t,e,n,i):g(t)?u(t,e,n,i):"object"==typeof e?p(t,e,n,i):"string"==typeof e?o(t,e,n,i):"function"==typeof e?e:function(o,u,s){u=void 0!==u?u:o,s||(s=i);var a="function"==typeof s?s(o):o,p="number"==typeof e?((t+(e-t)*a)*n|0)/n:t;return f&&1===u&&(e=r(t+=e,f)),p}}var l=/rgb/g,c=/argb/g,d=/\s+|([A-Za-z?().,{}:""[\]#\%]+)|([-+/*%]+=)?([-+*/%]+)?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,y=/^#([0-9a-f]{6}|[0-9a-f]{3})$/i,v=/\n|\r|\t/g,_=/, | ,| , /g,m=255,g=Array.isArray||function(t){return t instanceof Array},b=/([.\[])/g,T=/\]/g,O=function(t,e){var n=t[e],r=e.replace(T,"").split(b),i=r.length-1,o=Array.isArray(t),u="object"==typeof t&&!o;return u?(t[e]=null,delete t[e]):o&&t.splice(e,1),r.reduce(function(t,e,s){o&&"."!==e&&"["!==e&&(e*=1);var a="["===r[s+1];if("."===e||"["===e)return"."===e?(u=!0,o=!1):"["===e&&(u=!1,o=!0),t;if(void 0===t[e]){if(o||u)return t[e]=s===i?n:o||a?[]:u?{}:null,u=o=!1,t[e]}else if(void 0!==t[e])return s===i&&(t[e]=n),t[e];return t},t)},w=function(t){if("object"==typeof t&&t)for(var e in t)if(-1!==e.indexOf(".")||-1!==e.indexOf("["))O(t,e);else if("object"==typeof t[e]&&t[e]){var n=t[e];for(var r in n)if(-1!==r.indexOf(".")||-1!==r.indexOf("["))O(n,r);else if("object"==typeof n[r]&&n[r]){var i=n[r];for(var o in i)-1===o.indexOf(".")&&-1===o.indexOf("[")||O(i,o)}}return t},M={"+=":1,"-=":1,"*=":2,"/=":3,"%=":4},x=function(t){return"string"!=typeof t?t:n(t).replace(y,e)},I=["px","pt","pc","deg","rad","turn","em","ex","cm","mm","dm","inch","in","rem","vw","vh","vmin","vmax","%"],j=Object.getOwnPropertyDescriptor,P=j||function(){};return h})}),i=Object.create||function(t){return Object.assign({},t||{})},o=Object.assign||function(t){for(var e=[],n=arguments.length-1;n-- >0;)e[n]=arguments[n+1];for(var r=0,i=e.length;r<i;r++){var o=e[r];for(var u in o)t[u]=o[u]}return t},u="undefined"!=typeof window?window:"undefined"!=typeof global?global:this,s=[],a=!1,f=!1,p=u.requestAnimationFrame||function(t){return u.setTimeout(t,16)},h=u.cancelAnimationFrame||function(t){return u.clearTimeout(t)},l=function(t){s.push(t),f&&!a&&(e=p(v),a=!0)},c=function(t){for(var e=0;e<s.length;e++)if(t===s[e])return s[e];return null},d=function(t){var e=s.indexOf(t);-1!==e&&s.splice(e,1)},y=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!==u.performance&&void 0!==u.performance.now)return u.performance.now.bind(u.performance);var t=u.performance&&u.performance.timing&&u.performance.timing.navigationStart?u.performance.timing.navigationStart:Date.now();return function(){return Date.now()-t}}(),v=function(t,n){if(t=void 0!==t?t:y(),f&&a&&(e=p(v)),0===s.length)return h(e),a=!1,!1;for(var r=0;r<s.length;)s[r].update(t,n),r++;return!0},_={};if(u.document&&u.document.addEventListener){var m=0,g=0;u.document.addEventListener("visibilitychange",function(){if(document.hidden)g=y(),h(e),a=!1;else{m=y()-g;for(var t=0,n=s.length;t<n;t++)s[t]._startTime+=m;e=p(v),a=!0}return!0})}var b={Linear:{None:function(t){return t}},Quadratic:{In:function(t){return t*t},Out:function(t){return t*(2-t)},InOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}},Cubic:{In:function(t){return t*t*t},Out:function(t){return--t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}},Quartic:{In:function(t){return t*t*t*t},Out:function(t){return 1- --t*t*t*t},InOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}},Quintic:{In:function(t){return t*t*t*t*t},Out:function(t){return--t*t*t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},Sinusoidal:{In:function(t){return 1-Math.cos(t*Math.PI/2)},Out:function(t){return Math.sin(t*Math.PI/2)},InOut:function(t){return.5*(1-Math.cos(Math.PI*t))}},Exponential:{In:function(t){return 0===t?0:Math.pow(1024,t-1)},Out:function(t){return 1===t?1:1-Math.pow(2,-10*t)},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(2-Math.pow(2,-10*(t-1)))}},Circular:{In:function(t){return 1-Math.sqrt(1-t*t)},Out:function(t){return Math.sqrt(1- --t*t)},InOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},Elastic:{In:function(t){return 0===t?0:1===t?1:-Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)},Out:function(t){return 0===t?0:1===t?1:Math.pow(2,-10*t)*Math.sin(5*(t-.1)*Math.PI)+1},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?-.5*Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI):.5*Math.pow(2,-10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)+1}},Back:{In:function(t){var e=1.70158;return t*t*((e+1)*t-e)},Out:function(t){var e=1.70158;return--t*t*((e+1)*t+e)+1},InOut:function(t){var e=2.5949095;return(t*=2)<1?t*t*((e+1)*t-e)*.5:.5*((t-=2)*t*((e+1)*t+e)+2)}},Bounce:{In:function(t){return 1-b.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*b.Bounce.In(2*t):.5*b.Bounce.Out(2*t-1)+.5}}},T=function(){this.totalTime=0,this.labels=[],this.offsets=[]};T.prototype.parseLabel=function(t,e){var n=this,r=n.offsets,i=n.labels,o=i.indexOf(t);if("string"==typeof t&&-1!==t.indexOf("=")&&!e&&-1===o){var u=t.substr(t.indexOf("=")-1,2),s=t.split(u);e=2===s.length?u+s[1]:null,t=s[0],o=i.indexOf(t)}if(-1!==o&&t){var a=r[o]||0;if("number"==typeof e)a=e;else if("string"==typeof e&&-1!==e.indexOf("=")){var f=e.charAt(0);e=Number(e.substr(2)),"+"===f||"-"===f?a+=parseFloat(f+e):"*"===f?a*=e:"/"===f?a/=e:"%"===f&&(a*=e/100)}return a}return"number"==typeof e?e:0},T.prototype.addLabel=function(t,e){return this.labels.push(t),this.offsets.push(this.parseLabel(t,e)),this},T.prototype.setLabel=function(t,e){var n=this.labels.indexOf(t);return-1!==n&&this.offsets.splice(n,1,this.parseLabel(t,e)),this},T.prototype.eraseLabel=function(t){var e=this.labels.indexOf(t);return-1!==e&&(this.labels.splice(e,1),this.offsets.splice(e,1)),this};var O=function(){this._events={}};O.prototype.on=function(t,e){return this._events[t]||(this._events[t]=[]),this._events[t].push(e),this},O.prototype.once=function(t,e){var n=this;this._events[t]||(this._events[t]=[]);var r=this._events,i=r[t].length;return this._events[t].push(function(){for(var o=[],u=arguments.length;u--;)o[u]=arguments[u];e.apply(n,o),r[t].splice(i,1)}),this},O.prototype.off=function(t,e){var n=this._events;return void 0!==t&&n[t]?(e?this._events[t]=this._events[t].filter(function(t){return t!==e}):this._events[t].length=0,this):this},O.prototype.emit=function(t,e,n,r,i){var o=this._events[t];if(!o||!o.length)return this;for(var u=0,s=o.length;u<s;u++)o[u](e,n,r,i);return this};var w={},M=function(t,e){if(!t||!t.nodeType||!e)return e;var n=t.queueID||"queue_"+Math.round(1e3*Math.random()+Date.now());return t.queueID||(t.queueID=n),w[n]?(e&&(w[n]=o(w[n],e)),w[n]):(w[n]=e,w[n])};Object.create=i;var x=0,I=b.Linear.None,j=function(t){function e(e,n){return t.call(this),this.id=x++,void 0===e||n||e.nodeType?void 0!==e&&(this.node=e,"object"==typeof n?n=this.object=M(e,n):this.object=n):(n=this.object=e,e=null),this._valuesEnd=null,this._duration=1e3,this._easingFunction=I,this._easingReverse=I,this._startTime=0,this._delayTime=0,this._repeat=0,this._r=0,this._isPlaying=!1,this._yoyo=!1,this._reversed=!1,this._onStartCallbackFired=!1,this._pausedTime=null,this._isFinite=!0,this._elapsed=0,this}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.fromTo=function(t,n,r,i){void 0===i&&(i={}),i.quickRender=i.quickRender?i.quickRender:!r;var o=new e(t,n).to(r,i);return i.quickRender&&(o.render().update(o._startTime),o._rendered=!1,o._onStartCallbackFired=!1),o},e.to=function(t,n,r){return e.fromTo(t,null,n,r)},e.from=function(t,n,r){return e.fromTo(t,n,null,r)},e.prototype.isPlaying=function(){return this._isPlaying},e.prototype.isStarted=function(){return this._onStartCallbackFired},e.prototype.reverse=function(){var t=this._reversed;return this._reversed=!t,this},e.prototype.reversed=function(){return this._reversed},e.prototype.pause=function(){return this._isPlaying?(this._isPlaying=!1,d(this),this._pausedTime=y(),this.emit("pause",this.object)):this},e.prototype.play=function(){return this._isPlaying?this:(this._isPlaying=!0,this._startTime+=y()-this._pausedTime,l(this),this._pausedTime=y(),this.emit("play",this.object))},e.prototype.restart=function(t){return this._repeat=this._r,this._startTime=y()+(t?0:this._delayTime),this._isPlaying||l(this),this.emit("restart",this.object)},e.prototype.seek=function(t,e){return this._startTime=y()+Math.max(0,Math.min(t,this._duration)),this.emit("seek",t,this.object),e?this:this.pause()},e.prototype.duration=function(t){return this._duration="function"==typeof t?t(this._duration):t,this},e.prototype.to=function(t,e,n){var r=this;if(void 0===e&&(e=1e3),this._valuesEnd=t,"number"==typeof e||"function"==typeof e)this._duration="function"==typeof e?e(this._duration):e;else if("object"==typeof e)for(var i in e)if("function"==typeof r[i]){var o=Array.isArray(e[i])?e[i]:[e[i]],u=o[0];void 0===u&&(u=null);var s=o[1];void 0===s&&(s=null);var a=o[2];void 0===a&&(a=null);var f=o[3];void 0===f&&(f=null),r[i](u,s,a,f)}return this},e.prototype.render=function(){var t=this;if(this._rendered)return this;var e=this,n=e._valuesEnd,i=e.object,o=e.Renderer,u=e.node,s=e.InitialValues,a=e._easingFunction;u&&s&&(i?n||(n=this._valuesEnd=s(u,i)):i=this.object=M(u,s(u,n)));for(var f in n){var p=i&&i[f],h=n[f];if(_[f]){var l=_[f].prototype.update?new _[f](t,p,h,f,i):_[f](t,p,h,f,i);l&&(n[f]=l)}else;}return this._valuesEnd=r(i,n,null,a),o&&this.node&&(this.__render=new o(this,i,n)),this},e.prototype.start=function(t){return this._startTime=void 0!==t?t:y(),this._startTime+=this._delayTime,l(this),this._isPlaying=!0,this},e.prototype.stop=function(){var t=this,e=t._isPlaying,n=t.object,r=t._startTime,i=t._duration;return e?(this.update(r+i),d(this),this._isPlaying=!1,this.emit("stop",n)):this},e.prototype.delay=function(t){return this._delayTime="function"==typeof t?t(this._delayTime):t,this._startTime+=this._delayTime,this},e.prototype.repeat=function(t){return this._repeat="function"==typeof t?t(this._repeat):t,this._r=this._repeat,this._isFinite=isFinite(t),this},e.prototype.repeatDelay=function(t){return this._repeatDelayTime="function"==typeof t?t(this._repeatDelayTime):t,this},e.prototype.reverseDelay=function(t){return this._reverseDelayTime="function"==typeof t?t(this._reverseDelayTime):t,this},e.prototype.yoyo=function(t,e){return this._yoyo="function"==typeof t?t(this._yoyo):null===t?this._yoyo:t,this._easingReverse=e||this._easingFunction,this},e.prototype.easing=function(t){return this._easingFunction=t,this},e.prototype.reassignValues=function(){var t=this,e=t._valuesEnd,n=t.object,r=e(0);for(var i in r){var o=r[i];n[i]=o}return this},e.prototype.update=function(t,e){var n,r,i=this,o=i._onStartCallbackFired,u=i._easingFunction,s=i._easingReverse,a=i._repeat,f=i._repeatDelayTime,p=i._reverseDelayTime,h=i._yoyo,l=i._reversed,c=i._startTime,v=i._duration,_=i._valuesEnd,m=i.object,g=i._isFinite,b=i._isPlaying,T=i.__render;return t=void 0!==t?t:y(),!b||t<c||(o||(this._rendered||(this.render(),this._rendered=!0,_=this._valuesEnd),this.emit("start",m),this._onStartCallbackFired=!0),n=(t-c)/v,n=n>1?1:n,n=l?1-n:n,r=l?s:u,"function"!=typeof _||!m||(_(n,n,r),T&&T.update(m,n),this.emit("update",m,n),!(1===n||l&&0===n)||(a?(g&&this._repeat--,h&&(this._reversed=!l),this.emit(h&&!l?"reverse":"repeat",m),this._startTime=!l&&f?t+f:l&&p?t+p:t,!0):(e||(this._isPlaying=!1,d(this),x--),this.emit("complete",m),this._repeat=this._r,!1))))},e}(O),P=function(t){var e,n,r;for(r=t.length;r;r-=1)e=Math.floor(Math.random()*r),n=t[r-1],t[r-1]=t[e],t[e]=n;return t},L=0,F=function(t){function e(e){return t.call(this),this._duration=0,this._startTime=y(),this._tweens=[],this._elapsed=0,this._id=L++,this._defaultParams=e,this.position=new T,this.position.addLabel("afterLast",this._duration),this.position.addLabel("afterInit",this._startTime),this}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.mapTotal=function(t){return t.call(this,this._tweens),this},e.prototype.timingOrder=function(t){var e=t(this._tweens.map(function(t){return t._startTime}));return this._tweens.map(function(t,n){t._startTime=e[n]}),this},e.prototype.getTiming=function(t,e,n,r){if(void 0===r&&(r=0),"reverse"===t){var i=n.stagger,o=(i||0)*(e.length-1);return e.map(function(t,e){return o-(i||0)*e+r})}if("async"===t)return e.map(function(t){return r});if("sequence"===t||"delayed"===t){var u=n.stagger;return u||(u=(n.duration||1e3)/(e.length-1)),e.map(function(t,e){return u*e+r})}if("oneByOne"===t)return e.map(function(t){return n.duration});if("shuffle"===t){var s=n.stagger;return P(e.map(function(t,e){return(s||0)*e+r}))}var a=n.stagger;return e.map(function(t,e){return(a||0)*e+r})},e.prototype.fromTo=function(e,n,r,i){var o=this;if(Array.isArray(e)){this._defaultParams&&(i=Object.assign({},this._defaultParams,i));var u=i.label,s="number"==typeof u?u:this.position.parseLabel(void 0!==u?u:"afterLast",null),a=this.getTiming(i.mode,e,i,s);e.map(function(u,s){o.add(t.fromTo(u,"function"==typeof n?n(s,e.length):Object.assign({},n),"function"==typeof r?r(s,e.length):r,"function"==typeof i?i(s,e.length):i),a[s])})}return this.start()},e.prototype.from=function(t,e,n){return this.fromTo(t,e,null,n)},e.prototype.to=function(t,e,n){return this.fromTo(t,null,e,n)},e.prototype.addLabel=function(t,e){return this.position.addLabel(t,e),this},e.prototype.map=function(t){for(var e=this,n=0,r=this._tweens.length;n<r;n++){var i=e._tweens[n];t(i,n),e._duration=Math.max(e._duration,i._duration+i._startTime)}return this},e.prototype.add=function(e,n){var r=this;if(Array.isArray(e))return e.map(function(t){r.add(t,n)}),this;"object"!=typeof e||e instanceof t||(e=new t(e.from).to(e.to,e));var i=this,o=i._defaultParams,u=i._duration;if(o)for(var s in o)"function"==typeof e[s]&&e[s](o[s]);var a="number"==typeof n?n:this.position.parseLabel(void 0!==n?n:"afterLast",null);return e._startTime=Math.max(this._startTime,e._delayTime),e._startTime+=a,e._isPlaying=!0,this._duration=Math.max(u,e._startTime+e._delayTime+e._duration),this._tweens.push(e),this.position.setLabel("afterLast",this._duration),this},e.prototype.restart=function(){return this._startTime+=y(),l(this),this.emit("restart")},e.prototype.easing=function(t){return this.map(function(e){return e.easing(t)})},e.prototype.interpolation=function(t){return this.map(function(e){return e.interpolation(t)})},e.prototype.update=function(t){var e=this,n=e._tweens,r=e._duration,i=e._repeatDelayTime,o=e._reverseDelayTime,u=e._startTime,s=e._reversed,a=e._yoyo,f=e._repeat,p=e._isFinite,h=e._elapsed;if(!e._isPlaying||t<u)return!0;var l=(t-u)/r;if(l=l>1?1:l,l=s?1-l:l,(l=(1e3*l|0)/1e3)===h)return!0;this._elapsed=l;for(var c=t-u,y=s?r-c:c,v=0;v<n.length;)n[v].update(y,!0),v++;if(this.emit("update",l,c),1===l||s&&0===l){if(f){for(p&&this._repeat--,this.emit(s?"reverse":"repeat"),a&&(this._reversed=!s,this.timingOrder(function(t){return t.reverse()})),this._startTime=!s&&i?t+i:s&&o?t+o:t;v<n.length;)n[v].reassignValues(),v++;return!0}return this.emit("complete"),this._repeat=this._r,d(this),this._isPlaying=!1,!1}return!0},e.prototype.elapsed=function(t){return void 0!==t?this.update(t*this._duration):this._elapsed},e}(j);t.Plugins=_,t.Interpolator=r,t.onTick=function(t){return s.push({update:t})},t.has=function(t){return null!==c(t)},t.get=c,t.getAll=function(){return s},t.removeAll=function(){s.length=0},t.remove=d,t.add=l,t.now=y,t.update=v,t.autoPlay=function(t){f=t},t.isRunning=function(){return a},t.Tween=j,t.Easing=b,t.Timeline=F,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.TWEEN={})}(this,function(t){"use strict";var e,n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},r=function(t,e){return e={exports:{}},t(e,e.exports),e.exports}(function(t){!function(e,n){t.exports?t.exports=n():e.InterTween=n()}("undefined"!=typeof window?window:n,function(){function t(t){var e=parseFloat(t);return"number"!=typeof e||isNaN(e)?t:e}function e(t,e){var n,r,i;3===e.length&&(e=(n=e[0])+n+(r=e[1])+r+(i=e[2])+i);var o=parseInt(e,16);return n=o>>16&m,r=o>>8&m,i=o&m,"rgb("+n+","+r+","+i+")"}function n(t){return"string"==typeof t?t.replace(v,"").replace(_,","):t}function r(t,e){if("number"==typeof e)return e;var n=x[e.substr(0,2)],r=e.substr(2);if(1===n){var i=e[0]+r;return t+parseFloat(i)}return 2===n?t*+r:3===n?t/+r:4===n?t*(+r/100):e}function i(e){var n=M(e);return"string"==typeof n?n.match(d).map(t):e}function o(t,e,n,o){if(n=null!==n&&void 0!==n?n:1e4,!d.test(e))return e;var u=i(t),s=i(e),a=f(u,s,n,o);if(a)return a;a=null;for(var p=null,h=null,y=[],v=0,_=s.length;v<_;v++){var m=s[v],g=u[v];y[v]="string"==typeof m&&1===m.indexOf("=")?m:null,c.test(m)?(p=v+2,h=v+11):l.test(m)&&(p=v,h=v+9),s[v]=g===m?null:null!==y[v]?r(g,m):m}return function(t,e,i){i||(i=o),e=void 0!==e?e:t;var a="";for(v=0;v<_;v++){var f=u[v],l=s[v],c=y[v],d="function"==typeof i?i(t):t;a+="number"==typeof l?null!==p&&v>p&&v<h?f+(l-f)*d|0:((f+(l-f)*d)*n|0)/n:f,1===e&&null!==c&&(u[v]=l,s[v]=r(l,c))}return a}}function u(t,e,n,r){for(var i=[],u=0,s=t.length;u<s;u++){var f=t[u];i[u]=g(f)?a(f,e,n,r&&r[u]||r):"object"==typeof f?p(f,e,n,r&&r[u]||r):"string"==typeof f?o(f,e,n,r&&r[u]||r):f}return function(n,o,u){o=void 0!==o?o:n,u||(u=r);for(var s=0,a=i.length;s<a;s++){var f=f="function"==typeof u?u:u&&"function"==typeof u[s]?u[s]:null,p=f(n);t[s]="function"==typeof i[s]?i[s](f?n:p,o,u):"number"==typeof i[s]?i[s]+(e-i[s])*p:i[s]}return t}}function s(t,e,n,r){for(var i=[],o=0,u=e.length;o<u;o++){var s=e[o];i[o]=h(0===o?t:e[o-1],s,n,r&&r[o]||r)}var a=e[e.length-1];i.push(h(a,a,n,r&&r[e.length-1]||r));var f=i.length-1;return function(t){var e=t*f,n=Math.max(0,Math.floor(e)),r=e-n,o=i[n];return"function"==typeof o?o(r):o}}function a(t,e,n,i){n=null!==n&&void 0!==n?n:1e4,w(e),w(t);for(var f=t.slice(),h=[],l=Math.min(t.length,e.length),c=0;c<l;c++){var d=f[c],y=e[c];void 0!==d&&null!==d?(h[c]="string"==typeof y&&1===y.indexOf("=")?y:null,f[c]=y.nodeType||y.update?y.update:d===y?null:g(y)?g(d)&&y.length===d.length?a(d,y,n,i&&i[c]||i):s(d,y,n,i&&i[c]||i):g(d)?u(d,y,n,i&&i[c]||i):"object"==typeof d?p(d,y,n,i&&i[c]||i):"string"==typeof d?o(d,y,n,i&&i[c]||i):void 0!==d?d:y,e[c]=null!==h[c]?r(d,y):y):("function"==typeof y||y&&y.update)&&(f[c]=y)}return function(o,u,s){s||(s=i);for(var a=0;a<l;a++){var p=f[a],c=e[a],d=h[a];if(null!==p&&void 0!==p){var y=y="function"==typeof s?s:s&&"function"==typeof s[a]?s[a]:null,v=y?y(o):o;t[a]="number"==typeof p?((p+(c-p)*v)*n|0)/n:"function"==typeof p?p(y?o:v,u,y):p.update?p.update(v,u,y):c&&c.update?c.update(v,u,y):c,d&&1===u&&(f[a]=c,e[a]=r(f[a],d))}}return 1===u?e:t}}function f(t,e,n,i){if(n=null!==n&&void 0!==n?n:1e4,2===e.length&&2===t.length&&-1!==I.indexOf(e[1])){var o=+t[0],u=+e[0],s=e[1],a="string"==typeof e[0]&&1===e[0].indexOf("=")?e[0]:null;return a&&(u=r(o,u)),o===u&&e[0]===s?e:function(t,e,f){f||(f=i);var p="function"==typeof f?f(t):t,h=((o+(u-o)*p)*n|0)/n+s;return a&&1===e&&(u=r(o=u,a)),h}}return!1}function p(t,e,n,i){n=null!==n&&void 0!==n?n:1e4;var f,h={},l={};w(e),w(t),w(i);for(var c in e){var d=t[c],y=e[c];if(void 0!==d&&null!==d){var v=P(t,c);h[c]="string"==typeof y&&1===y.indexOf("=")?y:null,v&&!1===v.writable&&!v.set&&(f||(f={}),f[c]=!0),l[c]=y.nodeType?y:y.update?y:d===y?null:g(y)?g(d)&&y.length===d.length?a(d,y,n,i&&i[c]||i):s(d,y,n,i&&i[c]||i):g(d)?u(d,y,n,i&&i[c]||i):"object"==typeof d?p(d,y,n,i&&i[c]||i):"string"==typeof d?o(d,y,n,i&&i[c]||i):void 0!==d?d:y,e[c]=null!==h[c]?r(d,y):y}else("function"==typeof y||y&&y.update)&&(l[c]=y)}return function(o,u,s){s||(s=i),u=void 0!==u?u:o;for(var a in l){var p=l[a],c=e[a],d=h[a],y="function"==typeof s?s:s&&"function"==typeof s[a]?s[a]:null,v=y?y(o):o,_="number"==typeof p?((p+(c-p)*v)*n|0)/n:"function"==typeof p?p(y?o:v,u,y):p&&p.update?p.update(v,u,y):c&&c.update?c.update(v,u,y):c;f&&f[a]||(t[a]=_),1===u&&d&&(l[a]=c,e[a]=r(l[a],d))}return 1===u?e:t}}function h(t,e,n,i){w(i),n=null!==n&&void 0!==n?n:1e4;var f="string"==typeof e&&"number"==typeof t&&1===e.indexOf("=")?e:null;return f&&(e=r(t,f)),e.nodeType?e:t.nodeType?t:g(e)?g(t)&&t.length===e.length?a(t,e,n,i):s(t,e,n,i):g(t)?u(t,e,n,i):"object"==typeof e?p(t,e,n,i):"string"==typeof e?o(t,e,n,i):"function"==typeof e?e:function(o,u,s){u=void 0!==u?u:o,s||(s=i);var a="function"==typeof s?s(o):o,p="number"==typeof e?((t+(e-t)*a)*n|0)/n:t;return f&&1===u&&(e=r(t+=e,f)),p}}var l=/rgb/g,c=/argb/g,d=/\s+|([A-Za-z?().,{}:""[\]#\%]+)|([-+/*%]+=)?([-+*/%]+)?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,y=/^#([0-9a-f]{6}|[0-9a-f]{3})$/i,v=/\n|\r|\t/g,_=/, | ,| , /g,m=255,g=Array.isArray||function(t){return t instanceof Array},b=/([.\[])/g,T=/\]/g,O=function(t,e){var n=t[e],r=e.replace(T,"").split(b),i=r.length-1,o=Array.isArray(t),u="object"==typeof t&&!o;return u?(t[e]=null,delete t[e]):o&&t.splice(e,1),r.reduce(function(t,e,s){o&&"."!==e&&"["!==e&&(e*=1);var a="["===r[s+1];if("."===e||"["===e)return"."===e?(u=!0,o=!1):"["===e&&(u=!1,o=!0),t;if(void 0===t[e]){if(o||u)return t[e]=s===i?n:o||a?[]:u?{}:null,u=o=!1,t[e]}else if(void 0!==t[e])return s===i&&(t[e]=n),t[e];return t},t)},w=function(t){if("object"==typeof t&&t)for(var e in t)if(-1!==e.indexOf(".")||-1!==e.indexOf("["))O(t,e);else if("object"==typeof t[e]&&t[e]){var n=t[e];for(var r in n)if(-1!==r.indexOf(".")||-1!==r.indexOf("["))O(n,r);else if("object"==typeof n[r]&&n[r]){var i=n[r];for(var o in i)-1===o.indexOf(".")&&-1===o.indexOf("[")||O(i,o)}}return t},x={"+=":1,"-=":1,"*=":2,"/=":3,"%=":4},M=function(t){return"string"!=typeof t?t:n(t).replace(y,e)},I=["px","pt","pc","deg","rad","turn","em","ex","cm","mm","dm","inch","in","rem","vw","vh","vmin","vmax","%"],j=Object.getOwnPropertyDescriptor,P=j||function(){};return h})}),i=Object.create||function(t){return Object.assign({},t||{})},o=Object.assign||function(t){for(var e=[],n=arguments.length-1;n-- >0;)e[n]=arguments[n+1];for(var r=0,i=e.length;r<i;r++){var o=e[r];for(var u in o)t[u]=o[u]}return t},u="undefined"!=typeof window?window:"undefined"!=typeof global?global:this,s=[],a=!1,f=!1,p=u.requestAnimationFrame||function(t){return u.setTimeout(t,16)},h=u.cancelAnimationFrame||function(t){return u.clearTimeout(t)},l=function(t){s.push(t),f&&!a&&(e=p(g),a=!0)},c=function(t){for(var e=0;e<s.length;e++)if(t===s[e])return s[e];return null},d=function(t){var e=s.indexOf(t);-1!==e&&s.splice(e,1)},y=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!==u.performance&&void 0!==u.performance.now)return u.performance.now.bind(u.performance);var t=u.performance&&u.performance.timing&&u.performance.timing.navigationStart?u.performance.timing.navigationStart:Date.now();return function(){return Date.now()-t}}(),v=y(),_=0,m=0,g=function(t,n){if(t=void 0!==t?t:y(),(_=t-v)>150&&(m+=_-50/3),v=t,f&&a&&(e=p(g)),0===s.length)return h(e),a=!1,!1;for(var r=0;r<s.length;)s[r].update(t-m,n),r++;return!0},b=function(){return m},T={},O={Linear:{None:function(t){return t}},Quadratic:{In:function(t){return t*t},Out:function(t){return t*(2-t)},InOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}},Cubic:{In:function(t){return t*t*t},Out:function(t){return--t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}},Quartic:{In:function(t){return t*t*t*t},Out:function(t){return 1- --t*t*t*t},InOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}},Quintic:{In:function(t){return t*t*t*t*t},Out:function(t){return--t*t*t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},Sinusoidal:{In:function(t){return 1-Math.cos(t*Math.PI/2)},Out:function(t){return Math.sin(t*Math.PI/2)},InOut:function(t){return.5*(1-Math.cos(Math.PI*t))}},Exponential:{In:function(t){return 0===t?0:Math.pow(1024,t-1)},Out:function(t){return 1===t?1:1-Math.pow(2,-10*t)},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(2-Math.pow(2,-10*(t-1)))}},Circular:{In:function(t){return 1-Math.sqrt(1-t*t)},Out:function(t){return Math.sqrt(1- --t*t)},InOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},Elastic:{In:function(t){return 0===t?0:1===t?1:-Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)},Out:function(t){return 0===t?0:1===t?1:Math.pow(2,-10*t)*Math.sin(5*(t-.1)*Math.PI)+1},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?-.5*Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI):.5*Math.pow(2,-10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)+1}},Back:{In:function(t){var e=1.70158;return t*t*((e+1)*t-e)},Out:function(t){var e=1.70158;return--t*t*((e+1)*t+e)+1},InOut:function(t){var e=2.5949095;return(t*=2)<1?t*t*((e+1)*t-e)*.5:.5*((t-=2)*t*((e+1)*t+e)+2)}},Bounce:{In:function(t){return 1-O.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*O.Bounce.In(2*t):.5*O.Bounce.Out(2*t-1)+.5}}},w=function(){this.totalTime=0,this.labels=[],this.offsets=[]};w.prototype.parseLabel=function(t,e){var n=this,r=n.offsets,i=n.labels,o=i.indexOf(t);if("string"==typeof t&&-1!==t.indexOf("=")&&!e&&-1===o){var u=t.substr(t.indexOf("=")-1,2),s=t.split(u);e=2===s.length?u+s[1]:null,t=s[0],o=i.indexOf(t)}if(-1!==o&&t){var a=r[o]||0;if("number"==typeof e)a=e;else if("string"==typeof e&&-1!==e.indexOf("=")){var f=e.charAt(0);e=Number(e.substr(2)),"+"===f||"-"===f?a+=parseFloat(f+e):"*"===f?a*=e:"/"===f?a/=e:"%"===f&&(a*=e/100)}return a}return"number"==typeof e?e:0},w.prototype.addLabel=function(t,e){return this.labels.push(t),this.offsets.push(this.parseLabel(t,e)),this},w.prototype.setLabel=function(t,e){var n=this.labels.indexOf(t);return-1!==n&&this.offsets.splice(n,1,this.parseLabel(t,e)),this},w.prototype.eraseLabel=function(t){var e=this.labels.indexOf(t);return-1!==e&&(this.labels.splice(e,1),this.offsets.splice(e,1)),this};var x=function(){this._events={}};x.prototype.on=function(t,e){return this._events[t]||(this._events[t]=[]),this._events[t].push(e),this},x.prototype.once=function(t,e){var n=this;this._events[t]||(this._events[t]=[]);var r=this._events,i=r[t].length;return this._events[t].push(function(){for(var o=[],u=arguments.length;u--;)o[u]=arguments[u];e.apply(n,o),r[t].splice(i,1)}),this},x.prototype.off=function(t,e){var n=this._events;return void 0!==t&&n[t]?(e?this._events[t]=this._events[t].filter(function(t){return t!==e}):this._events[t].length=0,this):this},x.prototype.emit=function(t,e,n,r,i){var o=this._events[t];if(!o||!o.length)return this;for(var u=0,s=o.length;u<s;u++)o[u](e,n,r,i);return this};var M={},I=function(t,e){if(!t||!t.nodeType||!e)return e;var n=t.queueID||"q_"+Date.now();return t.queueID||(t.queueID=n),M[n]?(e&&(M[n]=o(M[n],e)),M[n]):(M[n]=e,M[n])};Object.create=i;var j=0,P=O.Linear.None,F=function(t){function e(e,n){return t.call(this),this.id=j++,void 0===e||n||e.nodeType?void 0!==e&&(this.node=e,"object"==typeof n?n=this.object=I(e,n):this.object=n):(n=this.object=e,e=null),this._valuesEnd=null,this._valuesFunc=null,this._duration=1e3,this._easingFunction=P,this._easingReverse=P,this._startTime=0,this._delayTime=0,this._repeat=0,this._r=0,this._isPlaying=!1,this._yoyo=!1,this._reversed=!1,this._onStartCallbackFired=!1,this._pausedTime=null,this._isFinite=!0,this._elapsed=0,this}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.fromTo=function(t,n,r,i){void 0===i&&(i={}),i.quickRender=i.quickRender?i.quickRender:!r;var o=new e(t,n).to(r,i);return i.quickRender&&(o.render().update(o._startTime),o._rendered=!1,o._onStartCallbackFired=!1),o},e.to=function(t,n,r){return e.fromTo(t,null,n,r)},e.from=function(t,n,r){return e.fromTo(t,n,null,r)},e.prototype.isPlaying=function(){return this._isPlaying},e.prototype.isStarted=function(){return this._onStartCallbackFired},e.prototype.reverse=function(){var t=this._reversed;return this._reversed=!t,this},e.prototype.reversed=function(){return this._reversed},e.prototype.pause=function(){return this._isPlaying?(this._isPlaying=!1,d(this),this._pausedTime=y()-b(),this.emit("pause",this.object)):this},e.prototype.play=function(){return this._isPlaying?this:(this._isPlaying=!0,this._startTime+=y()-b()-this._pausedTime,l(this),this._pausedTime=y()-b(),this.emit("play",this.object))},e.prototype.restart=function(t){return this._repeat=this._r,this._startTime=y()-b()+(t?0:this._delayTime),this._isPlaying||l(this),this.emit("restart",this.object)},e.prototype.seek=function(t,e){return this._startTime=y()-b()+Math.max(0,Math.min(t,this._duration)),this.emit("seek",t,this.object),e?this:this.pause()},e.prototype.duration=function(t){return this._duration="function"==typeof t?t(this._duration):t,this},e.prototype.to=function(t,e,n){var r=this;if(void 0===e&&(e=1e3),this._valuesEnd=t,"number"==typeof e||"function"==typeof e)this._duration="function"==typeof e?e(this._duration):e;else if("object"==typeof e)for(var i in e)if("function"==typeof r[i]){var o=Array.isArray(e[i])?e[i]:[e[i]],u=o[0];void 0===u&&(u=null);var s=o[1];void 0===s&&(s=null);var a=o[2];void 0===a&&(a=null);var f=o[3];void 0===f&&(f=null),r[i](u,s,a,f)}return this},e.prototype.render=function(){var t=this;if(this._rendered)return this;var e=this,n=e._valuesEnd,i=e.object,o=e.Renderer,u=e.node,s=e.InitialValues,a=e._easingFunction;u&&s&&(i?n||(n=this._valuesEnd=s(u,i)):i=this.object=I(u,s(u,n)));for(var f in n){var p=i&&i[f],h=n[f];if(T[f]){var l=T[f].prototype.update?new T[f](t,p,h,f,i):T[f](t,p,h,f,i);l&&(n[f]=l)}else;}return this._valuesFunc=r(i,n,null,a),o&&this.node&&(this.__render=new o(this,i,n)),this},e.prototype.start=function(t){return this._startTime=void 0!==t?t:y()-b(),this._startTime+=this._delayTime,this._onStartCallbackFired=!1,this._rendered=!1,this._isPlaying=!0,l(this),this},e.prototype.stop=function(){var t=this,e=t._isPlaying,n=t.object,r=t._startTime,i=t._duration;return e?(this.update(r+i),this._isPlaying=!1,d(this),this.emit("stop",n)):this},e.prototype.delay=function(t){return this._delayTime="function"==typeof t?t(this._delayTime):t,this},e.prototype.repeat=function(t){return this._repeat="function"==typeof t?t(this._repeat):t,this._r=this._repeat,this._isFinite=isFinite(t),this},e.prototype.repeatDelay=function(t){return this._repeatDelayTime="function"==typeof t?t(this._repeatDelayTime):t,this},e.prototype.reverseDelay=function(t){return this._reverseDelayTime="function"==typeof t?t(this._reverseDelayTime):t,this},e.prototype.yoyo=function(t,e){return this._yoyo="function"==typeof t?t(this._yoyo):null===t?this._yoyo:t,this._easingReverse=e||this._easingFunction,this},e.prototype.easing=function(t){return this._easingFunction=t,this},e.prototype.reassignValues=function(t){var e=this,n=e._valuesFunc,r=e.object,i=e._delayTime;this._isPlaying=!0,this._startTime=void 0!==t?t:y()-b(),this._startTime+=i,l(this);var o=n(0);for(var u in o){var s=o[u];r[u]=s}return this},e.prototype.update=function(t,e){var n,r,i=this,o=i._onStartCallbackFired,u=i._easingFunction,s=i._easingReverse,a=i._repeat,f=i._repeatDelayTime,p=i._reverseDelayTime,h=i._yoyo,l=i._reversed,c=i._startTime,v=i._duration,_=i._valuesFunc,m=i.object,g=i._isFinite,T=i._isPlaying,O=i.__render;return t=void 0!==t?t:y()-b(),!T||t<c||(o||(this._rendered||(this.render(),this._rendered=!0,_=this._valuesFunc),this.emit("start",m),this._onStartCallbackFired=!0),n=(t-c)/v,n=n>1?1:n,n=l?1-n:n,r=l?s:u,!m||(_(n,n,r),O&&O.update(m,n),this.emit("update",m,n),!(1===n||l&&0===n)||(a?(g&&this._repeat--,h&&(this._reversed=!l),this.emit(h&&!l?"reverse":"repeat",m),this._startTime=!l&&f?t+f:l&&p?t+p:t,!0):(e||(this._isPlaying=!1,d(this),j--),this.emit("complete",m),this._repeat=this._r,!1))))},e}(x),L=function(t){var e,n,r;for(r=t.length;r;r-=1)e=Math.floor(Math.random()*r),n=t[r-1],t[r-1]=t[e],t[e]=n;return t},A=0,D=function(t){function e(e){return t.call(this),this._duration=0,this._startTime=y()-b(),this._tweens=[],this._elapsed=0,this._id=A++,this._defaultParams=e,this.position=new w,this.position.addLabel("afterLast",this._duration),this.position.addLabel("afterInit",this._startTime),this}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.mapTotal=function(t){return t.call(this,this._tweens),this},e.prototype.timingOrder=function(t){var e=t(this._tweens.map(function(t){return t._startTime}));return this._tweens.map(function(t,n){t._startTime=e[n]}),this},e.prototype.getTiming=function(t,e,n,r){if(void 0===r&&(r=0),"reverse"===t){var i=n.stagger,o=(i||0)*(e.length-1);return e.map(function(t,e){return o-(i||0)*e+r})}if("async"===t)return e.map(function(t){return r});if("sequence"===t||"delayed"===t){var u=n.stagger;return u||(u=(n.duration||1e3)/(e.length-1)),e.map(function(t,e){return u*e+r})}if("oneByOne"===t)return e.map(function(t){return n.duration});if("shuffle"===t){var s=n.stagger;return L(e.map(function(t,e){return(s||0)*e+r}))}var a=n.stagger;return e.map(function(t,e){return(a||0)*e+r})},e.prototype.fromTo=function(e,n,r,i){var o=this;if(Array.isArray(e)){this._defaultParams&&(i=Object.assign({},this._defaultParams,i));var u=i.label,s="number"==typeof u?u:this.position.parseLabel(void 0!==u?u:"afterLast",null),a=this.getTiming(i.mode,e,i,s);e.map(function(u,s){o.add(t.fromTo(u,"function"==typeof n?n(s,e.length):Object.assign({},n),"function"==typeof r?r(s,e.length):r,"function"==typeof i?i(s,e.length):i),a[s])})}return this.start()},e.prototype.from=function(t,e,n){return this.fromTo(t,e,null,n)},e.prototype.to=function(t,e,n){return this.fromTo(t,null,e,n)},e.prototype.addLabel=function(t,e){return this.position.addLabel(t,e),this},e.prototype.map=function(t){for(var e=this,n=0,r=this._tweens.length;n<r;n++){var i=e._tweens[n];t(i,n),e._duration=Math.max(e._duration,i._duration+i._startTime)}return this},e.prototype.add=function(e,n){var r=this;if(Array.isArray(e))return e.map(function(t){r.add(t,n)}),this;"object"!=typeof e||e instanceof t||(e=new t(e.from).to(e.to,e));var i=this,o=i._defaultParams,u=i._duration;if(o)for(var s in o)"function"==typeof e[s]&&e[s](o[s]);var a="number"==typeof n?n:this.position.parseLabel(void 0!==n?n:"afterLast",null);return e._startTime=Math.max(this._startTime,e._delayTime,a),e._delayTime=a,e._isPlaying=!0,this._duration=Math.max(u,e._startTime+e._delayTime+e._duration),this._tweens.push(e),this.position.setLabel("afterLast",this._duration),this},e.prototype.restart=function(){return this._startTime+=y()-b(),l(this),this.emit("restart")},e.prototype.easing=function(t){return this.map(function(e){return e.easing(t)})},e.prototype.interpolation=function(t){return this.map(function(e){return e.interpolation(t)})},e.prototype.update=function(t){var e=this,n=e._tweens,r=e._duration,i=e._repeatDelayTime,o=e._reverseDelayTime,u=e._startTime,s=e._reversed,a=e._yoyo,f=e._repeat,p=e._isFinite;if(!e._isPlaying||t<u)return!0;var h=(t-u)/r;h=h>1?1:h,h=s?1-h:h;for(var l=t-u,c=s?r-l:l,y=0;y<n.length;)n[y].update(c),y++;if(this.emit("update",h,l),1===h||s&&0===h){if(f){for(p&&this._repeat--,this.emit(s?"reverse":"repeat"),a&&(this._reversed=!s,this.timingOrder(function(t){return t.reverse()})),this._startTime=!s&&i?t+i:s&&o?t+o:t,y=0;y<n.length;)n[y].reassignValues(t),y++;return!0}return this.emit("complete"),this._repeat=this._r,d(this),this._isPlaying=!1,!1}return!0},e.prototype.elapsed=function(t){return void 0!==t?this.update(t*this._duration):this._elapsed},e}(F);t.Plugins=T,t.Interpolator=r,t.onTick=function(t){return s.push({update:t})},t.has=function(t){return null!==c(t)},t.get=c,t.getAll=function(){return s},t.removeAll=function(){s.length=0},t.remove=d,t.add=l,t.now=y,t.update=g,t.autoPlay=function(t){f=t},t.isRunning=function(){return a},t.Tween=F,t.Easing=O,t.Timeline=D,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=full/Tween.min.js.map | ||
//# sourceMappingURL=Tween.min.js.map |
@@ -146,4 +146,13 @@ (function (global, factory) { | ||
*/ | ||
var lastTime = now(); | ||
var delta = 0; | ||
var timeDiff = 0; | ||
var frameMs = 50 / 3; | ||
var update = function (time, preserve) { | ||
time = time !== undefined ? time : now(); | ||
delta = time - lastTime; | ||
if (delta > 150) { | ||
timeDiff += delta - frameMs; | ||
} | ||
lastTime = time; | ||
if (_autoPlay && isStarted) { | ||
@@ -159,3 +168,3 @@ _tick = _ticker(update); | ||
while (i < _tweens.length) { | ||
_tweens[i].update(time, preserve); | ||
_tweens[i].update(time - timeDiff, preserve); | ||
i++; | ||
@@ -166,2 +175,9 @@ } | ||
/** | ||
* Normalised tweens global time | ||
* @return {number|Time} Normalised tweens global time | ||
* @memberof TWEEN | ||
* @example TWEEN.getTime() | ||
*/ | ||
var getTime = function () { return timeDiff; }; | ||
/** | ||
* The state of ticker running | ||
@@ -185,24 +201,2 @@ * @return {Boolean} Status of running updates on all tweens | ||
var Plugins = {}; | ||
// Normalise time when visiblity is changed (if available) ... | ||
if (root.document && root.document.addEventListener) { | ||
var doc = root.document; | ||
var timeDiff = 0; | ||
var timePause = 0; | ||
doc.addEventListener('visibilitychange', function () { | ||
if (document.hidden) { | ||
timePause = now(); | ||
_stopTicker(_tick); | ||
isStarted = false; | ||
} | ||
else { | ||
timeDiff = now() - timePause; | ||
for (var i = 0, length = _tweens.length; i < length; i++) { | ||
_tweens[i]._startTime += timeDiff; | ||
} | ||
_tick = _ticker(update); | ||
isStarted = true; | ||
} | ||
return true; | ||
}); | ||
} | ||
@@ -582,3 +576,3 @@ /** | ||
remove(this); | ||
this._pausedTime = now(); | ||
this._pausedTime = now() - getTime(); | ||
return this; | ||
@@ -596,5 +590,5 @@ }; | ||
this._isPlaying = true; | ||
this._startTime += now() - this._pausedTime; | ||
this._startTime += (now() - getTime()) - this._pausedTime; | ||
add(this); | ||
this._pausedTime = now(); | ||
this._pausedTime = now() - getTime(); | ||
return this; | ||
@@ -633,3 +627,3 @@ }; | ||
Lite.prototype.start = function start (time) { | ||
this._startTime = time !== undefined ? time : now(); | ||
this._startTime = time !== undefined ? time : now() - getTime(); | ||
this._startTime += this._delayTime; | ||
@@ -834,3 +828,3 @@ var ref = this; | ||
var property; | ||
time = time !== undefined ? time : now(); | ||
time = time !== undefined ? time : now() - getTime(); | ||
if (!_isPlaying || time < _startTime) { | ||
@@ -837,0 +831,0 @@ return true; |
@@ -1,3 +0,3 @@ | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(t.TWEEN={})}(this,function(t){"use strict";var n,e="undefined"!=typeof window?window:"undefined"!=typeof global?global:this,i=[],r=!1,o=!1,u=e.requestAnimationFrame||function(t){return e.setTimeout(t,16)},a=e.cancelAnimationFrame||function(t){return e.clearTimeout(t)},s=function(t){i.push(t),o&&!r&&(n=u(l),r=!0)},f=function(t){for(var n=0;n<i.length;n++)if(t===i[n])return i[n];return null},c=function(t){var n=i.indexOf(t);-1!==n&&i.splice(n,1)},h=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!==e.performance&&void 0!==e.performance.now)return e.performance.now.bind(e.performance);var t=e.performance&&e.performance.timing&&e.performance.timing.navigationStart?e.performance.timing.navigationStart:Date.now();return function(){return Date.now()-t}}(),l=function(t,e){if(t=void 0!==t?t:h(),o&&r&&(n=u(l)),0===i.length)return a(n),r=!1,!1;for(var s=0;s<i.length;)i[s].update(t,e),s++;return!0},p={};if(e.document&&e.document.addEventListener){var _=0,y=0;e.document.addEventListener("visibilitychange",function(){if(document.hidden)y=h(),a(n),r=!1;else{_=h()-y;for(var t=0,e=i.length;t<e;t++)i[t]._startTime+=_;n=u(l),r=!0}return!0})}var d={Linear:{None:function(t){return t}},Quadratic:{In:function(t){return t*t},Out:function(t){return t*(2-t)},InOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}},Cubic:{In:function(t){return t*t*t},Out:function(t){return--t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}},Quartic:{In:function(t){return t*t*t*t},Out:function(t){return 1- --t*t*t*t},InOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}},Quintic:{In:function(t){return t*t*t*t*t},Out:function(t){return--t*t*t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},Sinusoidal:{In:function(t){return 1-Math.cos(t*Math.PI/2)},Out:function(t){return Math.sin(t*Math.PI/2)},InOut:function(t){return.5*(1-Math.cos(Math.PI*t))}},Exponential:{In:function(t){return 0===t?0:Math.pow(1024,t-1)},Out:function(t){return 1===t?1:1-Math.pow(2,-10*t)},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(2-Math.pow(2,-10*(t-1)))}},Circular:{In:function(t){return 1-Math.sqrt(1-t*t)},Out:function(t){return Math.sqrt(1- --t*t)},InOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},Elastic:{In:function(t){return 0===t?0:1===t?1:-Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)},Out:function(t){return 0===t?0:1===t?1:Math.pow(2,-10*t)*Math.sin(5*(t-.1)*Math.PI)+1},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?-.5*Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI):.5*Math.pow(2,-10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)+1}},Back:{In:function(t){var 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?t*t*((n+1)*t-n)*.5:.5*((t-=2)*t*((n+1)*t+n)+2)}},Bounce:{In:function(t){return 1-d.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*d.Bounce.In(2*t):.5*d.Bounce.Out(2*t-1)+.5}}},v={Linear:function(t,n){var e=t.length-1,i=e*n,r=Math.floor(i),o=v.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=v.Utils.Bernstein,u=0;u<=i;u++)e+=r(1-n,i-u)*r(n,u)*t[u]*o(i,u);return e},CatmullRom:function(t,n){var e=t.length-1,i=e*n,r=Math.floor(i),o=v.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"function"==typeof t?t(e):(n-t)*e+t},Bernstein:function(t,n){var e=v.Utils.Factorial;return e(t)/e(n)/e(t-n)},Factorial:function(){var t=[1];return function(n){var e=1;if(t[n])return t[n];for(var i=n;i>1;i--)e*=i;return t[n]=e,e}}(),CatmullRom:function(t,n,e,i,r){var o=.5*(e-t),u=.5*(i-n),a=r*r;return(2*n-2*e+o+u)*(r*a)+(-3*n+3*e-2*o-u)*a+o*r+n}}},m=0,g=function(t){return this.id=m++,this.object=t,this._valuesStart={},this._valuesEnd=null,this._valuesStartRepeat={},this._duration=1e3,this._easingFunction=d.Linear.None,this._interpolationFunction=v.Linear,this._startTime=0,this._delayTime=0,this._repeat=0,this._r=0,this._isPlaying=!1,this._yoyo=!1,this._reversed=!1,this._onStartCallbackFired=!1,this._pausedTime=null,this._isFinite=!0,this._onStartCallback=null,this._onUpdateCallback=null,this._onCompleteCallback=null,this};g.prototype.onStart=function(t){return this._onStartCallback=t,this},g.prototype.onUpdate=function(t){return this._onUpdateCallback=t,this},g.prototype.onComplete=function(t){return this._onCompleteCallback=t,this},g.prototype.isPlaying=function(){return this._isPlaying},g.prototype.isStarted=function(){return this._onStartCallbackFired},g.prototype.pause=function(){return this._isPlaying?(this._isPlaying=!1,c(this),this._pausedTime=h(),this):this},g.prototype.play=function(){return this._isPlaying?this:(this._isPlaying=!0,this._startTime+=h()-this._pausedTime,s(this),this._pausedTime=h(),this)},g.prototype.duration=function(t){return this._duration="function"==typeof t?t(this._duration):t,this},g.prototype.to=function(t,n){return void 0===n&&(n=1e3),this._valuesEnd=t,this._duration=n,this},g.prototype.start=function(t){this._startTime=void 0!==t?t:h(),this._startTime+=this._delayTime;var n=this,e=n._valuesEnd,i=n._valuesStartRepeat,r=n._valuesStart,o=n._interpolationFunction,u=n.object;for(var a in e)!function(t){var n=u[t],a=e[t];if(u&&void 0!==u[t]){var s=u[t];if("number"==typeof n){if("string"==typeof a)i[t]=a,a=n+parseFloat(a);else if(Array.isArray(a)){a.unshift(n);var f=a;a=function(t){return o(f,t)}}}else if("object"==typeof a)if(Array.isArray(a)){var c=a,h=n.map(function(t){return t}),l=void 0,p=a.length;a=function(t){for(l=0;l<p;l++)s[l]="number"==typeof h[l]?h[l]+(c[l]-h[l])*t:c[l];return s}}else{var _=a,y={};for(var d in n)y[d]=n[d];a=function(t){for(var n in a)s[n]="number"==typeof y[n]?y[n]+(_[n]-y[n])*t:_[n];return s}}r[t]=n,e[t]=a}}(a);return s(this),this._isPlaying=!0,this},g.prototype.stop=function(){var t=this,n=t._isPlaying,e=t._startTime,i=t._duration;return n?(this.update(e+i),c(this),this._isPlaying=!1,this):this},g.prototype.delay=function(t){return this._delayTime="function"==typeof t?t(this._delayTime):t,this},g.prototype.repeat=function(t){return this._repeat="function"==typeof t?t(this._repeat):t,this._r=this._repeat,this._isFinite=isFinite(t),this},g.prototype.repeatDelay=function(t){return this._repeatDelayTime="function"==typeof t?t(this._repeatDelayTime):t,this},g.prototype.reverseDelay=function(t){return this._reverseDelayTime="function"==typeof t?t(this._reverseDelayTime):t,this},g.prototype.yoyo=function(t){return this._yoyo="function"==typeof t?t(this._yoyo):t,this},g.prototype.easing=function(t){return"function"==typeof t&&(this._easingFunction=t),this},g.prototype.interpolation=function(t){return"function"==typeof t&&(this._interpolationFunction=t),this},g.prototype.reassignValues=function(){var t=this,n=t._valuesStart,e=t._valuesEnd,i=t.object;for(var r in e){var o=n[r];i[r]=o}return this},g.prototype.update=function(t,n){var e,i,r,o=this,u=o._onStartCallbackFired,a=o._easingFunction,s=o._repeat,f=o._repeatDelayTime,l=o._reverseDelayTime,p=o._yoyo,_=o._reversed,y=o._startTime,d=o._duration,v=o._valuesStart,g=o._valuesEnd,M=o._valuesStartRepeat,b=o.object,I=o._isFinite,T=o._isPlaying,O=o._onStartCallback,C=o._onUpdateCallback,P=o._onCompleteCallback;if(t=void 0!==t?t:h(),!T||t<y)return!0;u||(O&&O(b),this._onStartCallbackFired=!0),e=(e=(t-y)/d)>1?1:e,i=a(e=_?1-e:e);for(r in g){var F=v[r],w=g[r];void 0!==F&&("function"==typeof w?b[r]=w(i):"number"==typeof w&&(b[r]=F+(w-F)*i))}if(C&&C(b,e),1===e||_&&0===e){if(s){if(I&&this._repeat--,!_)for(r in M)v[r]=g[r],g[r]+=parseFloat(M[r]);return p&&(this._reversed=!_),this._startTime=!_&&f?t+f:_&&l?t+l:t,!0}return n||c(this),this._isPlaying=!1,P&&P(),this._repeat=this._r,m--,!1}return!0},t.Plugins=p,t.onTick=function(t){return i.push({update:t})},t.has=function(t){return null!==f(t)},t.get=f,t.getAll=function(){return i},t.removeAll=function(){i.length=0},t.remove=c,t.add=s,t.now=h,t.update=l,t.autoPlay=function(t){o=t},t.isRunning=function(){return r},t.Tween=g,t.Easing=d,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(t.TWEEN={})}(this,function(t){"use strict";var n,i="undefined"!=typeof window?window:"undefined"!=typeof global?global:this,e=[],r=!1,o=!1,u=i.requestAnimationFrame||function(t){return i.setTimeout(t,16)},a=i.cancelAnimationFrame||function(t){return i.clearTimeout(t)},s=function(t){e.push(t),o&&!r&&(n=u(y),r=!0)},f=function(t){for(var n=0;n<e.length;n++)if(t===e[n])return e[n];return null},c=function(t){var n=e.indexOf(t);-1!==n&&e.splice(n,1)},h=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!==i.performance&&void 0!==i.performance.now)return i.performance.now.bind(i.performance);var t=i.performance&&i.performance.timing&&i.performance.timing.navigationStart?i.performance.timing.navigationStart:Date.now();return function(){return Date.now()-t}}(),l=h(),p=0,_=0,y=function(t,i){if(t=void 0!==t?t:h(),(p=t-l)>150&&(_+=p-50/3),l=t,o&&r&&(n=u(y)),0===e.length)return a(n),r=!1,!1;for(var s=0;s<e.length;)e[s].update(t-_,i),s++;return!0},d=function(){return _},v={},m={Linear:{None:function(t){return t}},Quadratic:{In:function(t){return t*t},Out:function(t){return t*(2-t)},InOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}},Cubic:{In:function(t){return t*t*t},Out:function(t){return--t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}},Quartic:{In:function(t){return t*t*t*t},Out:function(t){return 1- --t*t*t*t},InOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}},Quintic:{In:function(t){return t*t*t*t*t},Out:function(t){return--t*t*t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},Sinusoidal:{In:function(t){return 1-Math.cos(t*Math.PI/2)},Out:function(t){return Math.sin(t*Math.PI/2)},InOut:function(t){return.5*(1-Math.cos(Math.PI*t))}},Exponential:{In:function(t){return 0===t?0:Math.pow(1024,t-1)},Out:function(t){return 1===t?1:1-Math.pow(2,-10*t)},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(2-Math.pow(2,-10*(t-1)))}},Circular:{In:function(t){return 1-Math.sqrt(1-t*t)},Out:function(t){return Math.sqrt(1- --t*t)},InOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},Elastic:{In:function(t){return 0===t?0:1===t?1:-Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)},Out:function(t){return 0===t?0:1===t?1:Math.pow(2,-10*t)*Math.sin(5*(t-.1)*Math.PI)+1},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?-.5*Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI):.5*Math.pow(2,-10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)+1}},Back:{In:function(t){var 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?t*t*((n+1)*t-n)*.5:.5*((t-=2)*t*((n+1)*t+n)+2)}},Bounce:{In:function(t){return 1-m.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*m.Bounce.In(2*t):.5*m.Bounce.Out(2*t-1)+.5}}},g={Linear:function(t,n){var i=t.length-1,e=i*n,r=Math.floor(e),o=g.Utils.Linear;return n<0?o(t[0],t[1],e):n>1?o(t[i],t[i-1],i-e):o(t[r],t[r+1>i?i:r+1],e-r)},Bezier:function(t,n){for(var i=0,e=t.length-1,r=Math.pow,o=g.Utils.Bernstein,u=0;u<=e;u++)i+=r(1-n,e-u)*r(n,u)*t[u]*o(e,u);return i},CatmullRom:function(t,n){var i=t.length-1,e=i*n,r=Math.floor(e),o=g.Utils.CatmullRom;return t[0]===t[i]?(n<0&&(r=Math.floor(e=i*(1+n))),o(t[(r-1+i)%i],t[r],t[(r+1)%i],t[(r+2)%i],e-r)):n<0?t[0]-(o(t[0],t[0],t[1],t[1],-e)-t[0]):n>1?t[i]-(o(t[i],t[i],t[i-1],t[i-1],e-i)-t[i]):o(t[r?r-1:0],t[r],t[i<r+1?i:r+1],t[i<r+2?i:r+2],e-r)},Utils:{Linear:function(t,n,i){return"function"==typeof t?t(i):(n-t)*i+t},Bernstein:function(t,n){var i=g.Utils.Factorial;return i(t)/i(n)/i(t-n)},Factorial:function(){var t=[1];return function(n){var i=1;if(t[n])return t[n];for(var e=n;e>1;e--)i*=e;return t[n]=i,i}}(),CatmullRom:function(t,n,i,e,r){var o=.5*(i-t),u=.5*(e-n),a=r*r;return(2*n-2*i+o+u)*(r*a)+(-3*n+3*i-2*o-u)*a+o*r+n}}},M=0,b=function(t){return this.id=M++,this.object=t,this._valuesStart={},this._valuesEnd=null,this._valuesStartRepeat={},this._duration=1e3,this._easingFunction=m.Linear.None,this._interpolationFunction=g.Linear,this._startTime=0,this._delayTime=0,this._repeat=0,this._r=0,this._isPlaying=!1,this._yoyo=!1,this._reversed=!1,this._onStartCallbackFired=!1,this._pausedTime=null,this._isFinite=!0,this._onStartCallback=null,this._onUpdateCallback=null,this._onCompleteCallback=null,this};b.prototype.onStart=function(t){return this._onStartCallback=t,this},b.prototype.onUpdate=function(t){return this._onUpdateCallback=t,this},b.prototype.onComplete=function(t){return this._onCompleteCallback=t,this},b.prototype.isPlaying=function(){return this._isPlaying},b.prototype.isStarted=function(){return this._onStartCallbackFired},b.prototype.pause=function(){return this._isPlaying?(this._isPlaying=!1,c(this),this._pausedTime=h()-d(),this):this},b.prototype.play=function(){return this._isPlaying?this:(this._isPlaying=!0,this._startTime+=h()-d()-this._pausedTime,s(this),this._pausedTime=h()-d(),this)},b.prototype.duration=function(t){return this._duration="function"==typeof t?t(this._duration):t,this},b.prototype.to=function(t,n){return void 0===n&&(n=1e3),this._valuesEnd=t,this._duration=n,this},b.prototype.start=function(t){this._startTime=void 0!==t?t:h()-d(),this._startTime+=this._delayTime;var n=this,i=n._valuesEnd,e=n._valuesStartRepeat,r=n._valuesStart,o=n._interpolationFunction,u=n.object;for(var a in i)!function(t){var n=u[t],a=i[t];if(u&&void 0!==u[t]){var s=u[t];if("number"==typeof n){if("string"==typeof a)e[t]=a,a=n+parseFloat(a);else if(Array.isArray(a)){a.unshift(n);var f=a;a=function(t){return o(f,t)}}}else if("object"==typeof a)if(Array.isArray(a)){var c=a,h=n.map(function(t){return t}),l=void 0,p=a.length;a=function(t){for(l=0;l<p;l++)s[l]="number"==typeof h[l]?h[l]+(c[l]-h[l])*t:c[l];return s}}else{var _=a,y={};for(var d in n)y[d]=n[d];a=function(t){for(var n in a)s[n]="number"==typeof y[n]?y[n]+(_[n]-y[n])*t:_[n];return s}}r[t]=n,i[t]=a}}(a);return s(this),this._isPlaying=!0,this},b.prototype.stop=function(){var t=this,n=t._isPlaying,i=t._startTime,e=t._duration;return n?(this.update(i+e),c(this),this._isPlaying=!1,this):this},b.prototype.delay=function(t){return this._delayTime="function"==typeof t?t(this._delayTime):t,this},b.prototype.repeat=function(t){return this._repeat="function"==typeof t?t(this._repeat):t,this._r=this._repeat,this._isFinite=isFinite(t),this},b.prototype.repeatDelay=function(t){return this._repeatDelayTime="function"==typeof t?t(this._repeatDelayTime):t,this},b.prototype.reverseDelay=function(t){return this._reverseDelayTime="function"==typeof t?t(this._reverseDelayTime):t,this},b.prototype.yoyo=function(t){return this._yoyo="function"==typeof t?t(this._yoyo):t,this},b.prototype.easing=function(t){return"function"==typeof t&&(this._easingFunction=t),this},b.prototype.interpolation=function(t){return"function"==typeof t&&(this._interpolationFunction=t),this},b.prototype.reassignValues=function(){var t=this,n=t._valuesStart,i=t._valuesEnd,e=t.object;for(var r in i){var o=n[r];e[r]=o}return this},b.prototype.update=function(t,n){var i,e,r,o=this,u=o._onStartCallbackFired,a=o._easingFunction,s=o._repeat,f=o._repeatDelayTime,l=o._reverseDelayTime,p=o._yoyo,_=o._reversed,y=o._startTime,v=o._duration,m=o._valuesStart,g=o._valuesEnd,b=o._valuesStartRepeat,I=o.object,T=o._isFinite,O=o._isPlaying,C=o._onStartCallback,P=o._onUpdateCallback,F=o._onCompleteCallback;if(t=void 0!==t?t:h()-d(),!O||t<y)return!0;u||(C&&C(I),this._onStartCallbackFired=!0),i=(i=(t-y)/v)>1?1:i,e=a(i=_?1-i:i);for(r in g){var w=m[r],S=g[r];void 0!==w&&("function"==typeof S?I[r]=S(e):"number"==typeof S&&(I[r]=w+(S-w)*e))}if(P&&P(I,i),1===i||_&&0===i){if(s){if(T&&this._repeat--,!_)for(r in b)m[r]=g[r],g[r]+=parseFloat(b[r]);return p&&(this._reversed=!_),this._startTime=!_&&f?t+f:_&&l?t+l:t,!0}return n||c(this),this._isPlaying=!1,F&&F(),this._repeat=this._r,M--,!1}return!0},t.Plugins=v,t.onTick=function(t){return e.push({update:t})},t.has=function(t){return null!==f(t)},t.get=f,t.getAll=function(){return e},t.removeAll=function(){e.length=0},t.remove=c,t.add=s,t.now=h,t.update=y,t.autoPlay=function(t){o=t},t.isRunning=function(){return r},t.Tween=b,t.Easing=m,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=lite/Tween.min.js.map | ||
//# sourceMappingURL=Tween.min.js.map |
{ | ||
"name": "es6-tween", | ||
"version": "3.8.11", | ||
"version": "3.8.12", | ||
"description": "ES6 implementation of amazing tween.js", | ||
@@ -5,0 +5,0 @@ "browser": "full/Tween.min.js", |
@@ -18,3 +18,3 @@ /** | ||
*/ | ||
declare const onTick: (fn: any) => number; | ||
declare const onTick: (fn: Function) => number; | ||
/** | ||
@@ -46,3 +46,3 @@ * @returns {Array<Tween>} List of tweens in Array | ||
*/ | ||
declare const get: (tween: any) => any; | ||
declare const get: (tween: any) => Function; | ||
/** | ||
@@ -65,11 +65,10 @@ * @param {Tween} tween Tween Instance to be matched | ||
declare const now: any; | ||
declare const update: (time: number, preserve?: boolean) => boolean; | ||
/** | ||
* Updates global tweens by given time | ||
* @param {number|Time} time Timestamp | ||
* @param {Boolean=} preserve Prevents tween to be removed after finish | ||
* Normalised tweens global time | ||
* @return {number|Time} Normalised tweens global time | ||
* @memberof TWEEN | ||
* @example | ||
* TWEEN.update(500) | ||
* @example TWEEN.getTime() | ||
*/ | ||
declare const update: (time: number, preserve?: boolean) => boolean; | ||
declare const getTime: () => number; | ||
/** | ||
@@ -94,2 +93,2 @@ * The state of ticker running | ||
declare const Plugins: Object; | ||
export { Plugins, get, has, getAll, removeAll, remove, add, now, update, autoPlay, onTick, isRunning }; | ||
export { Plugins, get, getTime, has, getAll, removeAll, remove, add, now, update, autoPlay, onTick, isRunning }; |
@@ -41,3 +41,3 @@ /* global process */ | ||
*/ | ||
const onTick = fn => _tweens.push({ update: fn }) | ||
const onTick = (fn) => _tweens.push({ update: fn }) | ||
/** | ||
@@ -133,4 +133,13 @@ * @returns {Array<Tween>} List of tweens in Array | ||
*/ | ||
let lastTime = now() | ||
let delta = 0 | ||
let timeDiff = 0 | ||
let frameMs = 50 / 3 | ||
const update = (time, preserve) => { | ||
time = time !== undefined ? time : now() | ||
delta = time - lastTime | ||
if (delta > 150) { | ||
timeDiff += delta - frameMs | ||
} | ||
lastTime = time | ||
if (_autoPlay && isStarted) { | ||
@@ -146,3 +155,3 @@ _tick = _ticker(update) | ||
while (i < _tweens.length) { | ||
_tweens[i].update(time, preserve) | ||
_tweens[i].update(time - timeDiff, preserve) | ||
i++ | ||
@@ -153,2 +162,9 @@ } | ||
/** | ||
* Normalised tweens global time | ||
* @return {number|Time} Normalised tweens global time | ||
* @memberof TWEEN | ||
* @example TWEEN.getTime() | ||
*/ | ||
const getTime = () => timeDiff | ||
/** | ||
* The state of ticker running | ||
@@ -172,23 +188,2 @@ * @return {Boolean} Status of running updates on all tweens | ||
const Plugins = {} | ||
// Normalise time when visiblity is changed (if available) ... | ||
if (root.document && root.document.addEventListener) { | ||
const doc = root.document | ||
let timeDiff = 0 | ||
let timePause = 0 | ||
doc.addEventListener('visibilitychange', () => { | ||
if (document.hidden) { | ||
timePause = now() | ||
_stopTicker(_tick) | ||
isStarted = false | ||
} else { | ||
timeDiff = now() - timePause | ||
for (let i = 0, length = _tweens.length; i < length; i++) { | ||
_tweens[i]._startTime += timeDiff | ||
} | ||
_tick = _ticker(update) | ||
isStarted = true | ||
} | ||
return true | ||
}) | ||
} | ||
export { Plugins, get, has, getAll, removeAll, remove, add, now, update, autoPlay, onTick, isRunning } | ||
export { Plugins, get, getTime, has, getAll, removeAll, remove, add, now, update, autoPlay, onTick, isRunning } |
@@ -1,2 +0,2 @@ | ||
import { add, now, remove } from './core' | ||
import { add, now, remove, getTime } from './core' | ||
import Easing from './Easing' | ||
@@ -99,3 +99,3 @@ import Interpolation from './Interpolation' | ||
remove(this) | ||
this._pausedTime = now() | ||
this._pausedTime = now() - getTime() | ||
return this | ||
@@ -113,5 +113,5 @@ } | ||
this._isPlaying = true | ||
this._startTime += now() - this._pausedTime | ||
this._startTime += (now() - getTime()) - this._pausedTime | ||
add(this) | ||
this._pausedTime = now() | ||
this._pausedTime = now() - getTime() | ||
return this | ||
@@ -148,3 +148,3 @@ } | ||
start (time) { | ||
this._startTime = time !== undefined ? time : now() | ||
this._startTime = time !== undefined ? time : now() - getTime() | ||
this._startTime += this._delayTime | ||
@@ -315,3 +315,3 @@ const { _valuesEnd, _valuesStartRepeat, _valuesStart, _interpolationFunction, object } = this | ||
let property | ||
time = time !== undefined ? time : now() | ||
time = time !== undefined ? time : now() - getTime() | ||
if (!_isPlaying || time < _startTime) { | ||
@@ -318,0 +318,0 @@ return true |
@@ -5,3 +5,3 @@ import { assign } from './shim' | ||
if (!node || !node.nodeType || !tween) { return tween } | ||
const ID = node.queueID || 'queue_' + Math.round(Math.random() * 1000 + Date.now()) | ||
const ID = node.queueID || 'q_' + Date.now() | ||
if (!node.queueID) { | ||
@@ -8,0 +8,0 @@ node.queueID = ID |
@@ -12,3 +12,3 @@ export declare let create: { | ||
export declare let root: any; | ||
export declare let requestAnimationFrame: any; | ||
export declare let cancelAnimationFrame: any; | ||
export declare let requestAnimationFrame: Function; | ||
export declare let cancelAnimationFrame: Function; |
@@ -15,3 +15,3 @@ /* global global */ | ||
export let root = typeof (window) !== 'undefined' ? window : typeof (global) !== 'undefined' ? global : this | ||
export let requestAnimationFrame = root.requestAnimationFrame || (fn => root.setTimeout(fn, 16)) | ||
export let cancelAnimationFrame = root.cancelAnimationFrame || (id => root.clearTimeout(id)) | ||
export let requestAnimationFrame = root.requestAnimationFrame || ((fn) => root.setTimeout(fn, 16)) | ||
export let cancelAnimationFrame = root.cancelAnimationFrame || ((id) => root.clearTimeout(id)) |
@@ -1,2 +0,2 @@ | ||
import { add, now, remove } from './core' | ||
import { add, now, remove, getTime } from './core' | ||
import PlaybackPosition from './PlaybackPosition' | ||
@@ -32,3 +32,3 @@ import Tween, { EVENT_COMPLETE, EVENT_REPEAT, EVENT_REVERSE, EVENT_RS, EVENT_UPDATE } from './Tween' | ||
this._duration = 0 | ||
this._startTime = now() | ||
this._startTime = now() - getTime() | ||
this._tweens = [] | ||
@@ -164,4 +164,4 @@ this._elapsed = 0 | ||
const offset = typeof position === 'number' ? position : this.position.parseLabel(typeof position !== 'undefined' ? position : 'afterLast', null) | ||
tween._startTime = Math.max(this._startTime, tween._delayTime) | ||
tween._startTime += offset | ||
tween._startTime = Math.max(this._startTime, tween._delayTime, offset) | ||
tween._delayTime = offset | ||
tween._isPlaying = true | ||
@@ -174,3 +174,3 @@ this._duration = Math.max(_duration, tween._startTime + tween._delayTime + tween._duration) | ||
restart () { | ||
this._startTime += now() | ||
this._startTime += now() - getTime() | ||
add(this) | ||
@@ -186,3 +186,3 @@ return this.emit(EVENT_RS) | ||
update (time) { | ||
const { _tweens, _duration, _repeatDelayTime, _reverseDelayTime, _startTime, _reversed, _yoyo, _repeat, _isFinite, _elapsed, _isPlaying } = this | ||
const { _tweens, _duration, _repeatDelayTime, _reverseDelayTime, _startTime, _reversed, _yoyo, _repeat, _isFinite, _isPlaying } = this | ||
if (!_isPlaying || time < _startTime) { | ||
@@ -194,7 +194,2 @@ return true | ||
elapsed = _reversed ? 1 - elapsed : elapsed | ||
elapsed = ((elapsed * 1000) | 0) / 1000 | ||
if (elapsed === _elapsed) { | ||
return true | ||
} | ||
this._elapsed = elapsed | ||
const timing = time - _startTime | ||
@@ -204,3 +199,3 @@ const _timing = _reversed ? _duration - timing : timing | ||
while (i < _tweens.length) { | ||
_tweens[i].update(_timing, true) | ||
_tweens[i].update(_timing) | ||
i++ | ||
@@ -226,4 +221,5 @@ } | ||
} | ||
i = 0 | ||
while (i < _tweens.length) { | ||
_tweens[i].reassignValues() | ||
_tweens[i].reassignValues(time) | ||
i++ | ||
@@ -230,0 +226,0 @@ } |
@@ -31,3 +31,4 @@ import EventClass from './Event'; | ||
object: Object; | ||
_valuesEnd: any; | ||
_valuesEnd: Object; | ||
_valuesFunc: Function; | ||
_duration: number; | ||
@@ -219,3 +220,3 @@ _easingFunction: Function; | ||
*/ | ||
reassignValues(): this; | ||
reassignValues(time: any): this; | ||
/** | ||
@@ -222,0 +223,0 @@ * Updates initial object to target value by given `time` |
import InterTween from 'intertween' | ||
import { create } from './shim' | ||
import { add, now, Plugins, remove } from './core' | ||
import { add, now, Plugins, remove, getTime } from './core' | ||
import Easing from './Easing' | ||
@@ -91,2 +91,3 @@ import EventClass from './Event' | ||
this._valuesEnd = null | ||
this._valuesFunc = null | ||
this._duration = 1000 | ||
@@ -153,3 +154,3 @@ this._easingFunction = defaultEasing | ||
remove(this) | ||
this._pausedTime = now() | ||
this._pausedTime = now() - getTime() | ||
return this.emit(EVENT_PAUSE, this.object) | ||
@@ -167,5 +168,5 @@ } | ||
this._isPlaying = true | ||
this._startTime += now() - this._pausedTime | ||
this._startTime += (now() - getTime()) - this._pausedTime | ||
add(this) | ||
this._pausedTime = now() | ||
this._pausedTime = now() - getTime() | ||
return this.emit(EVENT_PLAY, this.object) | ||
@@ -181,3 +182,3 @@ } | ||
this._repeat = this._r | ||
this._startTime = now() + (noDelay ? 0 : this._delayTime) | ||
this._startTime = (now() - getTime()) + (noDelay ? 0 : this._delayTime) | ||
if (!this._isPlaying) { | ||
@@ -196,3 +197,3 @@ add(this) | ||
seek (time, keepPlaying) { | ||
this._startTime = now() + Math.max(0, Math.min(time, this._duration)) | ||
this._startTime = (now() - getTime()) + Math.max(0, Math.min(time, this._duration)) | ||
this.emit(EVENT_SEEK, time, this.object) | ||
@@ -260,3 +261,3 @@ return keepPlaying ? this : this.pause() | ||
} | ||
this._valuesEnd = InterTween(object, _valuesEnd, null, _easingFunction) | ||
this._valuesFunc = InterTween(object, _valuesEnd, null, _easingFunction) | ||
if (Renderer && this.node) { | ||
@@ -274,6 +275,8 @@ this.__render = new Renderer(this, object, _valuesEnd) | ||
start (time) { | ||
this._startTime = time !== undefined ? time : now() | ||
this._startTime = time !== undefined ? time : now() - getTime() | ||
this._startTime += this._delayTime | ||
this._onStartCallbackFired = false | ||
this._rendered = false | ||
this._isPlaying = true | ||
add(this) | ||
this._isPlaying = true | ||
return this | ||
@@ -292,4 +295,4 @@ } | ||
this.update(_startTime + _duration) | ||
this._isPlaying = false | ||
remove(this) | ||
this._isPlaying = false | ||
return this.emit(EVENT_STOP, object) | ||
@@ -305,3 +308,2 @@ } | ||
this._delayTime = typeof (amount) === 'function' ? amount(this._delayTime) : amount | ||
this._startTime += this._delayTime | ||
return this | ||
@@ -368,5 +370,9 @@ } | ||
*/ | ||
reassignValues () { | ||
const { _valuesEnd, object } = this | ||
const _valuesStart = _valuesEnd(0) | ||
reassignValues (time) { | ||
const { _valuesFunc, object, _delayTime } = this | ||
this._isPlaying = true | ||
this._startTime = time !== undefined ? time : now() - getTime() | ||
this._startTime += _delayTime | ||
add(this) | ||
const _valuesStart = _valuesFunc(0) | ||
for (const property in _valuesStart) { | ||
@@ -386,6 +392,6 @@ const start = _valuesStart[property] | ||
update (time, preserve) { | ||
let { _onStartCallbackFired, _easingFunction, _easingReverse, _repeat, _repeatDelayTime, _reverseDelayTime, _yoyo, _reversed, _startTime, _duration, _valuesEnd, object, _isFinite, _isPlaying, __render } = this | ||
let { _onStartCallbackFired, _easingFunction, _easingReverse, _repeat, _repeatDelayTime, _reverseDelayTime, _yoyo, _reversed, _startTime, _duration, _valuesFunc, object, _isFinite, _isPlaying, __render } = this | ||
let elapsed | ||
let currentEasing | ||
time = time !== undefined ? time : now() | ||
time = time !== undefined ? time : now() - getTime() | ||
if (!_isPlaying || time < _startTime) { | ||
@@ -398,3 +404,3 @@ return true | ||
this._rendered = true | ||
_valuesEnd = this._valuesEnd | ||
_valuesFunc = this._valuesFunc | ||
} | ||
@@ -408,6 +414,6 @@ this.emit(EVENT_START, object) | ||
currentEasing = _reversed ? _easingReverse : _easingFunction | ||
if (typeof _valuesEnd !== 'function' || !object) { | ||
if (!object) { | ||
return true | ||
} | ||
_valuesEnd(elapsed, elapsed, currentEasing) | ||
_valuesFunc(elapsed, elapsed, currentEasing) | ||
if (__render) { | ||
@@ -414,0 +420,0 @@ __render.update(object, elapsed) |
Sorry, the diff of this file is too big to display
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
820638
9411