jtween
Version:
jtween be similar to tweenlite and TimelineLite
2 lines (1 loc) • 21.3 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).jtween={})}(this,function(t){"use strict";function i(t){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function s(t,e,i){return e&&n(t.prototype,e),i&&n(t,i),t}var u={};function e(t,e){if(t.length&&0<t.length)for(var i=0;i<t.length;i++)e.call(t[i],i,t[i]);else e.call(t,0,t)}function a(t){return t.replace(/([A-Z])/g,"-$1").toLowerCase()}function o(t){return Math.round(1e3*t)/1e3}u.Linear={None:function(t){return t}},Date.now=Date.now||function(){return(new Date).getTime()};var h=Date.now();u.now=function(){return Date.now()-h};var l=function(){var t,e=document.createElement("div"),i=["Webkit","Moz","Ms","O"];for(t in i)if(i[t]+"Transform"in e.style)return i[t]}();function c(t){return l+(t?t.replace(/\b(\w)|\s(\w)/g,function(t){return t.toUpperCase()}):"")}function f(t){if(!t)throw new Error("el is undefined, can't tween!!!");return"string"==typeof t?document.querySelectorAll(t):t}var m=["ease","delay","yoyo","repeat","repeatDelay","onStart","onStartScope","onStartParams","onRepeat","onRepeatScope","onRepeatParams","onEnd","onEndScope","onEndParams","onUpdate","onUpdateScope","onUpdateParams","interpolation","isReverse","timeScale","isFrom","isPlaying"],p=["rotation","scale","autoAlpha"];function d(t,e,i){for(var n=0,s=m.length;n<s;n++)if(e===m[n])return;if(i){for(var a=0,r=p.length;a<r;a++)if(e===p[a])return e;if(void 0!==t._jt_obj[e])return e;if(void 0!==t.style[e])return e;if(e=c(e),void 0!==t.style[e])return e}else if("string"==typeof t[e]||"number"==typeof t[e])return e}function v(t,e){var i={};if(Array.isArray(e)){i.num=[t.num];for(var n=0,s=e.length;n<s;n++){var a=y(t,e[n]);i.num.push(a.num),i.unit=a.unit}}else i=y(t,e);return i}function y(t,e){var i,n=S(e);switch("rem"===t.unit&&"rem"!==n.unit?(x(),t.num=o(t.num*g),t.unit="px"):"rem"!==t.unit&&"rem"===n.unit&&(x(),t.num=o(t.num/g),t.unit="rem"),n.ext){case"+=":i=t.num+n.num;break;case"-=":i=t.num-n.num;break;default:i=n.num}return{num:i,unit:n.unit}}function T(t){void 0===t._jt_obj&&(t._jt_obj={x:0,y:0,z:0,rotationX:0,rotationY:0,rotationZ:0,scaleX:1,scaleY:1,scaleZ:1,skewX:0,skewY:0})}function S(t){t=/(\+=|-=|)(-|)(\d+\.\d+|\d+)(e[+-]?[0-9]{0,2}|)(rem|px|%|)/i.exec(t);return t?{num:o(t[2]+t[3]+t[4]),unit:t[5],ext:t[1]}:{num:0,unit:"px",ext:""}}function k(t,e){switch(e){case"x":case"y":case"z":case"rotationX":case"rotationY":case"rotationZ":case"scaleX":case"scaleY":case"scaleZ":case"skewX":case"skewY":return t._jt_obj[e];case"rotation":return t._jt_obj.rotationZ;case"scale":return t._jt_obj.scaleX;case"autoAlpha":return _(t,"opacity");default:return _(t,e)}}function _(t,e){if(t.style[e])return t.style[e];e=a(e),t=window.getComputedStyle(t,null);return t[e]||t.getPropertyValue(e)}var b,w,g,j={"column-count":1,columns:1,"font-weight":1,"line-height":1,opacity:1,"z-index":1,zoom:1};function P(t,e,i,n){switch(e){case"x":case"y":case"z":return t._jt_obj[e]=i+(n||"px"),1;case"rotationX":case"rotationY":case"rotationZ":case"skewX":case"skewY":return t._jt_obj[e]=i%360+"deg",1;case"scaleX":case"scaleY":case"scaleZ":return t._jt_obj[e]=i,1;case"rotation":return t._jt_obj.rotationZ=i%360+"deg",1;case"scale":return t._jt_obj.scaleX=i,t._jt_obj.scaleY=i,1;case"autoAlpha":return M(t,"opacity",i),void M(t,"display",0<i?"block":"none");default:return void 0!==n&&(i=j[a(e)]?i+n:i+(n||"px")),void M(t,e,i)}}function M(t,e,i){t.style[e]=i}function E(t){return"object"===i(t)&&1===t.nodeType}function R(t){var e="";(t._jt_obj.x||t._jt_obj.y||t._jt_obj.z)&&(e+="translate3d("+t._jt_obj.x+","+t._jt_obj.y+","+t._jt_obj.z+") "),t._jt_obj.rotationX&&(e+="rotateX("+t._jt_obj.rotationX+") "),t._jt_obj.rotationY&&(e+="rotateY("+t._jt_obj.rotationY+") "),t._jt_obj.rotationZ&&(e+="rotateZ("+t._jt_obj.rotationZ+") "),1===t._jt_obj.scaleX&&1===t._jt_obj.scaleY&&1===t._jt_obj.scaleZ||(e+="scale3d("+t._jt_obj.scaleX+", "+t._jt_obj.scaleY+", "+t._jt_obj.scaleZ+") "),(t._jt_obj.skewX||t._jt_obj.skewY)&&(e+="skew("+t._jt_obj.skewX+","+t._jt_obj.skewY+") "),t.style[c("transform")]=e}function x(){w||((w=document.createElement("div")).style.cssText="border:0 solid; position:absolute; line-height:0px;"),(b=b||document.getElementsByTagName("body")[0]).appendChild(w),w.style.borderLeftWidth="1rem",g=parseFloat(w.offsetWidth),b.removeChild(w)}var I=[],O=!1,U=function(){function a(t,e,i,n,s){r(this,a),this.initialize(t,e,i,n,s)}return s(a,[{key:"initialize",value:function(t,e,i,n,s){this.fromVars=i,this.curVars={},this.toVars=n,this.el=t,this.duration=1e3*Math.max(e,0),this.ease=n.ease||u.Linear.None,this.delay=1e3*Math.max(n.delay||0,0),this.yoyo=n.yoyo||!1,this.repeat=n.repeat||0,this.repeatDelay=1e3*Math.max(n.repeatDelay||0,0),this.onStart=n.onStart||null,this.onStartScope=n.onStartScope||this,this.onStartParams=n.onStartParams||[],this.onRepeat=n.onRepeat||null,this.onRepeatScope=n.onRepeatScope||this,this.onRepeatParams=n.onRepeatParams||[],this.onEnd=n.onEnd||null,this.onEndScope=n.onEndScope||this,this.onEndParams=n.onEndParams||[],this.onUpdate=n.onUpdate||null,this.onUpdateScope=n.onUpdateScope||this,this.onUpdateParams=n.onUpdateParams||[],this.isPlaying=!1,this.interpolation=n.interpolation||null,this.isReverse=n.isReverse||!1,this.timeScale=n.timeScale||1,this.isFrom=n.isFrom||!1,this.isInited=!1,this.isSeek=!1,this.isKeep=!1,this.isYoReverse=!1,this.isDom=s,this.repeat=this.repeat<0?999999999999:Math.floor(this.repeat),this.curRepeat=0,this.elapsed=null,this.startTime=this.delay,this.endTime=this.startTime+this.repeatDelay*this.repeat+this.duration*(this.repeat+1),this.curTime=null,this.lastTime=null,!1!==n.isPlaying&&this.play()}},{key:"_update",value:function(t){this.isKeep=!1,t=(this.isReverse?-1:1)*t*this.timeScale;var e=this.curTime,t=Math.min(this.endTime,Math.max(0,e+t));if(t===this.curTime)return!0;this.lastTime=e,this.curTime=t;e=Math.min(this.repeat,Math.max(0,Math.floor((this.curTime-this.startTime)/(this.duration+this.repeatDelay)))),t=!1;if(e!==this.curRepeat&&(this.curRepeat=e,this.yoyo&&(this.isYoReverse=this.curRepeat%2!=0),t=!0),this.isFrom&&(A(this),this._updateProp()),this.lastTime<this.startTime&&this.curTime<this.startTime)return!0;if(this.isFrom||(A(this),this._updateProp()),this.lastTime<this.curTime){if(this.lastTime<=this.startTime&&this.curTime>this.startTime&&!this.isSeek&&this.onStart&&this.onStart.apply(this.onStartScope,this.onStartParams),t&&!this.isSeek&&this.onRepeat&&this.onRepeat.apply(this.onRepeatScope,this.onRepeatParams),this.lastTime<this.endTime&&this.curTime>=this.endTime)return!this.isSeek&&this.onEnd&&this.onEnd.apply(this.onEndScope,this.onEndParams),this.isKeep}else if(this.lastTime>=this.endTime&&this.curTime<this.endTime&&!this.isSeek&&this.onEnd&&this.onEnd.apply(this.onEndScope,this.onEndParams),t&&!this.isSeek&&this.onRepeat&&this.onRepeat.apply(this.onRepeatScope,this.onRepeatParams),this.lastTime>this.startTime&&this.curTime<=this.startTime)return!this.isSeek&&this.onStart&&this.onStart.apply(this.onStartScope,this.onStartParams),this.isKeep;return!0}},{key:"_updateProp",value:function(){var t=Math.min(1,Math.max(0,(this.curTime===this.endTime?this.duration:(this.curTime-this.startTime)%(this.duration+this.repeatDelay))/this.duration));if(this.isYoReverse&&(t=1-t),t!==this.elapsed){this.elapsed=t;var e,i=this.ease(t),n=!1;for(e in this.fromVars){var s=this.fromVars[e],a=this.toVars[e],r=void 0;r=o(r=Array.isArray(a.num)?this.interpolation(a.num,i):s.num+(a.num-s.num)*i),this.curVars[e]={num:r,unit:a.unit},this.isDom?P(this.el,e,r,a.unit)&&(n=!0):this.el[e]=r+(a.unit||0)}n&&R(this.el),!this.isSeek&&this.onUpdate&&this.onUpdate.apply(this.onUpdateScope,this.onUpdateParams)}}},{key:"_addSelf",value:function(){I.push(this),O||(u.now(),O=!0)}},{key:"_removeSelf",value:function(){var t=I.indexOf(this);-1!==t&&I.splice(t,1)}},{key:"play",value:function(t){if(this.isReverse=!1,void 0!==t&&this.seek(t,!0),this.curTime===this.endTime)return this.isKeep=!1;this.isKeep=!0,this.isPlaying||(this.isPlaying=!0,this._addSelf())}},{key:"pause",value:function(){this.isKeep=!1,this.isPlaying&&(this.isPlaying=!1,this._removeSelf())}},{key:"stop",value:function(){this.pause(),this.seek(0,!0)}},{key:"reverse",value:function(t){if(this.isReverse=!0,void 0!==t&&this.seek(t,!0),0===this.curTime)return this.isKeep=!1;this.isKeep=!0,this.isPlaying||(this.isPlaying=!0,this._addSelf())}},{key:"seek",value:function(t,e){t=Math.max(0,Math.min(this.endTime,1e3*t));this.curTime!==t&&(this.isSeek=e||!1,this._update((this.isReverse?-1:1)*(t-this.curTime)),this.isSeek=!1)}},{key:"setTimeScale",value:function(t){this.timeScale=t}},{key:"kill",value:function(t){this.pause(),t&&this.seek(this.endTime),this.duration=null,this.curTime=this.lastTime=this.startTime=this.endTime=null,this.el=this.onStart=this.onRepeat=this.onEnd=this.onUpdate=null}}]),a}();function A(t){if(!t.isInited)for(var e in t.isInited=!0,t.fromVars){var i=S(t.isDom?k(t.el,e):t.el[e]);t.fromVars[e]=null===t.fromVars[e]?i:v(i,t.fromVars[e]),t.toVars[e]=null===t.toVars[e]?i:v(t.fromVars[e],t.toVars[e])}}function Y(u,t,h,l,c){if("number"!=typeof h)throw new Error("The second parameter must be a number!");z(c);var t=f(t),m=[];return e(t,function(t,e){var i,n,s={},a={},r=E(e);switch(u){case"fromTo":(i=c).isFrom=!0;break;case"from":(i=l).isFrom=!0;break;case"to":(i=c).isFrom=!1}for(n in r&&T(e),i){var o=d(e,n,r);if(o)switch(u){case"fromTo":s[o]=l[n],a[o]=c[n];break;case"from":s[o]=l[n],a[o]=null;break;case"to":s[o]=null,a[o]=c[n]}else a[n]=i[n]}m.push(new U(e,h,s,a,r))}),0===m.length?null:1===m.length?m[0]:m}function K(t,s,a){var t=f(t),r=I.length;e(t,function(t,e){for(var i=r-1;0<=i;i--){var n=I[i];n.el===e&&n[s](a)}})}function X(t,e){for(var i=I.length-1;0<=i;i--)I[i][t](e)}function z(t){t.bezier&&(F(t,t.bezier),t.interpolation=L,delete t.bezier),t.through&&(F(t,t.through),t.interpolation=Z,delete t.through),t.linear&&(F(t,t.linear),t.interpolation=V,delete t.linear)}function F(t,e){for(var i=0,n=e.length;i<n;i++)for(var s in e[i])0===i?t[s]=[e[i][s]]:t[s].push(e[i][s])}function V(t,e){var i=t.length-1,n=i*e,s=Math.floor(n),a=C.Linear;return e<0?a(t[0],t[1],n):1<e?a(t[i],t[i-1],i-n):a(t[s],t[i<s+1?i:s+1],n-s)}function L(t,e){for(var i=0,n=t.length-1,s=Math.pow,a=C.Bernstein,r=0;r<=n;r++)i+=s(1-e,n-r)*s(e,r)*t[r]*a(n,r);return i}function Z(t,e){var i=t.length-1,n=i*e,s=Math.floor(n),a=C.Through;return t[0]===t[i]?(e<0&&(s=Math.floor(n=i*(1+e))),a(t[(s-1+i)%i],t[s],t[(s+1)%i],t[(s+2)%i],n-s)):e<0?t[0]-(a(t[0],t[0],t[1],t[1],-n)-t[0]):1<e?t[i]-(a(t[i],t[i],t[i-1],t[i-1],n-i)-t[i]):a(t[s?s-1:0],t[s],t[i<s+1?i:s+1],t[i<s+2?i:s+2],n-s)}Object.assign(u,{get:function(t,e){var i=f(t);void 0!==i.length&&(i=i[0]);t=E(i);if(t){T(i);t=d(i,e,t);return t?k(i,t):null}return i[e]},set:function(t,h){e(f(t),function(t,e){var i,n=E(e);if(n){T(e);var s,a=!1;for(s in h){var r=d(e,s,n);r&&(i=h[s],/(,| |jpeg|jpg|png|gif|-3d)/g.test(i)||!/\d/g.test(i)?P(e,r,h[s])&&(a=!0):P(e,r,(r=v(S(k(e,r)),h[s])).num,r.unit)&&(a=!0))}a&&R(e)}else for(var o in h){var u=v(S(e[o]),h[o]);e[o]=u.num+(u.unit||0)}})},fromTo:function(t,e,i,n){return e||n.delay?Y("fromTo",t,e,i,n):this.set(t,n)},from:function(t,e,i){return e||i.delay?Y("from",t,e,i,{}):this.set(t,i)},to:function(t,e,i){return e||i.delay?Y("to",t,e,{},i):this.set(t,i)},kill:function(t,s){e(f(t),function(t,e){for(var i=I.length-1;0<=i;i--){var n=I[i];n.el===e&&n.kill(s)}})},killAll:function(t){for(var e=I.length-1;0<=e;e--)I[e].kill(t)},play:function(t,e){K(t,"play",e)},playAll:function(t){X("play",t)},pause:function(t){K(t,"pause")},pauseAll:function(){X("pause")},stop:function(t){K(t,"stop")},stopAll:function(){X("stop")},reverse:function(t,e){K(t,"reverse",e)},reverseAll:function(t){X("reverse",t)},seek:function(t,e){K(t,"seek",e)},seekAll:function(t){X("seek",t)},setTimeScale:function(t,e){K(t,"setTimeScale",e)},setTimeScaleAll:function(t){X("setTimeScale",t)},isTweening:function(t){for(var e=(e=f(t))[0]||e,i=I.length-1;0<=i;i--)if(I[i].el===e)return!0;return!1},call:function(t,e,i,n){return t?new U({},Math.max(0,t),{},{onEnd:e,onEndParams:i,isPlaying:n},!1):e.apply(e,i)}}),Object.assign(u,{path:function(t){z(t);for(var e,i=t.ease||u.Linear.None,n=t.step||1,s=[],a=0;a<=n;a++){e=i(a/n);var r,o={};for(r in t)Array.isArray(t[r])&&(o[r]=t.interpolation(t[r],e));s.push(o)}return s}});var D,C={Linear:function(t,e,i){return(e-t)*i+t},Bernstein:function(t,e){var i=this.Factorial;return i(t)/i(e)/i(t-e)},Factorial:(D=[1],function(t){var e,i=1;if(D[t])return D[t];for(e=t;1<e;e--)i*=e;return D[t]=i}),Through:function(t,e,i,n,s){var a=.5*(i-t),t=.5*(n-e),n=s*s;return(2*e-2*i+a+t)*(s*n)+(-3*e+3*i-2*a-t)*n+a*s+e}};var q=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)},B=[],N=[],Q=!1,W=0;function J(){var t=B.length;if(0!==t){var e=u.now(),i=e-W;W=e,500<i&&(i=33),N=B.slice(0);for(var n=0;n<t;n++){var s=N[n];s&&s.isPlaying&&!s._update(i)&&s.pause()}q(J)}else Q=!1}var $=function(){function e(t){r(this,e),this.initialize(t)}return s(e,[{key:"initialize",value:function(t){t=t||{},this.duration=0,this.delay=1e3*Math.max(t.delay||0,0),this.onStart=t.onStart||null,this.onStartScope=t.onStartScope||this,this.onStartParams=t.onStartParams||[],this.onEnd=t.onEnd||null,this.onEndScope=t.onEndScope||this,this.onEndParams=t.onEndParams||[],this.onUpdate=t.onUpdate||null,this.onUpdateScope=t.onUpdateScope||this,this.onUpdateParams=t.onUpdateParams||[],this.isPlaying=!1,this.isReverse=t.isReverse||!1,this.timeScale=t.timeScale||1,this.isSeek=!1,this.isKeep=!1,this.startTime=this.delay,this._updateEndTime(),this.curTime=null,this.lastTime=null,this.labels=[],this.tweens=[],this.calls=[]}},{key:"_updateEndTime",value:function(){this.endTime=this.startTime+this.duration}},{key:"_update",value:function(t){this.isKeep=!1,t=(this.isReverse?-1:1)*t*this.timeScale;var e=this.curTime,t=Math.min(this.endTime,Math.max(0,e+t));if(t===this.curTime)return!0;if(this.lastTime=e,this.curTime=t,this._updateProp(),this.lastTime<this.startTime&&this.curTime<this.startTime)return!0;if(this.lastTime<this.curTime){if(this.lastTime<=this.startTime&&this.curTime>this.startTime&&!this.isSeek&&this.onStart&&this.onStart.apply(this.onStartScope,this.onStartParams),this.lastTime<this.endTime&&this.curTime>=this.endTime)return!this.isSeek&&this.onEnd&&this.onEnd.apply(this.onEndScope,this.onEndParams),this.isKeep}else if(this.lastTime>=this.endTime&&this.curTime<this.endTime&&!this.isSeek&&this.onEnd&&this.onEnd.apply(this.onEndScope,this.onEndParams),this.lastTime>this.startTime&&this.curTime<=this.startTime)return!this.isSeek&&this.onStart&&this.onStart.apply(this.onStartScope,this.onStartParams),this.isKeep;return!0}},{key:"_updateProp",value:function(){this._checkTween(),this._checkCall(),!this.isSeek&&this.onUpdate&&this.onUpdate.apply(this.onUpdateScope,this.onUpdateParams)}},{key:"_addSelf",value:function(){B.push(this),Q||(W=u.now(),Q=!0,q(J))}},{key:"_removeSelf",value:function(){var t=B.indexOf(this);-1!==t&&B.splice(t,1)}},{key:"_parsePosition",value:function(t){if(void 0===t)return this.duration;var e={label:(t=/(^[a-zA-Z]\w*|)(\+=|-=|)(\d*\.\d*|\d*)/.exec(t=t))[1],ext:t[2],num:parseFloat(t[3])},i=0;if(e.label)i=this.getLabelTime(e.label);else if(e.ext){switch(e.ext){case"+=":i=this.duration+1e3*e.num;break;case"-=":i=this.duration-1e3*e.num}this._updateEndTime()}else e.num&&(i=1e3*e.num);return i}},{key:"addCall",value:function(t,e){e=this._parsePosition(e);this.duration=Math.max(this.duration,e),this.calls.push({time:e,call:t}),this._updateEndTime()}},{key:"_checkCall",value:function(){for(var t=0,e=this.calls.length;t<e;t++){var i=this.calls[t],n=this.lastTime-this.startTime,s=this.curTime-this.startTime,a=i.time;this.isSeek||(n<s?(0===a&&0==n&&0<s||n<a&&a<=s)&&i.call():(a<n&&s<=a||a===this.endTime&&n===this.endTime&&s<this.endTime)&&i.call())}}},{key:"addTween",value:function(t,e){e=this._parsePosition(e);this.duration=Math.max(this.duration,e+t.endTime),this.tweens.push({time:e,tween:t}),this._updateEndTime()}},{key:"_checkTween",value:function(){for(var t=0,e=this.tweens.length;t<e;t++){var i=this.tweens[t],n=this.lastTime-this.startTime,s=this.curTime-this.startTime,a=i.time;(null!==i.tween.curTime||a<=n||a<=s)&&i.tween.seek((s-a)/1e3,this.isSeek)}}},{key:"fromTo",value:function(t,e,i,n,s){return n.isPlaying=!1,this.addTween(u.fromTo(t,e,i,n),s),this}},{key:"from",value:function(t,e,i,n){return i.isPlaying=!1,this.addTween(u.from(t,e,i),n),this}},{key:"to",value:function(t,e,i,n){return i.isPlaying=!1,this.addTween(u.to(t,e,i),n),this}},{key:"add",value:function(t,e){switch(i(t)){case"object":this.addTween(t,e);break;case"function":this.addCall(t,e);break;case"string":this.addLabel(t,e);break;default:throw new Error("add action is wrong!!!")}return this}},{key:"remove",value:function(t){for(var e=this._parsePosition(t),i=this.tweens.length-1;0<=i;i--)this.tweens[i].time===e&&this.tweens.splice(i,1);return this}},{key:"addLabel",value:function(t,e){this.removeLabel(t);e=this._parsePosition(e);this.labels.push({name:t,time:e})}},{key:"removeLabel",value:function(t){for(var e=0,i=this.labels.length;e<i;e++)if(t===this.labels[e].name)return void this.labels.splice(e,1)}},{key:"getLabelTime",value:function(t){for(var e=0,i=this.labels.length;e<i;e++){var n=this.labels[e];if(t===n.name)return n.time}return null}},{key:"totalTime",value:function(){return this.duration}},{key:"play",value:function(t){if(this.isReverse=!1,void 0!==t&&this.seek(t,!0),this.curTime===this.endTime)return this.isKeep=!1;this.isKeep=!0,this.isPlaying||(this.isPlaying=!0,this._addSelf())}},{key:"pause",value:function(){this.isKeep=!1,this.isPlaying&&(this.isPlaying=!1,this._removeSelf())}},{key:"stop",value:function(){this.pause(),this.seek(0,!0)}},{key:"reverse",value:function(t){if(this.isReverse=!0,void 0!==t&&this.seek(t,!0),0===this.curTime)return this.isKeep=!1;this.isKeep=!0,this.isPlaying||(this.isPlaying=!0,this._addSelf())}},{key:"seek",value:function(t,e){t=Math.max(0,Math.min(this.endTime,this._parsePosition(t)));this.curTime!==t&&(this.isSeek=e||!1,this._update((this.isReverse?-1:1)*(t-this.curTime)),this.isSeek=!1)}},{key:"kill",value:function(t){this.pause(),t&&this.seek(this.endTime),this.labels=[],this.tweens=[],this.calls=[],this.duration=null,this.curTime=this.lastTime=this.startTime=this.endTime=null,this.onStart=this.onEnd=this.onUpdate=null}}]),e}(),G={create:function(t){return new $(t)},kill:function(t){t.kill()}},H={Linear:{None:function(t){return t}},Quad:{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)}},Quart:{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)}},Quint:{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)}},Sine:{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))}},Expo:{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)))}},Circ:{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){var e,i=.1;return 0===t?0:1===t?1:(e=!i||i<1?(i=1,.1):.4*Math.asin(1/i)/(2*Math.PI),-(i*Math.pow(2,10*--t)*Math.sin((t-e)*(2*Math.PI)/.4)))},Out:function(t){var e,i=.1;return 0===t?0:1===t?1:(e=!i||i<1?(i=1,.1):.4*Math.asin(1/i)/(2*Math.PI),i*Math.pow(2,-10*t)*Math.sin((t-e)*(2*Math.PI)/.4)+1)},InOut:function(t){var e,i=.1;return 0===t?0:1===t?1:(e=!i||i<1?(i=1,.1):.4*Math.asin(1/i)/(2*Math.PI),(t*=2)<1?i*Math.pow(2,10*--t)*Math.sin((t-e)*(2*Math.PI)/.4)*-.5:i*Math.pow(2,-10*--t)*Math.sin((t-e)*(2*Math.PI)/.4)*.5+1)}},Back:{In:function(t){return t*t*(2.70158*t-1.70158)},Out:function(t){return--t*t*(2.70158*t+1.70158)+1},InOut:function(t){var e=2.5949095;return(t*=2)<1?t*t*((1+e)*t-e)*.5:.5*((t-=2)*t*((1+e)*t+e)+2)}},Bounce:{In:function(t){return 1-this.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*this.Bounce.In(2*t):.5*this.Bounce.Out(2*t-1)+.5}}};t.Ease=H,t.JT=u,t.JTL=G,Object.defineProperty(t,"__esModule",{value:!0})});