just-animate
Version:
_Making Animation Simple_
174 lines (173 loc) • 18 kB
JavaScript
var just=function(t){"use strict"
var b={}
function e(t){b[t.name]=t}function R(t){return!!t||0===t||!1===t}function k(t){return"function"==typeof t}function x(t){return"number"==typeof t}function p(t){return"object"==typeof t&&!!t}function s(t){return"string"==typeof t}function w(t){return t&&isFinite(t.length)&&!s(t)&&!k(t)}function c(t){return t.nodeType||t instanceof SVGElement}function T(t,e){return t.hasOwnProperty(e)}var u=1,f=2,l=3,_=void 0,n=/^([+|-]*[0-9]*[.]*?[0-9]+)([a-z%]+)*$/i,r="config",v=Math.abs,d=Math.floor,h=Math.max,g=Math.min
function m(t,e,r){return t!==_&&e<=t&&t<=r}function S(t){return t.replace(/([A-Z])/g,function(t){return"-"+t[0].toLowerCase()})}function i(t){return t.split(",")}var y="running",A="px",M="deg",a="translate",z="transform",W=i("rotateX,rotateY,rotateZ,rotate"),o=i("scaleX,scaleY,scaleZ,scale"),L=i("perspective,x,y,z"),E=W.concat(o,L),B={x:a+"X",y:a+"Y",z:a+"Z"},F=i("backgroundSize,border,borderBottom,borderBottomLeftRadius,borderBottomRightRadius,borderBottomWidth,borderLeft,borderLeftWidth,borderRadius,borderRight,borderRightWidth,borderTop,borderTopLeftRadius,borderTopRightRadius,borderTopWidth,borderWidth,bottom,columnGap,columnRuleWidth,columnWidth,columns,flexBasis,font,fontSize,gridColumnGap,gridGap,gridRowGap,height,left,letterSpacing,lineHeight,margin,marginBottom,marginLeft,marginRight,marginTop,maskSize,maxHeight,maxWidth,minHeight,minWidth,outline,outlineOffset,outlineWidth,padding,paddingBottom,paddingLeft,paddingRight,paddingTop,perspective,right,shapeMargin,tabSize,top,width,wordSpacing")
function O(f){var s=[]
return function(){for(var t=arguments,e=0,r=s.length;e<r;e++){var n=s[e].args,i=t.length
if(n.length===i){for(var a=0,o=0;o<i&&n[o]===t[o];o++)++a
if(a===i)return s[e].value}}var u=f.apply(_,t)
return s.push({args:t,value:u}),u}}var C=17
function j(t,e){return-1!==(r=e,t.indexOf(r))
var r}function q(t,e,r){var n=t&&t.length
if(!n)return _
if(e===_)return t[r?n-1:0]
if(r){for(var i=n-1;-1<i;i--)if(e(t[i]))return t[i]}else for(i=0;i<n;i++)if(e(t[i]))return t[i]
return _}function P(t,e){var r=t.indexOf(e)
return-1!==r?t.splice(r,1):_}function G(i){return function(t,e){var r=t[i],n=e[i]
return r<n?-1:n<r?1:0}}function H(t){return R(t)?w(t)?t:[t]:[]}function N(t,e){return e!==_&&Array.prototype.push.call(t,e),e}function V(t,e){return j(t,e)||N(t,e),e}function U(t,r){var n=[]
return Z(t,function(t){var e=r(t)
w(e)?Z(e,function(t){return N(n,t)}):N(n,e)}),n}function Z(t,e){for(var r=H(t),n=0,i=r.length;n<i;n++)e(r[n],n,i)}function D(t){var e={unit:_,value:_}
if(!R(t))return e
if(Number(t))return e.value=+t,e
var r=n.exec(t)
return r&&(e.unit=r[2]||_,e.value=r[1]?parseFloat(r[1]):_),e}var I={name:"web",animate:function(t){var r=t.keyframes,a=t.prop,e=t.from,n=t.to,i=t.target,o=n-e,u=O(function(){var t=r.map(function(t){var e,r=t.offset,n=t.value,i=t.easing
return(e={offset:r})[a]=n,e.easing=i,e}),e=i.animate(t,{duration:o,fill:"both"})
return e.pause(),e})
return{cancel:function(){u().cancel()},update:function(t,e,r){var n=u(),i=o*t
if(1<v(n.currentTime-i)&&(n.currentTime=i),r&&n.playbackRate!==e){var a=n.currentTime
a<1?n.currentTime=1:a<o-1||(n.currentTime=o-1),n.playbackRate=e}r&&!(n.playState===y||"finish"===n.playState)&&!(e<0&&i<C)&&!(0<=e&&o-C<i)&&n.play(),!r&&(n.playState===y||"pending"===n.playState)&&n.pause()}}},getValue:function(t,e){return getComputedStyle(t)[e]},onWillAnimate:function(t,e,r){c(t.target)&&(function(t){for(var e in t)if(j(F,e)){var r=t[e]
for(var n in r){var i=r[n]
R(i)&&x(i.value)&&(i.value+=A)}}}(e),function(t,i,e){var a=t.propNames.filter(function(t){return j(E,t)})
if(a.length){if(j(t.propNames,z))throw new Error("transform + shorthand is not allowed")
var r=[],o={}
Z(a,function(t){var e=i[t]
e&&Z(e,function(t){o[t.offset]=t.easing,V(r,t.offset)})}),r.sort()
for(var n=r.map(function(r){var n={}
return Z(a,function(t){var e=q(i[t],function(t){return t.offset===r})
n[t]=e?e.value:_}),{offset:r,easing:o[r],values:n}}),u=n.length,f=u-1;-1<f;--f){var s=n[f]
for(var c in s.values)if(!R(s.values[c])){for(var l=_,v=f-1;-1<v;v--)if(R(n[v].values[c])){l=v
break}for(var p=_,d=f+1;d<u;d++)if(R(n[d].values[c])){p=d
break}var g=l!==_
if(g&&p!==_)for(var m=n[l],h=n[p],y=D(m.values[c]),b=D(h.values[c]),w=l+1;w<p;w++){var k=(r[w]-m.offset)/(h.offset-m.offset),x=y.value+(b.value-y.value)*k+(b.unit||y.unit||"")
n[w].values[c]=x}else if(g)for(w=l+1;w<u;w++)n[w].values[c]=n[l].values[c]}}if(n.length){Z(a,function(t){i[t]=_})
var T=[]
Z(n,function(t){var e=_
for(var r in t.values){var n=D(t.values[r])
n.value!==_&&(n.unit||(n.unit=j(L,r)?A:j(W,r)?M:""),e=(e?e+" ":"")+(B[r]||r)+"("+n.value+n.unit+")")}T.push({offset:t.offset,value:e,easing:t.easing,interpolate:_})}),i[z]=T,e[z]="web"}}}(t,e,r))}},X=function(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)},Y=function(){return X()+X()+X()+X()+X()+X()+X()+X()},$="append",J="cancel",K="destroy",Q="finish",tt="insert",et="pause",rt="play",nt="reverse",it="set",at="tick",ot="update",ut="rate",ft="time",st=requestAnimationFrame,ct=cancelAnimationFrame,lt=function(){return performance.now()},vt=[],pt=_,dt=_
function gt(){ct(pt),pt=dt=_}function mt(){var t=vt.length
if(dt=dt||lt(),t){var e=lt(),r=e-dt
dt=e,pt=st(mt)
for(var n=t-1;-1<n;n--){var i=vt[n]
It(at,i,r)}}else gt()}function ht(t){P(vt,t),vt.length||gt()}var yt=function(t,e,r){Z(t.players,function(t){return t.cancel()}),t.state=u,t.time=_,t.round=_,t.players=_,ht(t.id),r.trigger(J)},bt=function(t,e,r){yt(t,0,r),r.destroyed=!0},wt=0,kt=/\[object ([a-z]+)\]/i
function xt(t,e){for(var r in t)if(t[r]===e)return r
var n=function(t){var e=t.id||t.name
if(!e){e=Object.prototype.toString.call(t)
var r=kt.exec(e)
r&&(e=r[1])}return"@"+e+"_"+ ++wt}(e)
return t[n]=e,n}function Tt(t){return s(t)?Array.prototype.slice.call(document.querySelectorAll(t)):k(t)?Tt(t()):w(t)?U(t,Tt):p(t)?[t]:[]}function Rt(){var r={}
return Z(arguments,function(t){for(var e in t)T(t,e)&&(r[e]=t[e])}),r}function St(t,e,r,n){return k(t)?St(t(e,r,n),e,r,n):t}var At=G("offset")
function Mt(t){var e
Z(t,function(t){t.value!==_?e=t.value:t.value=e})}function zt(t){for(var e,r=t.length-1;-1<r;r--){var n=t[r]
n.interpolate!==_?e=n.interpolate:n.interpolate=e}}function Wt(t,e,r,n,i){var a=q(e,function(t){return 0===t.offset})
if(a===_||a.value===_){var o=n.getValue(r,i)
a===_?e.splice(0,0,{offset:0,value:o,easing:t.easing,interpolate:_}):(a.value=o,a.easing=t.easing,a.interpolate=_)}}function Lt(t,e){var r=q(e,function(t){return 1===t.offset},!0)
if(r===_||r.value===_){var n=e[e.length-1].value
r===_?N(e,{offset:1,value:n,easing:t.easing,interpolate:_}):(r.value=n,r.easing=r.easing||t.easing)}}function Et(n){var t
n.players=[],Z(n.configs,function(t){return e=t,void Z((v=function e(r,t,n){if(!R(t)||x(t)||k(t))return t
if(s(t)){var i=t
return T(r,i)&&"@"===i.charAt(0)?r[i]:i}if(w(t)){var a=[]
return Z(t,function(t){return N(a,e(r,t,n))}),a}if(!n||c(t))return t
var o={}
for(var u in t)if(T(t,u)){var f=t[u]
o[u]=n?e(r,f,"targets"!==u):f}return o}((r=n).refs,e,!0),p=v.keyframes,d=v.from,g=v.to,m=v.stagger||0,h=v.duration,y=[],Z(Tt(v.target),function(u,t,f){var s={},c={}
for(var e in Z(p,function(t){var e=s[t.prop]||(s[t.prop]=[]),r=(t.time-d)/(h||1),n=t.easing,i=t.interpolate,a=St(t.value,u,t.index,f)
c[t.prop]=t.plugin
var o=q(e,function(t){return t.offset===r})||N(e,{easing:n,offset:r,value:a,interpolate:i})
o.easing=n,o.value=a,o.interpolate=i}),b){var r=b[e]
if(r.onWillAnimate&&v.keyframes.some(function(t){return t.plugin===e})){var n=Rt(v,{target:u})
r.onWillAnimate(n,s,c)}}for(var i in s){var a=s[i],o=c[i],l=b[o]
a&&(a.sort(At),Wt(v,a,u,l,i),Mt(a),zt(a),Lt(v,a),N(y,{plugin:c[i],target:u,prop:i,from:d+(m?m*t:0),to:g+(m?m*t:0),keyframes:a}))}}),y),function(t){var e=b[t.plugin].animate(t)
e&&(e.from=t.from,e.to=t.to,N(r.players,e))})
var r,e,v,p,d,g,m,h,y}),(t=n).duration=h.apply(_,t.players.filter(function(t){return isFinite(t.to)}).map(function(t){return t.to})),t.time=isFinite(t.time)?t.time:t.rate<0?t.duration:0}var Bt=function(o,t,e){o.players===_&&Et(o)
var u=o.state===l,f=o.time
u||ht(o.id),Z(o.players,function(t){var e,r=t.from,n=t.to,i=u&&m(d(f),r,n),a=(e=1,g(h((f-r)/(n-r),0),e))
t.update(a,o.rate,i)}),e.trigger(ot)},Ft=function(t,e,r){t.round=0,t.state=f,t.yoyo||(t.time=t.rate<0?0:t.duration),ht(t.id),Bt(t,0,r),r.trigger(Q),t.destroy&&bt(t,0,r)},Ot=function(t,e,r){t.state=f,ht(t.id),Bt(t,0,r),r.trigger(et)},Ct=function(t,e,r){e&&(t.repeat=e.repeat,t.yoyo=!!e.alternate,t.destroy=!!e.destroy),t.repeat=t.repeat||1,t.yoyo=t.yoyo||!1,t.state=l
var n,i=0<=t.rate
i&&t.time===t.duration?t.time=0:i||0!==t.time||(t.time=t.duration),n=t.id,j(vt,n)||N(vt,n),pt||(pt=st(mt)),Bt(t,0,r),r.trigger(rt)},jt=function(t){for(var e=0,r=0,n=t.configs,i=0,a=n.length;i<a;i++){var o=n[i],u=o.keyframes.map(function(t){return t.time}),f=h.apply(_,u),s=g.apply(_,u)
o.to=f,o.from=s,o.duration=f-s,e=h(f,e),r=h(f+o.endDelay,r)}t.cursor=r,t.duration=e},qt=G("time"),Pt=function(a,t,o){Z(t,function(i){if(i.to===_)throw new Error("missing duration")
Z((i=function e(r,t,n){if(!R(t)||s(t)||x(t))return t
if(w(t))return U(t,function(t){return e(r,t,n)})
if(k(t))return xt(r,t)
if(n){for(var i in t)T(t,i)&&(t[i]=e(r,t[i],n&&"targets"!==i))
return t}return xt(r,t)}(a.refs,i,!0)).targets,function(t,e,r){var n=function(t,e,r,n,i){var a="ease",o=St(i.delay,e,r,n)||0,u=q(t.configs,function(t){return t.target===e})||N(t.configs,{from:h(i.from+o,0),to:h(i.to+o,0),easing:i.easing||a,duration:i.to-i.from,endDelay:St(i.endDelay,e,r,n)||0,stagger:i.stagger||0,target:e,targetLength:n,propNames:[],keyframes:[]}),f=i.stagger&&i.stagger*(r+1)||0,s=St(i.delay,u,r,u.targetLength)||0,c=h(f+s+i.from,0),l=i.to-i.from,v=i.easing||a
for(var p in b)if(T(i,p)){var d=i[p]
for(var g in d){var m=d[g]
T(d,g)&&R(m)&&Gt(u,p,r,g,m,l,c,v)}}return u.keyframes.sort(qt),u}(a,t,e,r,i)
o.dirty(n)})}),jt(a),o.trigger(r)}
function Gt(s,i,c,a,t,o,u,l){var v,e
if(!w(t)&&p(t)){var r=t
r.easing&&(l=r.easing),r.interpolate&&(v=r.interpolate),e=H(r.value)}else e=H(t)
var n=e.map(function(t,e,r){var n=St(t,s.target,c,s.targetLength),i=n,a=p(n),o=a?i.value:n,u=a&&x(i.offset)?i.offset:e===r.length-1?1:0===e?0:_,f=i&&i.interpolate||v
return{offset:u,value:o,easing:i&&i.easing||l,interpolate:f}})
!function(t){if(!t.length)return
var e=q(t,function(t){return 0===t.offset})||t[0]
R(e.offset)||(e.offset=0)
var r=q(t,function(t){return 1===t.offset},!0)||t[t.length-1]
1<t.length&&!R(r.offset)&&(r.offset=1)
for(var n=1,i=t.length;n<i;n++){var a=t[n]
if(!R(a.offset))for(var o=n+1;o<i;o++){var u=t[o].offset
if(R(u)){for(var f=t[n-1].offset,s=u-f,c=o-n+1,l=1;l<c;l++)t[l-1+n].offset=l/o*s+f
n=o
break}}}}(n),Z(n,function(t){var e=t.offset,r=t.value,n=d(o*e+u);(q(s.keyframes,function(t){return t.prop===a&&t.time===n})||N(s.keyframes,{plugin:i,easing:t.easing,index:c,prop:a,time:n,value:r,interpolate:t.interpolate})).value=r}),q(s.keyframes,function(t){return t.prop===a&&t.time===u})||N(s.keyframes,{plugin:i,easing:l,index:c,prop:a,time:u,value:_,interpolate:v})
var f=u+o
q(s.keyframes,function(t){return t.prop===a&&t.time===f},!0)||N(s.keyframes,{plugin:i,easing:l,index:c,prop:a,time:f,value:_,interpolate:v}),V(s.propNames,a)}var Ht
var Nt=[],Vt={},Ut=((Ht={})[$]=function(t,e,r){var f=t.cursor,n=H(e).map(function(t){var e=t.to,r=t.from,n=t.duration,i=R(e),a=R(r),o=R(n),u=t
return u.to=i&&(a||o)?e:o&&a?r+n:i&&!o?f+e:o?f+n:_,u.from=a&&(i||o)?r:i&&o?e-n:i||o?f:_,u})
Pt(t,n,r)},Ht[J]=yt,Ht[K]=bt,Ht[Q]=Ft,Ht[tt]=Pt,Ht[et]=Ot,Ht[rt]=Ct,Ht[nt]=function(t,e,r){t.rate*=-1,Bt(t,0,r),r.trigger(nt)},Ht[it]=function(f,t,e){var s=Object.keys(b),r=H(t).map(function(t){var e=t.at||f.cursor,r={}
for(var n in t)if(j(s,n)){var i=t[n],a={}
for(var o in i){var u=i[o]
a[o]=[_,u]}r[n]=a}else r[n]=t[n]
return r.from=e-1e-9,r.to=e,r})
Pt(f,r,e)},Ht[at]=function(t,e,r){var n=t.duration,i=t.repeat,a=t.rate,o=t.time===_?a<0?n:0:t.time,u=t.round||0,f=a<0,s=!1
m(o+=e*a,0,n)||(t.round=++u,o=f?0:n,s=!0,t.yoyo&&(t.rate=-1*(t.rate||0)),o=t.rate<0?n:0),t.time=o,t.round=u,s&&i===u?Ft(t,0,r):Bt(t,0,r)},Ht[ot]=Bt,Ht[ut]=function(t,e,r){t.rate=e||1,Bt(t,0,r)},Ht[ft]=function(t,e,r){var n=+e
t.time=isFinite(n)?n:t.rate<0?t.duration:0,Bt(t,0,r)},Ht)
function Zt(t){var e=Vt[t]
if(!e)throw new Error("not found")
return e.state}function Dt(t){Vt[t.id]={state:function(t){var e={}
if(t.references)for(var r in t.references)e["@"+r]=t.references[r]
return{configs:[],cursor:0,duration:0,id:t.id,players:_,rate:1,refs:e,repeat:_,round:_,state:u,time:_,yoyo:!1}}(t),subs:{}}}function It(t,e,r){var n=Ut[t],i=Vt[e]
if(!n||!i)throw new Error("not found")
var a={events:[],needUpdate:[],trigger:Xt,dirty:Yt},o=i.state
n(o,r,a),Z(a.events,function(t){var e=i.subs[t]
e&&Z(e,function(t){t(o.time)})}),a.destroyed?delete Vt[e]:a.needUpdate.length&&(o.state!==u?function(t,e){var r=t.state
switch(Z(t.players,function(t){return t.cancel()}),t.players=_,r){case f:Ot(t,_,e)
break
case l:Ct(t,_,e)}}(o,a):jt(o),Z(Nt,function(t){t(i)}))}function Xt(t){V(this.events,t)}function Yt(t){V(this.needUpdate,t)}"undefined"!=typeof window&&(window.just_devtools={dispatch:It,subscribe:function(t){V(Nt,t)},unsubscribe:function(t){P(Nt,t)}})
var $t={get state(){return Zt(this.id).state},get duration(){return Zt(this.id).duration},get currentTime(){return Zt(this.id).time},set currentTime(t){It(ft,this.id,t)},get playbackRate(){return Zt(this.id).rate},set playbackRate(t){It(ut,this.id,t)},add:function(t){return It($,this.id,t),this},animate:function(t){return It($,this.id,t),this},fromTo:function(e,r,t){return Z(t,function(t){t.to=r,t.from=e}),It(tt,this.id,t),this},cancel:function(){return It(J,this.id),this},destroy:function(){It(K,this.id)},finish:function(){return It(Q,this.id),this},on:function(t,e){var r,n,i,a
return r=this.id,n=t,i=e,(a=Vt[r])&&V(a.subs[n]=a.subs[n]||[],i),this},once:function(r,n){var i=this
return i.on(r,function t(e){i.off(r,t),n(e)}),i},off:function(t,e){var r,n,i,a
return r=this.id,n=t,i=e,(a=Vt[r])&&P(a.subs[n],i),this},pause:function(){return It(et,this.id),this},play:function(t){return It(rt,this.id,t),this},reverse:function(){return It(nt,this.id),this},seek:function(t){return It(ft,this.id,t),this},sequence:function(t){var e=this
return Z(t,function(t){return It($,e.id,t)}),this},set:function(t){return It(it,this.id,t),this}}
function _t(t){var e=Object.create($t)
return(t=t||{}).id=t.id||Y(),e.id=t.id,Dt(t),e}Math.PI
var Jt=1e-4,Kt="cubic-bezier",Qt="steps",te=function(t,e,r){return 3*t*(1-r)*(1-r)*r+3*e*(1-r)*r*r+r*r*r},ee=/([a-z])[- ]([a-z])/gi,re=/^([a-z-]+)\(([^\)]+)\)$/i,ne={ease:Kt+"(.25,.1,.25,1)",easeIn:Kt+"(.42,0,1,1)",easeOut:Kt+"(0,0,.58,1)",easeInOut:Kt+"(.42,0,.58,1)",stepStart:Qt+"(1,1)",stepEnd:Qt+"(1,0)",linear:Kt+"(0,0,1,1)"},ie=function(t,e,r){return e+r.toUpperCase()},ae=function(t){var e,r="string"==typeof(e=t)?e.replace(ee,ie):"",n=ne[r]||t,i=re.exec(n)
if(!i)throw new Error("css parse error")
return[i[1]].concat(i[2].split(","))},oe=Math.abs
var ue=O(function(t){var e,r,n,i,o,u,f,s,a=ae(t),c=a[0]
if("steps"===c)return e=+a[1],r=a[2],n=e/1,i="end"===r?0:"start"===r?1:r||0,function(t){return t<1?i*n+t-(i*n+t)%n:1}
if("cubic-bezier"===c)return o=+a[1],u=+a[2],f=+a[3],s=+a[4],o<0||1<o||f<0||1<f?function(t){return t}:function(t){if(0===t||1===t)return t
var e=0,r=1,n=19
do{var i=.5*(e+r),a=te(o,f,i)
if(oe(t-a)<Jt)return te(u,s,i)
a<t?e=i:r=i}while(--n)
return t}
throw new Error("css parse error")}),fe=O(function(t){return O(t)})
function se(t,e,r){return t+(e-t)*r}function ce(t,e,r){return r<.5?t:e}var le=0,ve=1,pe=2,de=3,ge=/^\-\-[a-z0-9\-]+$/i,me="rx ry viewBox transform x x1 x2 y y1 y2".split(" "),he=["viewBox"]
function ye(t,e){return c(t)?ge.test(e)?de:"undefined"==typeof t[e]||j(me,e)?j(he,e)?ve:pe:le:le}function be(t,e){var r,n,i,a,o,u,f,s,c=ye(t,e)
return c===de?(f=t,s=e,function(){return f.style.getPropertyValue(s)}):c===ve?(o=t,u=e,function(){return o.getAttribute(u)}):c===pe?(i=t,a=S(e),function(){return i.getAttribute(a)}):(r=t,n=e,function(){return r[n]})}e({name:"props",animate:function(t){var s,c,l,e,r,n,i,a,o,u,f,v,p,d,g=t.target,m=t.prop,h=(s=t.to-t.from,c=t.keyframes,l=c.map(function(t){return t.offset*s}),Z(c,function(t){var e=!k(t.interpolate)
t.simpleFn=e,t.interpolate=e?x(t.value)?se:ce:fe(t.interpolate)}),function(t){var e=s*t,r=function(t,e){for(var r=t.length,n=0;n<r;n++)if(t[n]>e)return n
return r-1}(l,e),n=r?r-1:0,i=l[r],a=l[n],o=c[n],u=(e-a)/(i-a),f=o.easing?ue(o.easing)(u):u
return o.simpleFn?o.interpolate(o.value,c[r].value,f):o.interpolate(o.value,c[r].value)(f)}),y=(n=ye(e=g,r=m))===de?(p=e,d=r,function(t){return p.style.setProperty(d,t?t+"":"")}):n===ve?(f=e,v=r,function(t){return f.setAttribute(v,t)}):n===pe?(o=e,u=S(r),function(t){return o.setAttribute(u,t)}):(i=e,a=r,function(t){return i[a]=t}),b=be(g,m),w=_
return{cancel:function(){w!==_&&y(w),w=_},update:function(t,e,r){w===_&&(w=b()),y(h(t))}}},getValue:function(t,e){return be(t,e)()}})
var we=Math.random,ke=Math.floor
function xe(t){var e=document.createElement("div")
return e.setAttribute("style","display:inline-block;position:relative;text-align:start"),e.innerHTML=t||"",e}return e(I),t.animate=function(t){return _t().add(t)},t.sequence=function(t){return _t().sequence(t)},t.timeline=_t,t.addPlugin=e,t.removePlugin=function(t){delete b[t.name]},t.interpolate=se,t.random=function(t,e,r,n){var i=t+we()*(e-t)
return!0===n&&(i=ke(i)),r?i+r:i},t.shuffle=function(t){return t[Math.floor(Math.random()*t.length)]},t.splitText=function(t){for(var e=[],r=[],n="string"==typeof t?document.querySelectorAll(t):t instanceof Element?[t]:"number"==typeof t.length?t:[],i=0,a=n.length;i<a;i++){var o=n[i]
if(o){var u=o.textContent.replace(/[\r\n\s\t]+/gi," ").trim()
o.innerHTML=""
for(var f=u.split(/[\s]+/gi),s=0,c=f.length;s<c;s++){var l=f[s]
if(l){if(0<s){var v=xe(" ")
o.appendChild(v)}var p=xe()
r.push(p),o.appendChild(p)
for(var d=0,g=l.length;d<g;d++){var m=xe(l[d])
p.appendChild(m),e.push(m)}}}}}return{characters:e,words:r}},t}({})