-
Notifications
You must be signed in to change notification settings - Fork 125
/
Copy pathanimatic.min.js
2 lines (2 loc) · 22 KB
/
animatic.min.js
1
2
!function(t){"use strict";function i(t){return x?x+t:t}function e(t){for(var i=1;i<arguments.length;){var e=arguments[i++];for(var n in e)if(Array.isArray(e[n]))for(var r=0;r<e[n].length;++r){var s=e[n][r];s&&(t[n][r]=s)}else t[n]=e[n]}return t}function n(){this.handlers={}}function r(t,i,e){var n=r.propTypes[e]||r.NUMERIC;this.type=n,this.start=r.parseValue(t,n),this.end=r.parseValue(i,n),this.suffix=-1!==r.px.indexOf(e)?"px":""}function s(t,i,e){return Math.min(e,Math.max(i,t))}function o(t,i,e,n,r){this.item=t,this.transformation=i,this.start=null,this.diff=null,this.duration=0|(i.duration||e),this.delay=0|(i.delay||r),n=i.ease||n,this.ease=N[n]||N.linear,this.easeName=i.ease||n||"linear"}function a(t,i,e,n,r,s){this.item=t,this.name=i.name||i,this.start=null,this.diff=null,this.duration=0|(i.duration||e),this.delay=0|(i.delay||r),this.ease=N.css[i.ease]||N.css[n]||N.css.linear,this._infinite=!1,this._generated=s}function u(t){n.call(this),this.start=null,this.item=t,this.delay=0,this.duration=0,this.ease=N.linear,this.easeName="linear",this.animations=[]}function h(t){u.call(this,t)}function c(t){u.call(this,t),this._infinite=!1}function p(t,i){!document.styleSheets.length&&this.createStyleSheet(),this.stylesheet=document.styleSheets[0],this.item=t,this.animation=t.animation,!i&&this.style()}function l(){n.call(this),this.items=[],this.frame=null,this.run()}function f(){l.call(this,!0),this.currentTime=0,this.start=0}function m(t){n.call(this),this.dom=t,this.animation=new c(this),this.running=!0,this.state={}}function y(){var t=R.sub(this.state.translate,this.current.position);this.current.acceleration=R.add(this.current.acceleration,t)}function d(t,i,e){t||(t=R.set(0)),i||(i=R.set(0)),e||(e=!0);for(var n=0;3>n;++n)(this.current.position[n]<t[n]||this.current.position[n]>i[n])&&(e?this.previous.position[n]=2*this.current.position[n]-this.previous.position[n]:this.current.position[n]=Math.max(t[n],Math.min(i[n],this.current.position[n])))}function g(t,i){var e=this.current,n=this.previous;e.acceleration=R.scale(e.acceleration,this.mass),e.velocity=R.sub(e.position,n.position),void 0!==i&&(e.velocity=R.scale(e.velocity,i)),n.position=e.position,e.position=R.add(e.position,R.add(e.velocity,R.scale(e.acceleration,t*t))),e.acceleration=R.zero()}function v(t,i,e,n){m.call(this,t),i===Object(i)&&(e=i.viscosity,n=i.edge,i=i.mass),i/=100,i||(i=.01),e||(e=.1),n||(n=!1),this.mass=1/i,this.viscosity=e,this.edge=n,this.current={position:R.zero(),velocity:R.zero(),acceleration:R.zero()},this.previous={position:R.zero(),velocity:R.zero(),acceleration:R.zero()},this.clock=null}var b={};b.world=function(){return new l},b.timeline=function(){return new f},"object"==typeof module&&"object"==typeof module.exports?module.exports=b:"function"==typeof define&&define.amd?define(b):t.animatic=t.a=b;for(var M=t.requestAnimationFrame,z=t.cancelAnimationFrame,w=["moz","webkit","ms"],A=0;A<w.length&&!M;A++)M=t[w[A]+"RequestAnimationFrame"],z=t[w[A]+"CancelAnimationFrame"]||t[w[A]+"CancelRequestAnimationFrame"];var k,x=([].slice.call(getComputedStyle(document.documentElement,null)).join("").match(/(-(moz|webkit|ms)-)transform/)||[])[1],O=i("transform"),C=i("animation"),q=t.performance&&t.performance.now?t.performance:Date;M(function(t){k=t>1e12!=q.now()>1e12});var R={set:function(t,i,e){return Array.isArray(t)&&(i=t[1],e=t[2],t=t[0]),void 0===t&&(t=0),void 0===i&&(i=t,e=t),[t,i,e]},length:function(t,i,e){return Array.isArray(t)&&(i=t[1],e=t[2],t=t[0]),Math.sqrt(t*t+i*i+e*e)},add:function(t,i){return[t[0]+i[0],t[1]+i[1],t[2]+i[2]]},sub:function(t,i){return[t[0]-i[0],t[1]-i[1],t[2]-i[2]]},norm:function(t,i,e){Array.isArray(t)&&(i=t[1],e=t[2],t=t[0]);var n=this.length(t,i,e);return 0!==n?(t/=n,i/=n,e/=n):(t=0,i=0,e=0),[t,i,e]},dist:function(t,i){var e=t[0]-i[0],n=t[1]-i[1],r=t[2]-i[2];return Math.sqrt(e*e+n*n+r+r)},cross:function(t,i){var e=t[1]*i[2]-t[2]*i[1],n=t[2]*i[0]-t[0]*i[2],r=t[1]*i[1]-t[1]*i[0];return[e,n,r]},clone:function(t){return t.slice()},scale:function(t,i,e,n){return Array.isArray(t)&&(n=i,i=t[1],e=t[2],t=t[0]),[t*n,i*n,e*n]},zero:function(){return[0,0,0]}},S=Math.PI/180,j={identity:function(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]},multiply:function E(t,i){var e=this.identity();return e[0]=t[0]*i[0]+t[1]*i[4]+t[2]*i[8],e[1]=t[0]*i[1]+t[1]*i[5]+t[2]*i[9],e[2]=t[0]*i[2]+t[1]*i[6]+t[2]*i[10],e[4]=t[4]*i[0]+t[5]*i[4]+t[6]*i[8],e[5]=t[4]*i[1]+t[5]*i[5]+t[6]*i[9],e[6]=t[4]*i[2]+t[5]*i[6]+t[6]*i[10],e[8]=t[8]*i[0]+t[9]*i[4]+t[10]*i[8],e[9]=t[8]*i[1]+t[9]*i[5]+t[10]*i[9],e[10]=t[8]*i[2]+t[9]*i[6]+t[10]*i[10],e[12]=t[12]*i[0]+t[13]*i[4]+t[14]*i[8]+i[12],e[13]=t[12]*i[1]+t[13]*i[5]+t[14]*i[9]+i[13],e[14]=t[12]*i[2]+t[13]*i[6]+t[14]*i[10]+i[14],2>=arguments.length?e:E.apply(this,[e].concat(Array.prototype.slice.call(arguments,2)))},translate:function(t,i,e){return t||i||e?(t||(t=0),i||(i=0),e||(e=0),[1,0,0,0,0,1,0,0,0,0,1,0,t,i,e,1]):this.identity()},scale:function(t,i,e){return t||i||e?(t||(t=1),i||(i=1),e||(e=1),[t,0,0,0,0,i,0,0,0,0,e,0,0,0,0,1]):this.identity()},rotate:function(t,i,e){if(!(t||i||e))return this.identity();t||(t=0),i||(i=0),e||(e=0),t*=S,i*=S,e*=S;var n=Math.sin(t),r=Math.cos(t),s=Math.sin(i),o=Math.cos(i),a=Math.sin(e),u=Math.cos(e);return[o*u,r*a+n*s*u,n*a-r*s*u,0,-o*a,r*u-n*s*a,n*u+r*s*a,0,s,-n*o,r*o,0,0,0,0,1]},rotate3d:function(t,i,e,n){n||(n=0),n*=S;var r=Math.sin(n),s=Math.cos(n),o=R.norm(t,i,e);t=o[0],i=o[1],e=o[2];var a=t*t,u=i*i,h=e*e,c=1-s;return[a+(1-a)*s,t*i*c+e*r,t*e*c-i*r,0,t*i*c-e*r,u+(1-u)*s,i*e*c+t*r,0,t*e*c+i*r,i*e*c-t*r,h+(1-h)*s,0,0,0,0,1]},skew:function(t,i){return t||i?(t||(t=0),i||(i=0),t*=S,i*=S,[1,Math.tan(i),0,0,Math.tan(t),1,0,0,0,0,1,0,0,0,0,1]):this.identity()},perspective:function(t){return t=-1/t,[1,0,0,0,0,1,0,0,0,0,1,t,0,0,0,1]},parse:function(t){var i=t.match(/\((.+)\)/)[1].split(/,\s?/);return 6===i.length&&(i.splice(2,0,0,0),i.splice(6,0,0,0),i.splice(8,0,0,0,1,0),i.push(0,1)),i},inverse:function(t){var i=this.identity(),e=t[5]*t[10]-t[6]*t[9],n=t[1]*t[10]-t[2]*t[9],r=t[1]*t[6]-t[2]*t[5],s=t[4]*t[10]-t[6]*t[8],o=t[0]*t[10]-t[2]*t[8],a=t[0]*t[6]-t[2]*t[4],u=t[4]*t[9]-t[5]*t[8],h=t[0]*t[9]-t[1]*t[8],c=t[0]*t[5]-t[1]*t[4],p=1/(t[0]*e-t[1]*s+t[2]*u);return i[0]=p*e,i[1]=-p*n,i[2]=p*r,i[4]=-p*s,i[5]=p*o,i[6]=-p*a,i[8]=p*u,i[9]=-p*h,i[10]=p*c,i[12]=-t[12]*i[0]-t[13]*i[4]-t[14]*i[8],i[13]=-t[12]*i[1]-t[13]*i[5]-t[14]*i[9],i[14]=-t[12]*i[2]-t[13]*i[6]-t[14]*i[10],i},compose:function(t,i,e){t||(t=[]),i||(i=[]),e||(e=[]);var n=this.rotate(i[0],i[1],i[2]);return e.length&&(n[0]*=e[0],n[1]*=e[0],n[2]*=e[0],n[4]*=e[1],n[5]*=e[1],n[6]*=e[1],n[8]*=e[2],n[9]*=e[2],n[10]*=e[2]),t.length&&(n[12]=t[0],n[13]=t[1],n[14]=t[2]),n},decompose:function(t){var i=R.length(t[0],t[1],t[2]),e=R.length(t[4],t[5],t[6]),n=R.length(t[8],t[9],t[10]),r=Math.atan2(-t[9]/n,t[10]/n)/S,s=Math.asin(t[8]/n)/S,o=Math.atan2(-t[4]/e,t[0]/i)/S;(1===t[4]||-1===t[4])&&(r=0,s=t[4]*-Math.PI/2,o=t[4]*Math.atan2(t[6]/e,t[5]/e)/S);var a=t[12],u=t[13],h=t[14];return{translate:[a,u,h],rotate:[r,s,o],scale:[i,e,n]}},transpose:function(t){var i;return i=t[1],t[1]=t[4],t[4]=i,i=t[2],t[2]=t[8],t[8]=i,i=t[6],t[6]=t[9],t[9]=i,i=t[3],t[3]=t[12],t[12]=i,i=t[7],t[7]=t[13],t[13]=i,i=t[11],t[11]=t[14],t[14]=i,t},lookAt:function(t,i,e){var n=R.sub(t,i);n=R.norm(n),0===R.length(n)&&(n[2]=1);var r=R.cross(e,n);0===R.length(r)&&(n[0]+=1e-4,r=R.norm(R.cross(e,n)));var s=R.cross(n,r),o=this.identity();return o[0]=r[0],o[1]=r[1],o[2]=r[2],o[4]=s[0],o[5]=s[1],o[6]=s[2],o[8]=n[0],o[9]=n[1],o[10]=n[2],o},stringify:function(t){for(var i=0;i<t.length;++i)Math.abs(t[i])<1e-5&&(t[i]=0);return"matrix3d("+t.join()+")"}};n.prototype.on=function(t,i){return(this.handlers[t]=this.handlers[t]||[]).push(i),this},n.prototype.off=function(t,i){var e=this.handlers[t];return i?e.splice(e.indexOf(i),1):delete this.handlers[t],this},n.prototype.emit=function(t){var i=Array.prototype.slice.call(arguments,1),e=this.handlers[t];if(e)for(var n=0;n<e.length;++n)e[n].apply(this,i);return this},n.prototype.listeners=function(t){return this.handlers[t]||[]};var N=function(){var t={quad:function(t){return Math.pow(t,2)},cubic:function(t){return Math.pow(t,3)},quart:function(t){return Math.pow(t,4)},quint:function(t){return Math.pow(t,5)},expo:function(t){return Math.pow(t,6)},sine:function(t){return 1-Math.cos(t*Math.PI/2)},circ:function(t){return 1-Math.sqrt(1-t*t)},back:function(t){return t*t*(3*t-2)}},i={linear:function(t){return t}};return Object.keys(t).forEach(function(e){var n=t[e];i["ease-in-"+e]=n,i["ease-out-"+e]=function(t){return 1-n(1-t)},i["ease-in-out-"+e]=function(t){return.5>t?n(2*t)/2:1-n(-2*t+2)/2}}),i.css={linear:"cubic-bezier(0.000, 0.000, 1.000, 1.000)","ease-in-quad":"cubic-bezier(0.550, 0.085, 0.680, 0.530)","ease-in-cubic":"cubic-bezier(0.550, 0.055, 0.675, 0.190)","ease-in-quart":"cubic-bezier(0.895, 0.030, 0.685, 0.220)","ease-in-quint":"cubic-bezier(0.755, 0.050, 0.855, 0.060)","ease-in-sine":"cubic-bezier(0.470, 0.000, 0.745, 0.715)","ease-in-expo":"cubic-bezier(0.950, 0.050, 0.795, 0.035)","ease-in-circ":"cubic-bezier(0.600, 0.040, 0.980, 0.335)","ease-in-back":"cubic-bezier(0.600, -0.280, 0.735, 0.045)","ease-out-quad":"cubic-bezier(0.250, 0.460, 0.450, 0.940)","ease-out-cubic":"cubic-bezier(0.215, 0.610, 0.355, 1.000)","ease-out-quart":"cubic-bezier(0.165, 0.840, 0.440, 1.000)","ease-out-quint":"cubic-bezier(0.230, 1.000, 0.320, 1.000)","ease-out-sine":"cubic-bezier(0.390, 0.575, 0.565, 1.000)","ease-out-expo":"cubic-bezier(0.190, 1.000, 0.220, 1.000)","ease-out-circ":"cubic-bezier(0.075, 0.820, 0.165, 1.000)","ease-out-back":"cubic-bezier(0.175, 0.885, 0.320, 1.275)","ease-in-out-quad":"cubic-bezier(0.455, 0.030, 0.515, 0.955)","ease-in-out-cubic":"cubic-bezier(0.645, 0.045, 0.355, 1.000)","ease-in-out-quart":"cubic-bezier(0.770, 0.000, 0.175, 1.000)","ease-in-out-quint":"cubic-bezier(0.860, 0.000, 0.070, 1.000)","ease-in-out-sine":"cubic-bezier(0.445, 0.050, 0.550, 0.950)","ease-in-out-expo":"cubic-bezier(1.000, 0.000, 0.000, 1.000)","ease-in-out-circ":"cubic-bezier(0.785, 0.135, 0.150, 0.860)","ease-in-out-back":"cubic-bezier(0.680, -0.550, 0.265, 1.550)"},i}();r.NUMERIC="NUMERIC",r.COLOR="COLOR",r.propTypes={color:r.COLOR,backgroundColor:r.COLOR,borderColor:r.COLOR},r.px="margin,marginTop,marginLeft,marginBottom,marginRight,padding,paddingTop,paddingLeft,paddingBottom,paddingRight,top,left,bottom,right,width,height,maxWidth,maxHeight,minWidth,minHeight,borderRadius,borderWidth".split(","),r.parseValue=function(t,i){return i===r.COLOR?r.parseColor(t):r.parseNumeric(t)},r.parseNumeric=function(t){return Array.isArray(t)||(t=String(t).split(/\s+/)),Array.isArray(t)?t.map(parseFloat):Number(t)},r.parseColor=function(t){var i=t.match(/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i);if(i)return{r:parseInt(i[1],16),g:parseInt(i[2],16),b:parseInt(i[3],16),a:1};var e=t.match(/^rgba?\(([0-9.]*), ?([0-9.]*), ?([0-9.]*)(?:, ?([0-9.]*))?\)$/);return e?{r:parseFloat(e[1]),g:parseFloat(e[2]),b:parseFloat(e[3]),a:parseFloat(null!=e[4]?e[4]:1)}:void 0},r.prototype.interpolate=function(t){if(this.type===r.NUMERIC){if(Array.isArray(this.end))return this.array(t);if(void 0!==this.end)return this.absolute(t)}else if(this.type===r.COLOR)return this.color(t)},r.prototype.array=function(t){for(var i=[],e=0;e<this.end.length;++e)this.end[e]&&(i[e]=this.start[e]+this.end[e]*t,this.suffix&&(i[e]+=this.suffix));return i},r.prototype.absolute=function(t){var i=Number(this.start)+(Number(this.end)-Number(this.start))*t;return this.suffix&&(i+=this.suffix),i},r.prototype.color=function(t){var i={r:0,g:0,b:0};for(var e in i){var n=Math.round(this.start[e]+(this.end[e]-this.start[e])*t);i[e]=s(n,0,255)}return e="a",n=Math.round(this.start[e]+(this.end[e]-this.start[e])*t),i[e]=s(n,0,1),"rgba("+[i.r,i.g,i.b,i.a]+")"},o.skip={duration:null,delay:null,ease:null},o.transform={translate:null,rotate:null,scale:null},o.getState=function(t,i){var e,n={};for(var s in t)s in o.skip||t.hasOwnProperty(s)&&(null==i.get(s)&&(e||(e=getComputedStyle(i.dom,null)),o.setItemState(i,s,e)),n[s]=new r(i.get(s),t[s],s));return n},o.setItemState=function(t,i,e){if(i in o.transform){var n=e[O];n="none"===n?{translate:R.zero(),rotate:R.zero(),scale:R.set(1)}:j.decompose(j.parse(n)),t.set("translate",n.translate),t.set("rotate",n.rotate),t.set("scale",n.scale)}else t.set(i,e[i])},o.prototype.init=function(t,i){(null===this.start||i)&&(null===this.start&&(this.state=o.getState(this.transformation,this.item)),this.start=t+this.delay)},o.prototype.merge=function(t,i,n,r){this.duration=0|(t.duration||i),this.delay=0|(t.delay||r),n=t.ease||n,this.ease=N[n]||N.linear,this.easeName=t.ease||n||"linear",e(this.transformation,t),this.start=null},o.prototype.get=function(t){return this.state[t]},o.prototype.run=function(t,i){if(!(t<this.start)||i){var e=0;t>=this.start&&(e=(t-this.start)/this.duration,e=this.ease(e)),this.transform(e)}},o.prototype.pause=function(){this.diff=q.now()-this.start},o.prototype.resume=function(){this.start=q.now()-this.diff},o.prototype.interpolate=function(t,i){return this.get(t).interpolate(i)},o.prototype.transform=function(t){for(var i in this.state)this.item.set(i,this.interpolate(i,t))},o.prototype.end=function(t,i){!t&&this.transform(this.ease(1)),!i&&(this.start=null)},a.prototype.init=function(t,i){(null===this.start||i)&&(this.start=t+this.delay,this.item.style(C,this.name+" "+this.duration+"ms "+this.ease+" "+this.delay+"ms"+(this._infinite?" infinite":"")+" forwards"))},a.prototype.run=function(){},a.prototype.pause=function(){this.item.style(C+"-play-state","paused"),this.diff=q.now()-this.start},a.prototype.resume=function(){this.item.style(C+"-play-state","running"),this.start=q.now()-this.diff},a.prototype.end=function(){if(this._generated){var t=getComputedStyle(this.item.dom,null),i=t[O];this.item.style(C,""),this.item.state=j.decompose(j.parse(i)),this.item.style()}this.start=null},u.prototype=Object.create(n.prototype),u.prototype.constructor=u,u.prototype.add=function(t,i,e,n,r){function s(t,r){var s=new c(t);return r.forEach(function(t){s.add(t,i,e,n)}),s}function p(t,r){var o=new h(t);return r.forEach(function(r){Array.isArray(r)?o.add(s(t,r)):o.add(r,i,e,n)}),o}return Array.isArray(t)?t=p(this.item,t):"string"==typeof t||void 0!=t.name?t=new a(this.item,t,i,e,n,r):t instanceof u||(t=new o(this.item,t,i,e,n)),this.animations.push(t),i=this.animations.map(function(t){return t.duration+t.delay}),this.duration=this instanceof h?Math.max.apply(null,i):i.reduce(function(t,i){return t+i},0),this},Object.defineProperty(u.prototype,"length",{get:function(){return this.animations.length}}),u.prototype.get=function(t){return this.animations[t]},u.prototype.empty=function(){this.animations=[]},u.prototype.animate=function(t,i,e,n){return this.add(t,i,e,n)},u.prototype.css=function(){return this.item.css()},h.prototype=Object.create(u.prototype),h.prototype.constructor=h,h.prototype.all=function(t){for(var i=Array.prototype.slice.call(arguments,1),e=0;e<this.animations.length;++e){var n=this.animations[e];n[t].apply(n,i)}},h.prototype.init=function(t,i){(null===this.start||i)&&(this.start=t,this.all("init",t,i),this.emit("start"))},h.prototype.run=function(t){if(this.animations.length){for(var i=0;i<this.animations.length;++i){var e=this.animations[i];e.start+e.duration<=t?(this.animations.splice(i--,1),e.end()):e.run(t)}this.item.style(),this.animations.length||this.end()}},h.prototype.seek=function(t){this.run(t)},h.prototype.pause=function(){this.all("pause")},h.prototype.resume=function(){this.all("resume")},h.prototype.end=function(t){this.all("end",t),this.emit("end")},c.prototype=Object.create(u.prototype),c.prototype.constructor=c,c.prototype.init=function(t,i){(null===this.start||i)&&(this.start=t,this.animations[0].init(t,i),this.emit("start"))},c.prototype.run=function(t,i){if(this.animations.length){for(;0!==this.animations.length;){if(i=this.animations[0],i instanceof a&&(i._infinite=this._infinite),i.init(t),!(i.start+i.duration<=t)){i.run(t);break}if(this._infinite&&i instanceof a)break;this.animations.shift(),i.end(),!this._infinite||i instanceof a||this.animations.push(i)}i instanceof a||this.item.style(),this.animations.length||this.end()}},c.prototype.seek=function(t){if(0!==this.animations.length){for(var i=0,e=0;e<this.animations.length;++e){var n=this.animations[e];n.init(i,!0);{if(!(n.start+n.duration<=t)){n.run(t,!0);break}i+=n.delay+n.duration,n.end(!1,!0)}}this.item.style()}},c.prototype.infinite=function(){return this._infinite=!0,this},c.prototype.pause=function(){this.animations.length&&this.animations[0].pause()},c.prototype.resume=function(){this.animations.length&&this.animations[0].resume()},c.prototype.end=function(t){for(var i=0;i<this.animations.length;++i)this.animations[i].end(t);this.animations=[],this._infinite=!1,this.emit("end")},p.skip={translate:null,rotate:null,scale:null},p.prototype.createStyleSheet=function(){var t=document.createElement("style");document.getElementsByTagName("head")[0].appendChild(t)},p.prototype.pause=function(){this.animation.pause()},p.prototype.resume=function(){this.animation.resume()},p.prototype.stop=function(){var t=getComputedStyle(this.item.dom,null),i=t[O];return this.item.style(C,""),this.item.state=j.decompose(j.parse(i)),this.item.style(),this},p.prototype.style=function(){var t="a"+Date.now()+"r"+Math.floor(1e3*Math.random()),i=this.stylesheet.cssRules;this.stylesheet.insertRule(this.keyframes(t),i?i.length:0),this.animation.empty(),this.animation.add(t,this.animation.duration,"",0,!0)},p.prototype.keyframes=function(t){for(var e=0,n=["@"+i("keyframes")+" "+t+"{"],r=0;r<this.animation.length;++r){var s=this.animation.get(r),a=this.animation.get(r+1);if(s.init(),s instanceof o)0===r&&n.push(this.frame(0,N.css[s.easeName])),s.delay&&n.push(this.frame(e+=s.delay)),s.transform(1),n.push(this.frame(e+=s.duration,a&&N.css[a.easeName]));else{var u=[];s.animations.forEach(function f(t){t.animations&&t.animations.forEach(f),t.delay&&-1===u.indexOf(t.delay)&&u.push(t.delay),t.duration&&-1===u.indexOf(t.delay+t.duration)&&u.push(t.delay+t.duration)}),u=u.sort(function(t,i){return t-i});for(var h=0;h<u.length;++h){for(var c=u[h],p=0;p<s.animations.length;++p){var l=s.animations[p];l.delay>=c||l.delay+l.duration<c||l.transform(l.ease((c-l.delay)/l.duration))}n.push(this.frame(e+=c))}}}return n.push("}"),n.join("")},p.prototype.percent=function(t){return(100*t/this.animation.duration).toFixed(3)},p.prototype.frame=function(t,e){var n=this.percent(t),r=[];for(var s in this.item.state)s in p.skip||r.push(n?s.replace(/([A-Z])/g,"-$1")+":"+this.item.get(s)+";":"");return n+"% {"+(n?O+":"+this.item.transform()+";":"")+r.join("")+(e?i("animation-timing-function")+":"+e+";":"")+"}"},l.prototype=Object.create(n.prototype),l.prototype.constructor=l,l.prototype.run=function(){function t(e){k&&(e=q.now()),i.update(e),i.frame=M(t)}var i=this;this.frame=M(t)},l.prototype.update=function(t){for(var i=0;i<this.items.length;++i)this.items[i].update(t)},l.prototype.add=function(t,i,e,n){var r;return r=i?new v(t,i,e,n):new m(t),this.items.push(r),r},l.prototype.cancel=function(){this.frame&&z(this.frame),this.frame=0},l.prototype.stop=function(){this.cancel();for(var t=0;t<this.items.length;++t)this.items[t].stop()},l.prototype.pause=function(){this.cancel();for(var t=0;t<this.items.length;++t)this.items[t].pause()},l.prototype.resume=function(){for(var t=0;t<this.items.length;++t)this.items[t].resume();this.run()},f.prototype=Object.create(l.prototype),f.prototype.constructor=f,f.prototype.run=function(){function t(e){k&&(e=q.now()),i.running&&(i.currentTime=e-i.start),i.update(i.currentTime),i.frame=M(t)}this.frame=M(t);var i=this},f.prototype.update=function(t){for(var i=0,e=this.items.length;e>i;++i){var n=this.items[i];this.changed<e||this.running?(n.timeline(t),this.changed++,this.emit("update",t)):n.style()}},f.prototype.play=function(){this.running=!0,this.start=q.now()-this.currentTime},f.prototype.pause=function(){this.running=!1},f.prototype.stop=function(){this.currentTime=0,this.running=!1},f.prototype.seek=function(t){this.changed=0,this.currentTime=t},m.prototype=Object.create(n.prototype),m.prototype.constructor=m,m.prototype.update=function(t){this.running&&this.animation.run(t)},m.prototype.timeline=function(t){this.clear(),this.animation.seek(t)},m.prototype.pause=function(){this.running&&(this.animation.pause(),this.running=!1)},m.prototype.resume=function(){this.running||(this.animation.resume(),this.running=!0)},m.prototype.style=function(t,i){var e=this.dom.style;if(t&&i)e[t]=i;else{e[O]=this.transform();for(var t in this.state)e[t]=this.get(t)}},m.prototype.transform=function(){return j.stringify(this.matrix())},m.prototype.matrix=function(){var t=this.state;return j.compose(t.translate,t.rotate,t.scale)},m.prototype.center=function(){return j.decompose(j.inverse(this.matrix()))},m.prototype.lookAt=function(t){var i=j.decompose(j.lookAt(t,this.get("translate"),R.set(0,1,0)));this.set("rotate",i.rotate)},m.prototype.set=function(t,i){if(Array.isArray(i)){this.state[t]||(this.state[t]=[]);for(var e=0;e<i.length;++e)void 0!==i[e]&&(this.state[t][e]=i[e])}else this.state[t]=i;return this},m.prototype.get=function(t){return this.state[t]},m.prototype.clear=function(){this.state.translate=R.zero(),this.state.rotate=R.zero(),this.state.scale=R.set(1)},m.prototype.animate=function(t,i,e,n){return this.animation.add(t,i,e,n)},m.prototype.alternate=function(t,i,e,n){this.animation.length?this.animation.get(0).merge(t,i,e,n):this.animate.call(this,t,i,e,n)},m.prototype.finish=function(t){return this.animation.end(t),this},m.prototype.stop=function(){return this.finish(!0)},m.prototype.css=function(t){return new p(this,t)},v.prototype=Object.create(m.prototype),v.prototype.constructor=v,v.prototype.update=function(t){this.animation.run(t),this.integrate(t),this.style()},v.prototype.timeline=function(t){this.clear(),this.animation.seek(t),this.integrate(t,!0),this.style()},v.prototype.integrate=function(t,i){this.clock||(this.clock=t);var e=t-this.clock;e&&(i&&(e=Math.max(-16,Math.min(16,e))),this.clock=t,e*=.001,y.call(this),this.edge&&d.call(this,R.set(this.edge.min),R.set(this.edge.max),this.edge.bounce),g.call(this,e,1-this.viscosity))},v.prototype.css=function(){throw new Error("CSS is nor supported for physics")},v.prototype.matrix=function(){var t=this.state;return j.compose(this.current.position,t.rotate,t.scale)}}(Function("return this")());
//# sourceMappingURL=animatic.min.js.map