@motionone/dom
Advanced tools
Comparing version 10.16.3 to 10.16.4
@@ -26,3 +26,3 @@ 'use strict'; | ||
to, | ||
velocity, restSpeed: isScale ? 0.05 : 2, restDistance: isScale ? 0.01 : 0.5 }, options))); | ||
velocity }, options))); | ||
} | ||
@@ -29,0 +29,0 @@ return generatorCache.get(key); |
@@ -22,3 +22,3 @@ import { calcGeneratorVelocity, pregenerateKeyframes } from '@motionone/generators'; | ||
to, | ||
velocity, restSpeed: isScale ? 0.05 : 2, restDistance: isScale ? 0.01 : 0.5 }, options))); | ||
velocity }, options))); | ||
} | ||
@@ -25,0 +25,0 @@ return generatorCache.get(key); |
@@ -1,1 +0,1 @@ | ||
const t=t=>t,e=t=>"string"==typeof t,n=t=>t/1e3;function r(t,e,n){const r=Math.max(e-5,0);return a=n-t(r),(s=e-r)?a*(1e3/s):0;var a,s}const a=100,s=10,o=1;const i=["","X","Y","Z"],c={x:"translateX",y:"translateY",z:"translateZ"},u={syntax:"<angle>",initialValue:"0deg",toDefaultUnit:t=>t+"deg"},l={translate:{syntax:"<length-percentage>",initialValue:"0px",toDefaultUnit:t=>t+"px"},rotate:u,scale:{syntax:"<number>",initialValue:1,toDefaultUnit:t},skew:u},h=new Map,f=t=>`--motion-${t}`,g=["x","y","z"];["translate","scale","rotate","skew"].forEach((t=>{i.forEach((e=>{g.push(t+e),h.set(f(t+e),l[t])}))}));const d=new Set(g);function p(t){return c[t]&&(t=c[t]),e=t,d.has(e)?f(t):t;var e}function m(t){return(t=>"number"==typeof t)(t)&&!isNaN(t)}function v(t){return e(t)?parseFloat(t):t}const M=function(n){const a=new WeakMap;return(s={})=>{const o=new Map,i=(t=0,e=100,r=0,a=!1)=>{const i=`${t}-${e}-${r}-${a}`;return o.has(i)||o.set(i,n(Object.assign({from:t,to:e,velocity:r,restSpeed:a?.05:2,restDistance:a?.01:.5},s))),o.get(i)},c=(e,n)=>(a.has(e)||a.set(e,function(e,n=t){let r,a=10,s=e(0);const o=[n(s.current)];for(;!s.done&&a<1e4;)s=e(a),o.push(n(s.done?s.target:s.current)),void 0===r&&s.hasReachedTarget&&(r=a),a+=10;const i=a-10;return 1===o.length&&o.push(s.current),{keyframes:o,duration:i/1e3,overshootDuration:(null!=r?r:i)/1e3}}(e,n)),a.get(e));return{createAnimation:(n,a=!0,s,o,u)=>{let l,f,g,d=0,M=t;const x=n.length;if(a){M=function(n,r){var a;let s=(null==r?void 0:r.toDefaultUnit)||t;const o=n[n.length-1];if(e(o)){const t=(null===(a=o.match(/(-?[\d.]+)([a-z%]*)/))||void 0===a?void 0:a[2])||"";t&&(s=e=>e+t)}return s}(n,o?h.get(p(o)):void 0);if(g=v(n[x-1]),x>1&&null!==n[0])f=v(n[0]);else{const t=null==u?void 0:u.generator;if(t){const{animation:e,generatorStartTime:n}=u,a=(null==e?void 0:e.startTime)||n||0,s=(null==e?void 0:e.currentTime)||performance.now()-a,o=t(s).current;f=o,d=r((e=>t(e).current),s,o)}else s&&(f=v(s()))}}if(m(f)&&m(g)){const t=i(f,g,d,null==o?void 0:o.includes("scale"));l=Object.assign(Object.assign({},c(t,M)),{easing:"linear"}),u&&(u.generator=t,u.generatorStartTime=performance.now())}if(!l){l={easing:"ease",duration:c(i(0,100)).overshootDuration}}return l}}}}((({stiffness:t=a,damping:e=s,mass:i=o,from:c=0,to:u=1,velocity:l=0,restSpeed:h=2,restDistance:f=.5}={})=>{l=l?n(l):0;const g={done:!1,hasReachedTarget:!1,current:c,target:u},d=u-c,p=Math.sqrt(t/i)/1e3,m=((t=a,e=s,n=o)=>e/(2*Math.sqrt(t*n)))(t,e,i);let v;if(m<1){const t=p*Math.sqrt(1-m*m);v=e=>u-Math.exp(-m*p*e)*((m*p*d-l)/t*Math.sin(t*e)+d*Math.cos(t*e))}else v=t=>u-Math.exp(-p*t)*(d+(p*d-l)*t);return t=>{g.current=v(t);const e=0===t?l:r(v,t,g.current),n=Math.abs(e)<=h,a=Math.abs(u-g.current)<=f;var s,o,i;return g.done=n&&a,g.hasReachedTarget=(s=c,o=u,i=g.current,s<o&&i>=o||s>o&&i<=o),g}}));export{M as spring}; | ||
const t=t=>t,e=t=>"string"==typeof t,n=t=>t/1e3;function a(t,e,n){const a=Math.max(e-5,0);return r=n-t(a),(o=e-a)?r*(1e3/o):0;var r,o}const r=100,o=10,s=1;const i=["","X","Y","Z"],c={x:"translateX",y:"translateY",z:"translateZ"},u={syntax:"<angle>",initialValue:"0deg",toDefaultUnit:t=>t+"deg"},l={translate:{syntax:"<length-percentage>",initialValue:"0px",toDefaultUnit:t=>t+"px"},rotate:u,scale:{syntax:"<number>",initialValue:1,toDefaultUnit:t},skew:u},h=new Map,f=t=>`--motion-${t}`,g=["x","y","z"];["translate","scale","rotate","skew"].forEach((t=>{i.forEach((e=>{g.push(t+e),h.set(f(t+e),l[t])}))}));const d=new Set(g);function p(t){return c[t]&&(t=c[t]),e=t,d.has(e)?f(t):t;var e}function m(t){return(t=>"number"==typeof t)(t)&&!isNaN(t)}function v(t){return e(t)?parseFloat(t):t}const M=function(n){const r=new WeakMap;return(o={})=>{const s=new Map,i=(t=0,e=100,a=0,r=!1)=>{const i=`${t}-${e}-${a}-${r}`;return s.has(i)||s.set(i,n(Object.assign({from:t,to:e,velocity:a},o))),s.get(i)},c=(e,n)=>(r.has(e)||r.set(e,function(e,n=t){let a,r=10,o=e(0);const s=[n(o.current)];for(;!o.done&&r<1e4;)o=e(r),s.push(n(o.done?o.target:o.current)),void 0===a&&o.hasReachedTarget&&(a=r),r+=10;const i=r-10;return 1===s.length&&s.push(o.current),{keyframes:s,duration:i/1e3,overshootDuration:(null!=a?a:i)/1e3}}(e,n)),r.get(e));return{createAnimation:(n,r=!0,o,s,u)=>{let l,f,g,d=0,M=t;const x=n.length;if(r){M=function(n,a){var r;let o=(null==a?void 0:a.toDefaultUnit)||t;const s=n[n.length-1];if(e(s)){const t=(null===(r=s.match(/(-?[\d.]+)([a-z%]*)/))||void 0===r?void 0:r[2])||"";t&&(o=e=>e+t)}return o}(n,s?h.get(p(s)):void 0);if(g=v(n[x-1]),x>1&&null!==n[0])f=v(n[0]);else{const t=null==u?void 0:u.generator;if(t){const{animation:e,generatorStartTime:n}=u,r=(null==e?void 0:e.startTime)||n||0,o=(null==e?void 0:e.currentTime)||performance.now()-r,s=t(o).current;f=s,d=a((e=>t(e).current),o,s)}else o&&(f=v(o()))}}if(m(f)&&m(g)){const t=i(f,g,d,null==s?void 0:s.includes("scale"));l=Object.assign(Object.assign({},c(t,M)),{easing:"linear"}),u&&(u.generator=t,u.generatorStartTime=performance.now())}if(!l){l={easing:"ease",duration:c(i(0,100)).overshootDuration}}return l}}}}((({stiffness:t=r,damping:e=o,mass:i=s,from:c=0,to:u=1,velocity:l=0,restSpeed:h,restDistance:f}={})=>{l=l?n(l):0;const g={done:!1,hasReachedTarget:!1,current:c,target:u},d=u-c,p=Math.sqrt(t/i)/1e3,m=((t=r,e=o,n=s)=>e/(2*Math.sqrt(t*n)))(t,e,i),v=Math.abs(d)<5;let M;if(h||(h=v?.01:2),f||(f=v?.005:.5),m<1){const t=p*Math.sqrt(1-m*m);M=e=>u-Math.exp(-m*p*e)*((m*p*d-l)/t*Math.sin(t*e)+d*Math.cos(t*e))}else M=t=>u-Math.exp(-p*t)*(d+(p*d-l)*t);return t=>{g.current=M(t);const e=0===t?l:a(M,t,g.current),n=Math.abs(e)<=h,r=Math.abs(u-g.current)<=f;var o,s,i;return g.done=n&&r,g.hasReachedTarget=(o=c,s=u,i=g.current,o<s&&i>=s||o>s&&i<=s),g}}));export{M as spring}; |
@@ -22,3 +22,3 @@ import { pregenerateKeyframes } from "@motionone/generators"; | ||
to, | ||
velocity, restSpeed: isScale ? 0.05 : 2, restDistance: isScale ? 0.01 : 0.5 }, options))); | ||
velocity }, options))); | ||
} | ||
@@ -25,0 +25,0 @@ return generatorCache.get(key); |
{ | ||
"name": "@motionone/dom", | ||
"version": "10.16.3", | ||
"version": "10.16.4", | ||
"description": "A tiny, performant animation library for the DOM", | ||
@@ -19,3 +19,3 @@ "license": "MIT", | ||
"@motionone/animation": "^10.16.3", | ||
"@motionone/generators": "^10.16.3", | ||
"@motionone/generators": "^10.16.4", | ||
"@motionone/types": "^10.16.3", | ||
@@ -60,3 +60,3 @@ "@motionone/utils": "^10.16.3", | ||
], | ||
"gitHead": "f4721014f749ce528145c09386af8584eced4e2a" | ||
"gitHead": "1b73773be02af31fedb8ac4b5d391650d06f4094" | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8518
481113