UNPKG

@infinityfx/lively

Version:

Feature complete, lightweight react animation library.

3 lines (2 loc) 1.58 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,e)=>(Math.sign(t)||1)*Math.max(Math.abs(t),e),s=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 i(t,e,n={}){const o=(e,o)=>{const r=1e4*e,i="strokeLength"===t;r in n||(n[r]={offset:e}),n[r][i?"strokeDashoffset":t]=i?s(o):o};for(let t=0;t<e.length;t++){let{offset:n,value:s,after:r}=e[t];void 0!==s&&(void 0!==r&&1===n&&(n-=1e-4),o(n,s)),void 0!==r&&(n=Math.min(n+1e-4,1),o(n,r))}return n}function c(t){let e,n=0;for(let o=0;o<t.length;o++){let s=t[o],r=t.length<2?1:Math.round(o/(t.length-1)*1e4)/1e4;0===o&&(e=s),s&&"object"==typeof s?"offset"in s||(s.offset=r):(s===e&&n++,t[o]={offset:r,value:null!==s?s:void 0})}return n<2||n!==t.length}function f(t,e,n){return function(o){const s=this.element.animate(e,{duration:1e3,fill:"forwards",easing:n});s.currentTime=1e3*o;const r=getComputedStyle(this.element)[t];return s.cancel(),r}}export{r as IndexedMap,n as combineRefs,f as createDynamic,i as distributeAnimatableKeyframes,s as lengthToOffset,o as limitSmallestQuantity,t as merge,c as normalizeAnimatableKeyframes,e as pick}; //# sourceMappingURL=utils.js.map