UNPKG

@infinityfx/lively

Version:

Feature complete, lightweight react animation library.

3 lines (2 loc) 1.5 kB
function t(...t){for(let e=1;e<t.length;e++)for(const n in t[e])n in t[0]&&void 0!==t[0][n]||(t[0][n]=t[e][n]);return t[0]}function e(t,e){const n={};for(const o of e)n[o]=t[o];return n}function n(...t){return e=>{t.forEach((t=>{t&&"current"in t&&(t.current=e),t instanceof Function&&t(e)}))}}const o=t=>1-parseFloat(t.toString());class r extends Map{constructor(){super(...arguments),this.stack=[]}set(t,e){return this.stack.push(e),super.set(t,e)}delete(t){const e=this.stack.indexOf(this.get(t));return e>=0&&this.stack.splice(e,1),super.delete(t)}}function s(t,e,n={}){const r=(e,r)=>{const s=1e4*e,i="strokeLength"===t;s in n||(n[s]={offset:e}),n[s][i?"strokeDashoffset":t]=i?o(r):r};for(let t=0;t<e.length;t++){let{offset:n,value:o,after:s}=e[t];void 0!==o&&(void 0!==s&&1===n&&(n-=1e-4),r(n,o)),void 0!==s&&(n=Math.min(n+1e-4,1),r(n,s))}return n}function i(t){let e,n=0;for(let o=0;o<t.length;o++){let r=t[o],s=t.length<2?1:Math.round(o/(t.length-1)*1e4)/1e4;0===o&&(e=r),r&&"object"==typeof r?"offset"in r||(r.offset=s):(r===e&&n++,t[o]={offset:s,value:null!==r?r:void 0})}return n<2||n!==t.length}function c(t,e,n){return function(o){const r=this.element.animate(e,{duration:1e3,fill:"forwards",easing:n});r.currentTime=1e3*o;const s=getComputedStyle(this.element)[t];return r.cancel(),s}}export{r as IndexedMap,n as combineRefs,c as createDynamic,s as distributeAnimatableKeyframes,o as lengthToOffset,t as merge,i as normalizeAnimatableKeyframes,e as pick}; //# sourceMappingURL=utils.js.map