UNPKG

@infinityfx/lively

Version:

Feature complete, lightweight react animation library.

3 lines (2 loc) 1.67 kB
import{__rest as t}from"tslib";import e from"./action.js";import{isLink as i}from"./link.js";import{normalizeAnimatableKeyframes as s,createDynamic as r,distributeAnimatableKeyframes as a,merge as n}from"./utils.js";class o{constructor(e,o){var{duration:h=1,delay:l=0,repeat:m=1,alternate:c=!1,easing:d="ease",reverse:y=!1,composite:p="none"}=e,f=t(e,["duration","delay","repeat","alternate","easing","reverse","composite"]);void 0===o&&(o={}),this.dynamic={};const u={};for(let t in f){let e=f[t],n=o[t];if(e instanceof Function){i(e)||(this.dynamic[t]=e);continue}const h=Array.isArray(e)?e:[e];h.length<2&&void 0!==n&&h.unshift(n),null===h[0]&&(void 0!==n?h[0]=n:h.splice(0,1)),s(h)&&("borderRadius"!==t?a(t,h,u):this.dynamic[t]=r(t,Object.values(a(t,h)),d))}this.keyframes=Object.values(u),this.initial=n({},o,this.keyframes.length?this.keyframes[0]:{}),delete this.initial.offset,this.isEmpty=!this.keyframes.length&&!Object.keys(this.dynamic).length,this.duration=this.isEmpty?0:h,this.delay=l,this.repeat=m,this.alternate=c,this.easing=d,this.reverse=y,this.composite=p}static from(t,e){return t instanceof o?t:new o(t||{},e)}unique(t){const e=new o({});for(const i in this)this.hasOwnProperty(i)&&(e[i]=i in t?t[i]:this[i]);return e}play(t,{composite:i=this.composite,reverse:s=this.reverse,commit:r=!0,delay:a=0}){if(this.isEmpty)return;const n=new e(t,this.keyframes,{duration:1e3*this.duration,delay:1e3*(a+this.delay),iterations:this.repeat,direction:this.alternate?s?"alternate-reverse":"alternate":s?"reverse":"normal",fill:"both",easing:this.easing,composite:i},this.dynamic);n.commit=r,t.push(n)}}export{o as default}; //# sourceMappingURL=clip.js.map