motion 10.6.0-rc.5 → 10.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  Motion One adheres to [Semantic Versioning](http://semver.org/).
4
4
 
5
+ ## [10.6.2] [2022-02-08]
6
+
7
+ ### Fixed
8
+
9
+ - Fixed velocity calculations of critically and overdamped animations.
10
+
11
+ ## [10.6.1] [2022-02-06]
12
+
13
+ ### Fixed
14
+
15
+ - Fixed velocity transfer of interrupted generated animations. [Issue (sponsors only)](https://github.com/motiondivision/motionone/issues/43)
16
+
5
17
  ## [10.6.0] [2022-01-22]
6
18
 
7
19
  ### Added
package/README.md CHANGED
@@ -0,0 +1,22 @@
1
+ # Motion One
2
+
3
+ A new animation library, built on the Web Animations API for the smallest filesize and the fastest performance.
4
+
5
+ ## 📚 Documentation
6
+
7
+ Full docs are available at [motion.dev](https://motion.dev).
8
+
9
+ ## 🙌 Sponsors
10
+
11
+ A huge thank you to all sponsors of this project, with a special shoutout to:
12
+
13
+ - [Victor Pontis](https://github.com/vpontis)
14
+ - [‹div›RIOTS](https://github.com/divriots)
15
+ - [Alex Frazer](https://github.com/AlexFrazer)
16
+ - [Derek Reynolds](https://github.com/derekr)
17
+ - [Martin Pitt](https://github.com/Martin-Pitt)
18
+ - [Mihael Konjević](https://github.com/retro)
19
+ - [impactvelocity](https://github.com/impactvelocity)
20
+ - [Namit Chadha](https://github.com/nc)
21
+
22
+ [Become a sponsor](https://github.com/sponsors/mattgperry) and get access to the private Motion One repo. File issues, read the changelog and source code, and join discussions that help shape the future of the API.
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Motion={})}(this,(function(t){"use strict";const e=new WeakMap;function n(t){return e.has(t)||e.set(t,{transforms:[],animations:{},generators:{},prevGeneratorState:{}}),e.get(t)}function a(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const i={duration:.3,delay:0,endDelay:0,repeat:0,easing:"ease"},r=t=>"number"==typeof t,s=t=>"object"==typeof t&&Boolean(t.createAnimation),o=t=>Array.isArray(t)&&!r(t[0]),c=(t,e,n)=>-n*t+n*e+t,l=()=>{},u=t=>t,h=(t,e,n)=>e-t==0?1:(n-t)/(e-t);function f(t,e){const n=t[t.length-1];for(let a=1;a<=e;a++){const i=h(0,e,a);t.push(c(n,1,i))}}function d(t){const e=[0];return f(e,t-1),e}const p=t=>1e3*t,m=t=>t/1e3;const y=["","X","Y","Z"],g={x:"translateX",y:"translateY",z:"translateZ"},v={syntax:"<angle>",initialValue:"0deg",toDefaultUnit:t=>t+"deg"},b={translate:{syntax:"<length-percentage>",initialValue:"0px",toDefaultUnit:t=>t+"px"},rotate:v,scale:{syntax:"<number>",initialValue:1,toDefaultUnit:u},skew:v},M=new Map,S=t=>`--motion-${t}`,x=["x","y","z"];["translate","scale","rotate","skew"].forEach((t=>{y.forEach((e=>{x.push(t+e),M.set(S(t+e),b[t])}))}));const T=(t,e)=>x.indexOf(t)-x.indexOf(e),w=new Set(x),O=t=>w.has(t),j=t=>t.sort(T).reduce(k,"").trim(),k=(t,e)=>`${t} ${e}(var(${S(e)}))`,A=t=>t.startsWith("--"),D=new Set;const P=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t;function R(t,e,n,a){if(t===e&&n===a)return u;const i=e=>function(t,e,n,a,i){let r,s,o=0;do{s=e+(n-e)/2,r=P(s,a,i)-t,r>0?n=s:e=s}while(Math.abs(r)>1e-7&&++o<12);return s}(e,0,1,t,n);return t=>0===t||1===t?t:P(i(t),e,a)}const $=(t,e="end")=>n=>{const a=(n="end"===e?Math.min(n,.999):Math.max(n,.001))*t,i="end"===e?Math.floor(a):Math.ceil(a);return r=0,s=1,o=i/t,Math.min(Math.max(o,r),s);var r,s,o},q={ease:R(.25,.1,.25,1),"ease-in":R(.42,0,1,1),"ease-in-out":R(.42,0,.58,1),"ease-out":R(0,0,.58,1)},E=/\((.*?)\)/;function V(t){if("function"==typeof t)return t;if(Array.isArray(t))return R(...t);if(q[t])return q[t];if(t.startsWith("steps")){const e=E.exec(t);if(e){const t=e[1].split(",");return $(parseFloat(t[0]),t[1].trim())}}return u}function F(t,e){return o(t)?t[((t,e,n)=>{const a=e-t;return((n-t)%a+a)%a+t})(0,t.length,e)]:t}function W(t,e=d(t.length),n=u){const a=t.length,i=a-e.length;return i>0&&f(e,i),i=>{let r=0;for(;r<a-2&&!(i<e[r+1]);r++);let s=(o=h(e[r],e[r+1],i),Math.min(1,Math.max(o,0)));var o;return s=F(n,r)(s),c(t[r],t[r+1],s)}}class U{constructor(t,e=[0,1],{easing:n=i.easing,duration:a=i.duration,delay:r=i.delay,endDelay:c=i.endDelay,repeat:l=i.repeat,offset:u,direction:h="normal"}={}){this.startTime=0,this.rate=1,this.t=0,this.cancelTimestamp=0,this.playState="idle",this.finished=new Promise(((t,e)=>{this.resolve=t,this.reject=e}));const f=a*(l+1);if(s(n)){const t=n.createAnimation(e,(()=>"0"),!0);n=t.easing,void 0!==t.keyframes&&(e=t.keyframes),void 0!==t.duration&&(a=t.duration)}const d=W(e,u,o(n)?n.map(V):V(n));this.tick=e=>{var n;this.pauseTime&&(e=this.pauseTime);let i=(e-this.startTime)*this.rate;this.t=i,i/=1e3,i=Math.max(i-r,0),"finished"===this.playState&&(i=f);const s=i/a;let o=Math.floor(s),l=s%1;!l&&s>=1&&(l=1),1===l&&o--;const u=o%2;("reverse"===h||"alternate"===h&&u||"alternate-reverse"===h&&!u)&&(l=1-l);const p=d(i>=f?1:Math.min(l,1));t(p);"finished"===this.playState||i>=f+c?(this.playState="finished",null===(n=this.resolve)||void 0===n||n.call(this,p)):"idle"!==this.playState&&(this.frameRequestId=requestAnimationFrame(this.tick))},this.play()}play(){const t=performance.now();this.playState="running",this.pauseTime?this.startTime=t-(this.pauseTime-this.startTime):this.startTime||(this.startTime=t),this.pauseTime=void 0,requestAnimationFrame(this.tick)}pause(){this.playState="paused",this.pauseTime=performance.now()}finish(){this.playState="finished",this.tick(0)}cancel(){var t;this.playState="idle",this.tick(this.cancelTimestamp),null===(t=this.reject)||void 0===t||t.call(this,!1),void 0!==this.frameRequestId&&cancelAnimationFrame(this.frameRequestId)}reverse(){this.rate*=-1}commitStyles(){this.cancelTimestamp=performance.now()}get currentTime(){return this.t}set currentTime(t){this.pauseTime||0===this.rate?this.pauseTime=t:this.startTime=performance.now()-t/this.rate}get playbackRate(){return this.rate}set playbackRate(t){this.rate=t}}const B=t=>(t=>Array.isArray(t)&&r(t[0]))(t)?C(t):t,C=([t,e,n,a])=>`cubic-bezier(${t}, ${e}, ${n}, ${a})`,I=t=>document.createElement("div").animate(t,{duration:.001}),z={cssRegisterProperty:()=>"undefined"!=typeof CSS&&Object.hasOwnProperty.call(CSS,"registerProperty"),waapi:()=>Object.hasOwnProperty.call(Element.prototype,"animate"),partialKeyframes:()=>{try{I({opacity:[1]})}catch(t){return!1}return!0},finished:()=>Boolean(I({opacity:[0,1]}).finished)},G={},K={};for(const t in z)K[t]=()=>(void 0===G[t]&&(G[t]=z[t]()),G[t]);const X=t=>Array.isArray(t)?t:[t];function Y(t){return g[t]&&(t=g[t]),O(t)?S(t):t}const Z={get:(t,e)=>{e=Y(e);let n=A(e)?t.style.getPropertyValue(e):getComputedStyle(t)[e];if(!n&&0!==n){const t=M.get(e);t&&(n=t.initialValue)}return n},set:(t,e,n)=>{e=Y(e),A(e)?t.style.setProperty(e,n):t.style[e]=n}};function _(t){if(t&&"finished"!==t.playState)try{t.commitStyles(),t.cancel()}catch(t){}}function H(t,e,a,c={}){let u,{duration:h=i.duration,delay:f=i.delay,endDelay:d=i.endDelay,repeat:m=i.repeat,easing:y=i.easing,direction:v,offset:b,allowWebkitAcceleration:S=!1}=c;const x=n(t);let T=K.waapi();const w=O(e);w&&((t,e)=>{g[e]&&(e=g[e]);const{transforms:a}=n(t);var i,r;r=e,-1===(i=a).indexOf(r)&&i.push(r),t.style.transform=j(a)})(t,e);const k=Y(e),P=M.get(k);return _(x.animations[k]),()=>{const e=()=>{var e,n;return null!==(n=null!==(e=Z.get(t,k))&&void 0!==e?e:null==P?void 0:P.initialValue)&&void 0!==n?n:0};let n=function(t,e){for(let n=0;n<t.length;n++)null===t[n]&&(t[n]=n?t[n-1]:e());return t}(X(a),e);if(s(y)){const t=y.createAnimation(n,e,w,k,x);y=t.easing,void 0!==t.keyframes&&(n=t.keyframes),void 0!==t.duration&&(h=t.duration)}if(A(k)&&(K.cssRegisterProperty()?function(t){if(!D.has(t)){D.add(t);try{const{syntax:e,initialValue:n}=M.has(t)?M.get(t):{};CSS.registerProperty({name:t,inherits:!1,syntax:e,initialValue:n})}catch(t){}}}(k):T=!1),T){P&&(n=n.map((t=>r(t)?P.toDefaultUnit(t):t))),K.partialKeyframes()||1!==n.length||n.unshift(e());const a={delay:p(f),duration:p(h),endDelay:p(d),easing:o(y)?void 0:B(y),direction:v,iterations:m+1,fill:"both"};u=t.animate({[k]:n,offset:b,easing:o(y)?y.map(B):void 0},a),u.finished||(u.finished=new Promise(((t,e)=>{u.onfinish=t,u.oncancel=e})));const i=n[n.length-1];u.finished.then((()=>{Z.set(t,k,i),u.cancel()})).catch(l),S||(u.playbackRate=1.000001)}else if(w&&n.every(r)){1===n.length&&n.unshift(parseFloat(e()));u=new U((e=>{P&&(e=P.toDefaultUnit(e)),Z.set(t,k,e)}),n,Object.assign(Object.assign({},c),{duration:h,easing:y}))}else{const e=n[n.length-1];Z.set(t,k,P&&r(e)?P.toDefaultUnit(e):e)}return x.animations[k]=u,null==u||u.finished.then((()=>{x.animations[k]=void 0,x.generators[k]=void 0,x.prevGeneratorState[k]=void 0})).catch(l),u}}const J=(t,e)=>t[e]?Object.assign(Object.assign({},t),t[e]):Object.assign({},t);function L(t,e){var n;return"string"==typeof t?e?(null!==(n=e[t])&&void 0!==n||(e[t]=document.querySelectorAll(t)),t=e[t]):t=document.querySelectorAll(t):t instanceof Element&&(t=[t]),Array.from(t)}const N=t=>t(),Q=(t,e=i.duration)=>new Proxy({animations:t.map(N).filter(Boolean),duration:e},et),tt=t=>t.animations[0],et={get:(t,e)=>{var n,a;switch(e){case"duration":return t.duration;case"currentTime":let i=(null===(n=tt(t))||void 0===n?void 0:n[e])||0;return i?i/1e3:0;case"playbackRate":return null===(a=tt(t))||void 0===a?void 0:a[e];case"finished":return t.finished||(t.finished=Promise.all(t.animations.map(nt)).catch(l)),t.finished;case"stop":return()=>t.animations.forEach(_);default:return()=>t.animations.forEach((t=>t[e]()))}},set:(t,e,n)=>{switch(e){case"currentTime":n=p(n);case"currentTime":case"playbackRate":for(let a=0;a<t.animations.length;a++)t.animations[a][e]=n;return!0}return!1}},nt=t=>t.finished;function at(t,e,n){return"function"==typeof t?t(e,n):t}function it(t,e,n={}){const a=(t=L(t)).length,i=[];for(let r=0;r<a;r++){const s=t[r];for(const t in e){const o=J(n,t);o.delay=at(o.delay,r,a);const c=H(s,t,e[t],o);i.push(c)}}return Q(i,n.duration)}function rt(t,e,n,a){var i;return r(e)?e:e.startsWith("-")||e.startsWith("+")?Math.max(0,t+parseFloat(e)):"<"===e?n:null!==(i=a.get(e))&&void 0!==i?i:t}function st(t,e,n,i,r,s){!function(t,e,n){for(let i=0;i<t.length;i++){const r=t[i];r.at>e&&r.at<n&&(a(t,r),i--)}}(t,r,s);for(let a=0;a<e.length;a++)t.push({value:e[a],at:c(r,s,i[a]),easing:F(n,a)})}function ot(t,e){return t.at===e.at?null===t.value?1:-1:t.at-e.at}function ct(t,e){return!e.has(t)&&e.set(t,{}),e.get(t)}function lt(t,e){return e[t]||(e[t]=[]),e[t]}function ut(t,e,n){const a=Math.max(e-5,0);return i=n-t(a),(r=5)?i*(1e3/r):0;var i,r}const ht=100,ft=10,dt=1;const pt=({stiffness:t=ht,damping:e=ft,mass:n=dt,from:a=0,to:i=1,velocity:r=0,restSpeed:s=2,restDistance:o=.5}={})=>{r=r?m(r):0;const c={done:!1,hasReachedTarget:!1,current:a,target:i,velocity:r},l=((t=ht,e=ft,n=dt)=>e/(2*Math.sqrt(t*n)))(t,e,n),u=i-a,h=Math.sqrt(t/n)/1e3,f=((t,e)=>t*Math.sqrt(1-e*e))(h,l);let d;return d=l<1?t=>i-Math.exp(-l*h*t)*((l*h*u-r)/f*Math.sin(f*t)+u*Math.cos(f*t)):t=>i-Math.exp(-h*t)*(u+(r+h*u)*t),t=>{c.current=d(t),c.velocity=0===t?r:ut(d,t,c.current);const e=Math.abs(c.velocity)<=s,n=Math.abs(i-c.current)<=o;var l,u,h;return c.done=e&&n,c.hasReachedTarget=(l=a,u=i,h=c.current,l<u&&h>=u||l>u&&h<=u),c}};function mt(t){const e=new WeakMap;return(n={})=>{const a=new Map,i=(e=0,i=100,r=0,s=!1)=>{const o=`${e}-${i}-${r}-${s}`;return a.has(o)||a.set(o,t(Object.assign({from:e,to:i,velocity:r,restSpeed:s?.05:2,restDistance:s?.01:.5},n))),a.get(o)},r=t=>(e.has(t)||e.set(t,function(t){let e,n=10,a=t(0);const i=[a.current];for(;!a.done&&n<1e4;)a=t(n),i.push(a.done?a.target:a.current),void 0===e&&a.hasReachedTarget&&(e=n),n+=10;const r=n-10;return 1===i.length&&i.push(a.current),{keyframes:i,duration:r/1e3,overshootDuration:(null!=e?e:r)/1e3}}(t)),e.get(t));return{createAnimation:(t,e,n,a,s)=>{let o,c;const l=t.length;if(n&&l<=2&&t.every(yt)){const n=a&&s&&s.prevGeneratorState[a],u=n&&(1===l||2===l&&null===t[0])?n.velocity:0,h=t[l-1],f=1===l?null:t[0],d=null===f?n?n.current:parseFloat(e()):f;c=i(d,h,u,null==a?void 0:a.includes("scale"));const p=r(c);o=Object.assign(Object.assign({},p),{easing:"linear"})}else{c=i(0,100);o={easing:"ease",duration:r(c).overshootDuration}}return s&&a&&(s.generators[a]=c),o}}}}const yt=t=>"string"!=typeof t,gt=mt(pt),vt=mt((({from:t=0,velocity:e=0,power:n=.8,decay:a=.325,bounceDamping:i,bounceStiffness:r,changeTarget:s,min:o,max:c,restDistance:l=.5,restSpeed:u})=>{a=p(a);const h={hasReachedTarget:!1,done:!1,current:t,target:t,velocity:e},f=t=>void 0===o?c:void 0===c||Math.abs(o-t)<Math.abs(c-t)?o:c;let d=n*e;const m=t+d,y=void 0===s?m:s(m);h.target=y,y!==m&&(d=y-t);const g=t=>-d*Math.exp(-t/a),v=t=>y+g(t),b=t=>{const n=g(t),a=v(t);h.done=Math.abs(n)<=l,h.current=h.done?y:a,h.velocity=0===t?e:ut(v,t,h.current)};let M,S;const x=t=>{var e;(e=h.current,void 0!==o&&e<o||void 0!==c&&e>c)&&(M=t,S=pt({from:h.current,to:f(h.current),velocity:h.velocity,damping:i,stiffness:r,restDistance:l,restSpeed:u}))};return x(0),t=>{let e=!1;return S||void 0!==M||(e=!0,b(t),x(t)),void 0!==M&&t>M?(h.hasReachedTarget=!0,S(t-M)):(h.hasReachedTarget=!1,!e&&b(t),h)}}));function bt(t,e){return Q([()=>{const n=new U(t,[0,1],e);return n.finished.catch((()=>{})),n}],null==e?void 0:e.duration)}t.animate=function(t,e,n){return("function"==typeof t?bt:it)(t,e,n)},t.glide=vt,t.spring=gt,t.stagger=function(t=.1,{start:e=0,from:n=0,easing:a}={}){return(i,s)=>{const o=r(n)?n:function(t,e){if("first"===t)return 0;{const n=e-1;return"last"===t?n:n/2}}(n,s),c=Math.abs(o-i);let l=t*c;if(a){const t=s*i;l=V(a)(l/t)*t}return e+l}},t.style=Z,t.timeline=function(t,e={}){var n;const a=function(t,e={}){var{defaultOptions:n={}}=e,a=function(t,e){var n={};for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&e.indexOf(a)<0&&(n[a]=t[a]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(a=Object.getOwnPropertySymbols(t);i<a.length;i++)e.indexOf(a[i])<0&&Object.prototype.propertyIsEnumerable.call(t,a[i])&&(n[a[i]]=t[a[i]])}return n}(e,["defaultOptions"]);const r=[],o=new Map,c={},l=new Map;let u=0,p=0,m=0;for(let e=0;e<t.length;e++){const[a,r,h={}]=t[e];void 0!==h.at&&(p=rt(p,h.at,u,l));let y=0;const g=L(a,c),v=g.length;for(let t=0;t<v;t++){const e=ct(g[t],o);for(const a in r){const o=lt(a,e);let c=X(r[a]);const l=J(h,a);let{duration:u=n.duration||i.duration,easing:g=n.easing||i.easing}=l;if(s(g)){const t=O(a);c.length;const e=g.createAnimation(c,(()=>"0"),t);g=e.easing,void 0!==e.keyframes&&(c=e.keyframes),void 0!==e.duration&&(u=e.duration)}const b=at(h.delay,t,v)||0,M=p+b,S=M+u;let{offset:x=d(c.length)}=l;1===x.length&&0===x[0]&&(x[1]=1);const T=length-c.length;T>0&&f(x,T),1===c.length&&c.unshift(null),st(o,c,g,x,M,S),y=Math.max(b+u,y),m=Math.max(S,m)}}u=p,p+=y}return o.forEach(((t,e)=>{for(const s in t){const o=t[s];o.sort(ot);const c=[],l=[],u=[];for(let t=0;t<o.length;t++){const{at:e,value:n,easing:a}=o[t];c.push(n),l.push(h(0,m,e)),u.push(a||i.easing)}0!==l[0]&&(l.unshift(0),c.unshift(c[0]),u.unshift("linear")),1!==l[l.length-1]&&(l.push(1),c.push(null)),r.push([e,s,c,Object.assign(Object.assign(Object.assign({},n),{duration:m,easing:u,offset:l}),a)])}})),r}(t,e),r=a.map((t=>H(...t))).filter(Boolean);return Q(r,null===(n=a[0])||void 0===n?void 0:n[3].duration)},Object.defineProperty(t,"__esModule",{value:!0})}));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Motion={})}(this,(function(t){"use strict";class e{setAnimation(t){this.animation=t,null==t||t.finished.then((()=>this.clearAnimation())).catch((()=>{}))}clearAnimation(){this.animation=this.generator=void 0}}const n=new WeakMap;function a(t){return n.has(t)||n.set(t,{transforms:[],values:new Map}),n.get(t)}function i(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const r={duration:.3,delay:0,endDelay:0,repeat:0,easing:"ease"},s=t=>"number"==typeof t,o=t=>"object"==typeof t&&Boolean(t.createAnimation),c=t=>Array.isArray(t)&&!s(t[0]),l=(t,e,n)=>-n*t+n*e+t,u=()=>{},h=t=>t,f=(t,e,n)=>e-t==0?1:(n-t)/(e-t);function d(t,e){const n=t[t.length-1];for(let a=1;a<=e;a++){const i=f(0,e,a);t.push(l(n,1,i))}}function m(t){const e=[0];return d(e,t-1),e}const p=t=>1e3*t,g=t=>t/1e3;const y=["","X","Y","Z"],v={x:"translateX",y:"translateY",z:"translateZ"},b={syntax:"<angle>",initialValue:"0deg",toDefaultUnit:t=>t+"deg"},M={translate:{syntax:"<length-percentage>",initialValue:"0px",toDefaultUnit:t=>t+"px"},rotate:b,scale:{syntax:"<number>",initialValue:1,toDefaultUnit:h},skew:b},T=new Map,w=t=>`--motion-${t}`,x=["x","y","z"];["translate","scale","rotate","skew"].forEach((t=>{y.forEach((e=>{x.push(t+e),T.set(w(t+e),M[t])}))}));const S=(t,e)=>x.indexOf(t)-x.indexOf(e),O=new Set(x),A=t=>O.has(t),j=t=>t.sort(S).reduce(k,"").trim(),k=(t,e)=>`${t} ${e}(var(${w(e)}))`,D=t=>t.startsWith("--"),P=new Set;const R=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t;function $(t,e,n,a){if(t===e&&n===a)return h;const i=e=>function(t,e,n,a,i){let r,s,o=0;do{s=e+(n-e)/2,r=R(s,a,i)-t,r>0?n=s:e=s}while(Math.abs(r)>1e-7&&++o<12);return s}(e,0,1,t,n);return t=>0===t||1===t?t:R(i(t),e,a)}const q=(t,e="end")=>n=>{const a=(n="end"===e?Math.min(n,.999):Math.max(n,.001))*t,i="end"===e?Math.floor(a):Math.ceil(a);return r=0,s=1,o=i/t,Math.min(Math.max(o,r),s);var r,s,o},E={ease:$(.25,.1,.25,1),"ease-in":$(.42,0,1,1),"ease-in-out":$(.42,0,.58,1),"ease-out":$(0,0,.58,1)},V=/\((.*?)\)/;function F(t){if("function"==typeof t)return t;if(Array.isArray(t))return $(...t);if(E[t])return E[t];if(t.startsWith("steps")){const e=V.exec(t);if(e){const t=e[1].split(",");return q(parseFloat(t[0]),t[1].trim())}}return h}function W(t,e){return c(t)?t[((t,e,n)=>{const a=e-t;return((n-t)%a+a)%a+t})(0,t.length,e)]:t}function U(t,e=m(t.length),n=h){const a=t.length,i=a-e.length;return i>0&&d(e,i),i=>{let r=0;for(;r<a-2&&!(i<e[r+1]);r++);let s=(o=f(e[r],e[r+1],i),Math.min(1,Math.max(o,0)));var o;return s=W(n,r)(s),l(t[r],t[r+1],s)}}class B{constructor(t,e=[0,1],{easing:n=r.easing,duration:a=r.duration,delay:i=r.delay,endDelay:s=r.endDelay,repeat:l=r.repeat,offset:u,direction:h="normal"}={}){if(this.startTime=null,this.rate=1,this.t=0,this.cancelTimestamp=null,this.playState="idle",this.finished=new Promise(((t,e)=>{this.resolve=t,this.reject=e})),o(n)){const t=n.createAnimation(e,(()=>"0"),!0);n=t.easing,void 0!==t.keyframes&&(e=t.keyframes),void 0!==t.duration&&(a=t.duration)}const f=a*(l+1),d=U(e,u,c(n)?n.map(F):F(n));this.tick=e=>{var n;this.pauseTime&&(e=this.pauseTime);let r=(e-this.startTime)*this.rate;this.t=r,r/=1e3,r=Math.max(r-i,0),"finished"===this.playState&&(r=f);const o=r/a;let c=Math.floor(o),l=o%1;!l&&o>=1&&(l=1),1===l&&c--;const u=c%2;("reverse"===h||"alternate"===h&&u||"alternate-reverse"===h&&!u)&&(l=1-l);const m=d(r>=f?1:Math.min(l,1));t(m);"finished"===this.playState||r>=f+s?(this.playState="finished",null===(n=this.resolve)||void 0===n||n.call(this,m)):"idle"!==this.playState&&(this.frameRequestId=requestAnimationFrame(this.tick))},this.play()}play(){var t;const e=performance.now();this.playState="running",this.pauseTime?this.startTime=e-(this.pauseTime-(null!==(t=this.startTime)&&void 0!==t?t:0)):this.startTime||(this.startTime=e),this.cancelTimestamp=this.startTime,this.pauseTime=void 0,requestAnimationFrame(this.tick)}pause(){this.playState="paused",this.pauseTime=performance.now()}finish(){this.playState="finished",this.tick(0)}stop(){var t;this.playState="idle",void 0!==this.frameRequestId&&cancelAnimationFrame(this.frameRequestId),null===(t=this.reject)||void 0===t||t.call(this,!1)}cancel(){this.stop(),this.tick(this.cancelTimestamp)}reverse(){this.rate*=-1}commitStyles(){}get currentTime(){return this.t}set currentTime(t){this.pauseTime||0===this.rate?this.pauseTime=t:this.startTime=performance.now()-t/this.rate}get playbackRate(){return this.rate}set playbackRate(t){this.rate=t}}const C=t=>(t=>Array.isArray(t)&&s(t[0]))(t)?I(t):t,I=([t,e,n,a])=>`cubic-bezier(${t}, ${e}, ${n}, ${a})`,z=t=>document.createElement("div").animate(t,{duration:.001}),K={cssRegisterProperty:()=>"undefined"!=typeof CSS&&Object.hasOwnProperty.call(CSS,"registerProperty"),waapi:()=>Object.hasOwnProperty.call(Element.prototype,"animate"),partialKeyframes:()=>{try{z({opacity:[1]})}catch(t){return!1}return!0},finished:()=>Boolean(z({opacity:[0,1]}).finished)},X={},Y={};for(const t in K)Y[t]=()=>(void 0===X[t]&&(X[t]=K[t]()),X[t]);const Z=t=>Array.isArray(t)?t:[t];function _(t){return v[t]&&(t=v[t]),A(t)?w(t):t}const G={get:(t,e)=>{e=_(e);let n=D(e)?t.style.getPropertyValue(e):getComputedStyle(t)[e];if(!n&&0!==n){const t=T.get(e);t&&(n=t.initialValue)}return n},set:(t,e,n)=>{e=_(e),D(e)?t.style.setProperty(e,n):t.style[e]=n}};function H(t,e=!0){if(t&&"finished"!==t.playState)try{t.stop?t.stop():(e&&t.commitStyles(),t.cancel())}catch(t){}}function J(t,n,i,l={}){let h,{duration:f=r.duration,delay:d=r.delay,endDelay:m=r.endDelay,repeat:g=r.repeat,easing:y=r.easing,direction:b,offset:M,allowWebkitAcceleration:w=!1}=l;const x=a(t);let S=Y.waapi();const O=A(n);O&&((t,e)=>{v[e]&&(e=v[e]);const{transforms:n}=a(t);var i,r;r=e,-1===(i=n).indexOf(r)&&i.push(r),t.style.transform=j(n)})(t,n);const k=_(n),R=function(t,n){return t.has(n)||t.set(n,new e),t.get(n)}(x.values,k),$=T.get(k);return H(R.animation,!(o(y)&&R.generator)),()=>{const e=()=>{var e,n;return null!==(n=null!==(e=G.get(t,k))&&void 0!==e?e:null==$?void 0:$.initialValue)&&void 0!==n?n:0};let n=function(t,e){for(let n=0;n<t.length;n++)null===t[n]&&(t[n]=n?t[n-1]:e());return t}(Z(i),e);if(o(y)){const t=y.createAnimation(n,e,O,k,R);y=t.easing,void 0!==t.keyframes&&(n=t.keyframes),void 0!==t.duration&&(f=t.duration)}if(D(k)&&(Y.cssRegisterProperty()?function(t){if(!P.has(t)){P.add(t);try{const{syntax:e,initialValue:n}=T.has(t)?T.get(t):{};CSS.registerProperty({name:t,inherits:!1,syntax:e,initialValue:n})}catch(t){}}}(k):S=!1),S){$&&(n=n.map((t=>s(t)?$.toDefaultUnit(t):t))),Y.partialKeyframes()||1!==n.length||n.unshift(e());const a={delay:p(d),duration:p(f),endDelay:p(m),easing:c(y)?void 0:C(y),direction:b,iterations:g+1,fill:"both"};h=t.animate({[k]:n,offset:M,easing:c(y)?y.map(C):void 0},a),h.finished||(h.finished=new Promise(((t,e)=>{h.onfinish=t,h.oncancel=e})));const i=n[n.length-1];h.finished.then((()=>{G.set(t,k,i),h.cancel()})).catch(u),w||(h.playbackRate=1.000001)}else if(O&&n.every(s)){1===n.length&&n.unshift(parseFloat(e()));h=new B((e=>{$&&(e=$.toDefaultUnit(e)),G.set(t,k,e)}),n,Object.assign(Object.assign({},l),{duration:f,easing:y}))}else{const e=n[n.length-1];G.set(t,k,$&&s(e)?$.toDefaultUnit(e):e)}return R.setAnimation(h),h}}const L=(t,e)=>t[e]?Object.assign(Object.assign({},t),t[e]):Object.assign({},t);function N(t,e){var n;return"string"==typeof t?e?(null!==(n=e[t])&&void 0!==n||(e[t]=document.querySelectorAll(t)),t=e[t]):t=document.querySelectorAll(t):t instanceof Element&&(t=[t]),Array.from(t)}const Q=t=>t(),tt=(t,e=r.duration)=>new Proxy({animations:t.map(Q).filter(Boolean),duration:e},nt),et=t=>t.animations[0],nt={get:(t,e)=>{var n,a;switch(e){case"duration":return t.duration;case"currentTime":let i=(null===(n=et(t))||void 0===n?void 0:n[e])||0;return i?i/1e3:0;case"playbackRate":return null===(a=et(t))||void 0===a?void 0:a[e];case"finished":return t.finished||(t.finished=Promise.all(t.animations.map(at)).catch(u)),t.finished;case"stop":return()=>t.animations.forEach((t=>H(t)));default:return()=>t.animations.forEach((t=>t[e]()))}},set:(t,e,n)=>{switch(e){case"currentTime":n=p(n);case"currentTime":case"playbackRate":for(let a=0;a<t.animations.length;a++)t.animations[a][e]=n;return!0}return!1}},at=t=>t.finished;function it(t,e,n){return"function"==typeof t?t(e,n):t}function rt(t,e,n={}){const a=(t=N(t)).length,i=[];for(let r=0;r<a;r++){const s=t[r];for(const t in e){const o=L(n,t);o.delay=it(o.delay,r,a);const c=J(s,t,e[t],o);i.push(c)}}return tt(i,n.duration)}function st(t,e,n,a){var i;return s(e)?e:e.startsWith("-")||e.startsWith("+")?Math.max(0,t+parseFloat(e)):"<"===e?n:null!==(i=a.get(e))&&void 0!==i?i:t}function ot(t,e,n,a,r,s){!function(t,e,n){for(let a=0;a<t.length;a++){const r=t[a];r.at>e&&r.at<n&&(i(t,r),a--)}}(t,r,s);for(let i=0;i<e.length;i++)t.push({value:e[i],at:l(r,s,a[i]),easing:W(n,i)})}function ct(t,e){return t.at===e.at?null===t.value?1:-1:t.at-e.at}function lt(t,e){return!e.has(t)&&e.set(t,{}),e.get(t)}function ut(t,e){return e[t]||(e[t]=[]),e[t]}function ht(t,e,n){const a=Math.max(e-5,0);return i=n-t(a),(r=e-a)?i*(1e3/r):0;var i,r}const ft=100,dt=10,mt=1;const pt=({stiffness:t=ft,damping:e=dt,mass:n=mt,from:a=0,to:i=1,velocity:r=0,restSpeed:s=2,restDistance:o=.5}={})=>{r=r?g(r):0;const c={done:!1,hasReachedTarget:!1,current:a,target:i},l=i-a,u=Math.sqrt(t/n)/1e3,h=((t=ft,e=dt,n=mt)=>e/(2*Math.sqrt(t*n)))(t,e,n);let f;if(h<1){const t=u*Math.sqrt(1-h*h);f=e=>i-Math.exp(-h*u*e)*((h*u*l-r)/t*Math.sin(t*e)+l*Math.cos(t*e))}else f=t=>i-Math.exp(-u*t)*(l+(u*l-r)*t);return t=>{c.current=f(t);const e=0===t?r:ht(f,t,c.current),n=Math.abs(e)<=s,l=Math.abs(i-c.current)<=o;var u,h,d;return c.done=n&&l,c.hasReachedTarget=(u=a,h=i,d=c.current,u<h&&d>=h||u>h&&d<=h),c}};function gt(t){const e=new WeakMap;return(n={})=>{const a=new Map,i=(e=0,i=100,r=0,s=!1)=>{const o=`${e}-${i}-${r}-${s}`;return a.has(o)||a.set(o,t(Object.assign({from:e,to:i,velocity:r,restSpeed:s?.05:2,restDistance:s?.01:.5},n))),a.get(o)},r=t=>(e.has(t)||e.set(t,function(t){let e,n=10,a=t(0);const i=[a.current];for(;!a.done&&n<1e4;)a=t(n),i.push(a.done?a.target:a.current),void 0===e&&a.hasReachedTarget&&(e=n),n+=10;const r=n-10;return 1===i.length&&i.push(a.current),{keyframes:i,duration:r/1e3,overshootDuration:(null!=e?e:r)/1e3}}(t)),e.get(t));return{createAnimation:(t,e,n,a,s)=>{var o,c;let l;const u=t.length;if(n&&u<=2&&t.every(yt)){const n=t[u-1],h=1===u?null:t[0];let f=0,d=0;const m=null==s?void 0:s.generator;if(m){const{animation:e,generatorStartTime:n}=s,a=(null==e?void 0:e.startTime)||n||0,i=(null==e?void 0:e.currentTime)||performance.now()-a,r=m(i).current;d=null!==(o=h)&&void 0!==o?o:r,(1===u||2===u&&null===t[0])&&(f=ht((t=>m(t).current),i,r))}else d=null!==(c=h)&&void 0!==c?c:parseFloat(e());const p=i(d,n,f,null==a?void 0:a.includes("scale")),g=r(p);l=Object.assign(Object.assign({},g),{easing:"linear"}),s&&(s.generator=p,s.generatorStartTime=performance.now())}else{l={easing:"ease",duration:r(i(0,100)).overshootDuration}}return l}}}}const yt=t=>"string"!=typeof t,vt=gt(pt),bt=gt((({from:t=0,velocity:e=0,power:n=.8,decay:a=.325,bounceDamping:i,bounceStiffness:r,changeTarget:s,min:o,max:c,restDistance:l=.5,restSpeed:u})=>{a=p(a);const h={hasReachedTarget:!1,done:!1,current:t,target:t},f=t=>void 0===o?c:void 0===c||Math.abs(o-t)<Math.abs(c-t)?o:c;let d=n*e;const m=t+d,g=void 0===s?m:s(m);h.target=g,g!==m&&(d=g-t);const y=t=>-d*Math.exp(-t/a),v=t=>g+y(t),b=t=>{const e=y(t),n=v(t);h.done=Math.abs(e)<=l,h.current=h.done?g:n};let M,T;const w=t=>{var e;(e=h.current,void 0!==o&&e<o||void 0!==c&&e>c)&&(M=t,T=pt({from:h.current,to:f(h.current),velocity:ht(v,t,h.current),damping:i,stiffness:r,restDistance:l,restSpeed:u}))};return w(0),t=>{let e=!1;return T||void 0!==M||(e=!0,b(t),w(t)),void 0!==M&&t>M?(h.hasReachedTarget=!0,T(t-M)):(h.hasReachedTarget=!1,!e&&b(t),h)}}));function Mt(t,e){return tt([()=>{const n=new B(t,[0,1],e);return n.finished.catch((()=>{})),n}],null==e?void 0:e.duration)}t.animate=function(t,e,n){return("function"==typeof t?Mt:rt)(t,e,n)},t.glide=bt,t.spring=vt,t.stagger=function(t=.1,{start:e=0,from:n=0,easing:a}={}){return(i,r)=>{const o=s(n)?n:function(t,e){if("first"===t)return 0;{const n=e-1;return"last"===t?n:n/2}}(n,r),c=Math.abs(o-i);let l=t*c;if(a){const t=r*i;l=F(a)(l/t)*t}return e+l}},t.style=G,t.timeline=function(t,e={}){var n;const a=function(t,e={}){var{defaultOptions:n={}}=e,a=function(t,e){var n={};for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&e.indexOf(a)<0&&(n[a]=t[a]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(a=Object.getOwnPropertySymbols(t);i<a.length;i++)e.indexOf(a[i])<0&&Object.prototype.propertyIsEnumerable.call(t,a[i])&&(n[a[i]]=t[a[i]])}return n}(e,["defaultOptions"]);const i=[],s=new Map,c={},l=new Map;let u=0,h=0,p=0;for(let e=0;e<t.length;e++){const[a,i,f={}]=t[e];void 0!==f.at&&(h=st(h,f.at,u,l));let g=0;const y=N(a,c),v=y.length;for(let t=0;t<v;t++){const e=lt(y[t],s);for(const a in i){const s=ut(a,e);let c=Z(i[a]);const l=L(f,a);let{duration:u=n.duration||r.duration,easing:y=n.easing||r.easing}=l;if(o(y)){const t=A(a);c.length;const e=y.createAnimation(c,(()=>"0"),t);y=e.easing,void 0!==e.keyframes&&(c=e.keyframes),void 0!==e.duration&&(u=e.duration)}const b=it(f.delay,t,v)||0,M=h+b,T=M+u;let{offset:w=m(c.length)}=l;1===w.length&&0===w[0]&&(w[1]=1);const x=length-c.length;x>0&&d(w,x),1===c.length&&c.unshift(null),ot(s,c,y,w,M,T),g=Math.max(b+u,g),p=Math.max(T,p)}}u=h,h+=g}return s.forEach(((t,e)=>{for(const s in t){const o=t[s];o.sort(ct);const c=[],l=[],u=[];for(let t=0;t<o.length;t++){const{at:e,value:n,easing:a}=o[t];c.push(n),l.push(f(0,p,e)),u.push(a||r.easing)}0!==l[0]&&(l.unshift(0),c.unshift(c[0]),u.unshift("linear")),1!==l[l.length-1]&&(l.push(1),c.push(null)),i.push([e,s,c,Object.assign(Object.assign(Object.assign({},n),{duration:p,easing:u,offset:l}),a)])}})),i}(t,e),i=a.map((t=>J(...t))).filter(Boolean);return tt(i,null===(n=a[0])||void 0===n?void 0:n[3].duration)},Object.defineProperty(t,"__esModule",{value:!0})}));
@@ -4,18 +4,38 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Motion = {}));
5
5
  })(this, (function (exports) { 'use strict';
6
6
 
7
+ /**
8
+ * The MotionValue tracks the state of a single animatable
9
+ * value. Currently, updatedAt and current are unused. The
10
+ * long term idea is to use this to minimise the number
11
+ * of DOM reads, and to abstract the DOM interactions here.
12
+ */
13
+ class MotionValue {
14
+ setAnimation(animation) {
15
+ this.animation = animation;
16
+ animation === null || animation === void 0 ? void 0 : animation.finished.then(() => this.clearAnimation()).catch(() => { });
17
+ }
18
+ clearAnimation() {
19
+ this.animation = this.generator = undefined;
20
+ }
21
+ }
22
+
7
23
  const data = new WeakMap();
8
24
  function getAnimationData(element) {
9
25
  if (!data.has(element)) {
10
26
  data.set(element, {
11
27
  transforms: [],
12
- animations: {},
13
- generators: {},
14
- prevGeneratorState: {},
28
+ values: new Map(),
15
29
  });
16
30
  }
17
31
  return data.get(element);
18
32
  }
33
+ function getMotionValue(motionValues, name) {
34
+ if (!motionValues.has(name)) {
35
+ motionValues.set(name, new MotionValue());
36
+ }
37
+ return motionValues.get(name);
38
+ }
19
39
 
20
40
  function addUniqueItem(array, item) {
21
41
  array.indexOf(item) === -1 && array.push(item);
@@ -142,6 +162,10 @@
142
162
  name = transformAlias[name];
143
163
  const { transforms } = getAnimationData(element);
144
164
  addUniqueItem(transforms, name);
165
+ /**
166
+ * TODO: An optimisation here could be to cache the transform in element data
167
+ * and only update if this has changed.
168
+ */
145
169
  element.style.transform = buildTransformTemplate(transforms);
146
170
  };
147
171
  const buildTransformTemplate = (transforms) => transforms
@@ -289,16 +313,15 @@
289
313
 
290
314
  class Animation {
291
315
  constructor(output, keyframes = [0, 1], { easing = defaults$1.easing, duration = defaults$1.duration, delay = defaults$1.delay, endDelay = defaults$1.endDelay, repeat = defaults$1.repeat, offset, direction = "normal", } = {}) {
292
- this.startTime = 0;
316
+ this.startTime = null;
293
317
  this.rate = 1;
294
318
  this.t = 0;
295
- this.cancelTimestamp = 0;
319
+ this.cancelTimestamp = null;
296
320
  this.playState = "idle";
297
321
  this.finished = new Promise((resolve, reject) => {
298
322
  this.resolve = resolve;
299
323
  this.reject = reject;
300
324
  });
301
- const totalDuration = duration * (repeat + 1);
302
325
  if (isEasingGenerator(easing)) {
303
326
  const custom = easing.createAnimation(keyframes, () => "0", true);
304
327
  easing = custom.easing;
@@ -307,6 +330,7 @@
307
330
  if (custom.duration !== undefined)
308
331
  duration = custom.duration;
309
332
  }
333
+ const totalDuration = duration * (repeat + 1);
310
334
  const interpolate$1 = interpolate(keyframes, offset, isEasingList(easing)
311
335
  ? easing.map(getEasingFunction)
312
336
  : getEasingFunction(easing));
@@ -374,14 +398,16 @@
374
398
  this.play();
375
399
  }
376
400
  play() {
401
+ var _a;
377
402
  const now = performance.now();
378
403
  this.playState = "running";
379
404
  if (this.pauseTime) {
380
- this.startTime = now - (this.pauseTime - this.startTime);
405
+ this.startTime = now - (this.pauseTime - ((_a = this.startTime) !== null && _a !== void 0 ? _a : 0));
381
406
  }
382
407
  else if (!this.startTime) {
383
408
  this.startTime = now;
384
409
  }
410
+ this.cancelTimestamp = this.startTime;
385
411
  this.pauseTime = undefined;
386
412
  requestAnimationFrame(this.tick);
387
413
  }
@@ -393,23 +419,22 @@
393
419
  this.playState = "finished";
394
420
  this.tick(0);
395
421
  }
396
- cancel() {
422
+ stop() {
397
423
  var _a;
398
424
  this.playState = "idle";
399
- this.tick(this.cancelTimestamp);
400
- (_a = this.reject) === null || _a === void 0 ? void 0 : _a.call(this, false);
401
425
  if (this.frameRequestId !== undefined) {
402
426
  cancelAnimationFrame(this.frameRequestId);
403
427
  }
428
+ (_a = this.reject) === null || _a === void 0 ? void 0 : _a.call(this, false);
429
+ }
430
+ cancel() {
431
+ this.stop();
432
+ this.tick(this.cancelTimestamp);
404
433
  }
405
434
  reverse() {
406
435
  this.rate *= -1;
407
436
  }
408
- commitStyles() {
409
- // TODO: The bug now is that this is not called if the animation is finished
410
- // this should be called regardless
411
- this.cancelTimestamp = performance.now();
412
- }
437
+ commitStyles() { }
413
438
  get currentTime() {
414
439
  return this.t;
415
440
  }
@@ -498,16 +523,18 @@
498
523
  },
499
524
  };
500
525
 
501
- function stopAnimation(animation) {
526
+ function stopAnimation(animation, needsCommit = true) {
502
527
  if (!animation || animation.playState === "finished")
503
528
  return;
504
529
  // Suppress error thrown by WAAPI
505
530
  try {
506
- /**
507
- * commitStyles has overhead so we only want to commit and cancel
508
- */
509
- animation.commitStyles();
510
- animation.cancel();
531
+ if (animation.stop) {
532
+ animation.stop();
533
+ }
534
+ else {
535
+ needsCommit && animation.commitStyles();
536
+ animation.cancel();
537
+ }
511
538
  }
512
539
  catch (e) { }
513
540
  }
@@ -524,6 +551,7 @@
524
551
  */
525
552
  valueIsTransform && addTransformToElement(element, key);
526
553
  const name = getStyleName(key);
554
+ const motionValue = getMotionValue(data.values, name);
527
555
  /**
528
556
  * Get definition of value, this will be used to convert numerical
529
557
  * keyframes into the default value type.
@@ -535,7 +563,7 @@
535
563
  * this is fired now and we return a factory function to create
536
564
  * the actual animation that can get called in batch,
537
565
  */
538
- stopAnimation(data.animations[name]);
566
+ stopAnimation(motionValue.animation, !(isEasingGenerator(easing) && motionValue.generator));
539
567
  /**
540
568
  * Batchable factory function containing all DOM reads.
541
569
  */
@@ -547,7 +575,7 @@
547
575
  */
548
576
  let keyframes = hydrateKeyframes(keyframesList(keyframesDefinition), readInitialValue);
549
577
  if (isEasingGenerator(easing)) {
550
- const custom = easing.createAnimation(keyframes, readInitialValue, valueIsTransform, name, data);
578
+ const custom = easing.createAnimation(keyframes, readInitialValue, valueIsTransform, name, motionValue);
551
579
  easing = custom.easing;
552
580
  if (custom.keyframes !== undefined)
553
581
  keyframes = custom.keyframes;
@@ -656,15 +684,7 @@
656
684
  ? definition.toDefaultUnit(target)
657
685
  : target);
658
686
  }
659
- data.animations[name] = animation;
660
- /**
661
- * When an animation finishes, delete the reference to the previous animation.
662
- */
663
- animation === null || animation === void 0 ? void 0 : animation.finished.then(() => {
664
- data.animations[name] = undefined;
665
- data.generators[name] = undefined;
666
- data.prevGeneratorState[name] = undefined;
667
- }).catch(noop);
687
+ motionValue.setAnimation(animation);
668
688
  return animation;
669
689
  };
670
690
  }
@@ -722,7 +742,7 @@
722
742
  }
723
743
  return target.finished;
724
744
  case "stop":
725
- return () => target.animations.forEach(stopAnimation);
745
+ return () => target.animations.forEach((animation) => stopAnimation(animation));
726
746
  default:
727
747
  return () => target.animations.forEach((animation) => animation[key]());
728
748
  }
@@ -1057,7 +1077,7 @@
1057
1077
  const sampleT = 5; // ms
1058
1078
  function calcGeneratorVelocity(resolveValue, t, current) {
1059
1079
  const prevT = Math.max(t - sampleT, 0);
1060
- return velocityPerSecond(current - resolveValue(prevT), 5);
1080
+ return velocityPerSecond(current - resolveValue(prevT), t - prevT);
1061
1081
  }
1062
1082
 
1063
1083
  const defaults = {
@@ -1067,7 +1087,6 @@
1067
1087
  };
1068
1088
 
1069
1089
  const calcDampingRatio = (stiffness = defaults.stiffness, damping = defaults.damping, mass = defaults.mass) => damping / (2 * Math.sqrt(stiffness * mass));
1070
- const calcAngularFreq = (undampedFreq, dampingRatio) => undampedFreq * Math.sqrt(1 - dampingRatio * dampingRatio);
1071
1090
 
1072
1091
  function hasReachedTarget(origin, target, current) {
1073
1092
  return ((origin < target && current >= target) ||
@@ -1081,14 +1100,13 @@
1081
1100
  hasReachedTarget: false,
1082
1101
  current: from,
1083
1102
  target: to,
1084
- velocity,
1085
1103
  };
1086
- const dampingRatio = calcDampingRatio(stiffness, damping, mass);
1087
1104
  const initialDelta = to - from;
1088
1105
  const undampedAngularFreq = Math.sqrt(stiffness / mass) / 1000;
1089
- const angularFreq = calcAngularFreq(undampedAngularFreq, dampingRatio);
1106
+ const dampingRatio = calcDampingRatio(stiffness, damping, mass);
1090
1107
  let resolveSpring;
1091
1108
  if (dampingRatio < 1) {
1109
+ const angularFreq = undampedAngularFreq * Math.sqrt(1 - dampingRatio * dampingRatio);
1092
1110
  // Underdamped spring (bouncy)
1093
1111
  resolveSpring = (t) => to -
1094
1112
  Math.exp(-dampingRatio * undampedAngularFreq * t) *
@@ -1099,17 +1117,18 @@
1099
1117
  }
1100
1118
  else {
1101
1119
  // Critically damped spring
1102
- resolveSpring = (t) => to -
1103
- Math.exp(-undampedAngularFreq * t) *
1104
- (initialDelta + (velocity + undampedAngularFreq * initialDelta) * t);
1120
+ resolveSpring = (t) => {
1121
+ return (to -
1122
+ Math.exp(-undampedAngularFreq * t) *
1123
+ (initialDelta + (-velocity + undampedAngularFreq * initialDelta) * t));
1124
+ };
1105
1125
  }
1106
1126
  return (t) => {
1107
1127
  state.current = resolveSpring(t);
1108
- state.velocity =
1109
- t === 0
1110
- ? velocity
1111
- : calcGeneratorVelocity(resolveSpring, t, state.current);
1112
- const isBelowVelocityThreshold = Math.abs(state.velocity) <= restSpeed;
1128
+ const currentVelocity = t === 0
1129
+ ? velocity
1130
+ : calcGeneratorVelocity(resolveSpring, t, state.current);
1131
+ const isBelowVelocityThreshold = Math.abs(currentVelocity) <= restSpeed;
1113
1132
  const isBelowDisplacementThreshold = Math.abs(to - state.current) <= restDistance;
1114
1133
  state.done = isBelowVelocityThreshold && isBelowDisplacementThreshold;
1115
1134
  state.hasReachedTarget = hasReachedTarget(from, to, state.current);
@@ -1124,7 +1143,6 @@
1124
1143
  done: false,
1125
1144
  current: from,
1126
1145
  target: from,
1127
- velocity,
1128
1146
  };
1129
1147
  const isOutOfBounds = (v) => (min !== undefined && v < min) || (max !== undefined && v > max);
1130
1148
  const nearestBoundary = (v) => {
@@ -1151,8 +1169,6 @@
1151
1169
  const latest = calcLatest(t);
1152
1170
  state.done = Math.abs(delta) <= restDistance;
1153
1171
  state.current = state.done ? target : latest;
1154
- state.velocity =
1155
- t === 0 ? velocity : calcGeneratorVelocity(calcLatest, t, state.current);
1156
1172
  };
1157
1173
  /**
1158
1174
  * Ideally this would resolve for t in a stateless way, we could
@@ -1169,7 +1185,7 @@
1169
1185
  spring$1$1 = spring$1({
1170
1186
  from: state.current,
1171
1187
  to: nearestBoundary(state.current),
1172
- velocity: state.velocity,
1188
+ velocity: calcGeneratorVelocity(calcLatest, t, state.current),
1173
1189
  damping: bounceDamping,
1174
1190
  stiffness: bounceStiffness,
1175
1191
  restDistance,
@@ -1255,43 +1271,53 @@
1255
1271
  return keyframesCache.get(generator);
1256
1272
  };
1257
1273
  return {
1258
- createAnimation: (keyframes, getOrigin, canUseGenerator, name, data) => {
1274
+ createAnimation: (keyframes, getOrigin, canUseGenerator, name, motionValue) => {
1275
+ var _a, _b;
1259
1276
  let settings;
1260
- let generator;
1261
1277
  const numKeyframes = keyframes.length;
1262
1278
  let shouldUseGenerator = canUseGenerator &&
1263
1279
  numKeyframes <= 2 &&
1264
1280
  keyframes.every(isNumberOrNull);
1265
1281
  if (shouldUseGenerator) {
1266
- const prevMotionState = name && data && data.prevGeneratorState[name];
1267
- const velocity = prevMotionState &&
1268
- (numKeyframes === 1 ||
1269
- (numKeyframes === 2 && keyframes[0] === null))
1270
- ? prevMotionState.velocity
1271
- : 0;
1272
1282
  const target = keyframes[numKeyframes - 1];
1273
1283
  const unresolvedOrigin = numKeyframes === 1 ? null : keyframes[0];
1274
- const origin = unresolvedOrigin === null
1275
- ? prevMotionState
1276
- ? prevMotionState.current
1277
- : parseFloat(getOrigin())
1278
- : unresolvedOrigin;
1279
- generator = getGenerator(origin, target, velocity, name === null || name === void 0 ? void 0 : name.includes("scale"));
1284
+ let velocity = 0;
1285
+ let origin = 0;
1286
+ const prevGenerator = motionValue === null || motionValue === void 0 ? void 0 : motionValue.generator;
1287
+ if (prevGenerator) {
1288
+ /**
1289
+ * If we have a generator for this value we can use it to resolve
1290
+ * the animations's current value and velocity.
1291
+ */
1292
+ const { animation, generatorStartTime } = motionValue;
1293
+ const startTime = (animation === null || animation === void 0 ? void 0 : animation.startTime) || generatorStartTime || 0;
1294
+ const currentTime = (animation === null || animation === void 0 ? void 0 : animation.currentTime) || performance.now() - startTime;
1295
+ const prevGeneratorCurrent = prevGenerator(currentTime).current;
1296
+ origin = (_a = unresolvedOrigin) !== null && _a !== void 0 ? _a : prevGeneratorCurrent;
1297
+ if (numKeyframes === 1 ||
1298
+ (numKeyframes === 2 && keyframes[0] === null)) {
1299
+ velocity = calcGeneratorVelocity((t) => prevGenerator(t).current, currentTime, prevGeneratorCurrent);
1300
+ }
1301
+ }
1302
+ else {
1303
+ origin = (_b = unresolvedOrigin) !== null && _b !== void 0 ? _b : parseFloat(getOrigin());
1304
+ }
1305
+ const generator = getGenerator(origin, target, velocity, name === null || name === void 0 ? void 0 : name.includes("scale"));
1280
1306
  const keyframesMetadata = getKeyframes(generator);
1281
1307
  settings = Object.assign(Object.assign({}, keyframesMetadata), { easing: "linear" });
1308
+ // TODO Add test for this
1309
+ if (motionValue) {
1310
+ motionValue.generator = generator;
1311
+ motionValue.generatorStartTime = performance.now();
1312
+ }
1282
1313
  }
1283
1314
  else {
1284
- generator = getGenerator(0, 100);
1285
- const keyframesMetadata = getKeyframes(generator);
1315
+ const keyframesMetadata = getKeyframes(getGenerator(0, 100));
1286
1316
  settings = {
1287
1317
  easing: "ease",
1288
1318
  duration: keyframesMetadata.overshootDuration,
1289
1319
  };
1290
1320
  }
1291
- // TODO Add test for this
1292
- if (data && name) {
1293
- data.generators[name] = generator;
1294
- }
1295
1321
  return settings;
1296
1322
  },
1297
1323
  };
@@ -1 +1 @@
1
- const t=new WeakMap;function e(e){return t.has(e)||t.set(e,{transforms:[],animations:{},generators:{},prevGeneratorState:{}}),t.get(e)}function n(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const a={duration:.3,delay:0,endDelay:0,repeat:0,easing:"ease"},r=t=>"number"==typeof t,i=t=>"object"==typeof t&&Boolean(t.createAnimation),s=t=>Array.isArray(t)&&!r(t[0]),o=(t,e,n)=>-n*t+n*e+t,c=()=>{},l=t=>t,u=(t,e,n)=>e-t==0?1:(n-t)/(e-t);function h(t,e){const n=t[t.length-1];for(let a=1;a<=e;a++){const r=u(0,e,a);t.push(o(n,1,r))}}function f(t){const e=[0];return h(e,t-1),e}const d=t=>1e3*t,p=t=>t/1e3;const m=["","X","Y","Z"],y={x:"translateX",y:"translateY",z:"translateZ"},g={syntax:"<angle>",initialValue:"0deg",toDefaultUnit:t=>t+"deg"},v={translate:{syntax:"<length-percentage>",initialValue:"0px",toDefaultUnit:t=>t+"px"},rotate:g,scale:{syntax:"<number>",initialValue:1,toDefaultUnit:l},skew:g},b=new Map,M=t=>`--motion-${t}`,w=["x","y","z"];["translate","scale","rotate","skew"].forEach((t=>{m.forEach((e=>{w.push(t+e),b.set(M(t+e),v[t])}))}));const S=(t,e)=>w.indexOf(t)-w.indexOf(e),O=new Set(w),x=t=>O.has(t),T=t=>t.sort(S).reduce(k,"").trim(),k=(t,e)=>`${t} ${e}(var(${M(e)}))`,j=t=>t.startsWith("--"),A=new Set;const D=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t;function R(t,e,n,a){if(t===e&&n===a)return l;const r=e=>function(t,e,n,a,r){let i,s,o=0;do{s=e+(n-e)/2,i=D(s,a,r)-t,i>0?n=s:e=s}while(Math.abs(i)>1e-7&&++o<12);return s}(e,0,1,t,n);return t=>0===t||1===t?t:D(r(t),e,a)}const P=(t,e="end")=>n=>{const a=(n="end"===e?Math.min(n,.999):Math.max(n,.001))*t,r="end"===e?Math.floor(a):Math.ceil(a);return i=0,s=1,o=r/t,Math.min(Math.max(o,i),s);var i,s,o},E={ease:R(.25,.1,.25,1),"ease-in":R(.42,0,1,1),"ease-in-out":R(.42,0,.58,1),"ease-out":R(0,0,.58,1)},$=/\((.*?)\)/;function q(t){if("function"==typeof t)return t;if(Array.isArray(t))return R(...t);if(E[t])return E[t];if(t.startsWith("steps")){const e=$.exec(t);if(e){const t=e[1].split(",");return P(parseFloat(t[0]),t[1].trim())}}return l}function V(t,e){return s(t)?t[((t,e,n)=>{const a=e-t;return((n-t)%a+a)%a+t})(0,t.length,e)]:t}function F(t,e=f(t.length),n=l){const a=t.length,r=a-e.length;return r>0&&h(e,r),r=>{let i=0;for(;i<a-2&&!(r<e[i+1]);i++);let s=(c=u(e[i],e[i+1],r),Math.min(1,Math.max(c,0)));var c;return s=V(n,i)(s),o(t[i],t[i+1],s)}}class W{constructor(t,e=[0,1],{easing:n=a.easing,duration:r=a.duration,delay:o=a.delay,endDelay:c=a.endDelay,repeat:l=a.repeat,offset:u,direction:h="normal"}={}){this.startTime=0,this.rate=1,this.t=0,this.cancelTimestamp=0,this.playState="idle",this.finished=new Promise(((t,e)=>{this.resolve=t,this.reject=e}));const f=r*(l+1);if(i(n)){const t=n.createAnimation(e,(()=>"0"),!0);n=t.easing,void 0!==t.keyframes&&(e=t.keyframes),void 0!==t.duration&&(r=t.duration)}const d=F(e,u,s(n)?n.map(q):q(n));this.tick=e=>{var n;this.pauseTime&&(e=this.pauseTime);let a=(e-this.startTime)*this.rate;this.t=a,a/=1e3,a=Math.max(a-o,0),"finished"===this.playState&&(a=f);const i=a/r;let s=Math.floor(i),l=i%1;!l&&i>=1&&(l=1),1===l&&s--;const u=s%2;("reverse"===h||"alternate"===h&&u||"alternate-reverse"===h&&!u)&&(l=1-l);const p=d(a>=f?1:Math.min(l,1));t(p);"finished"===this.playState||a>=f+c?(this.playState="finished",null===(n=this.resolve)||void 0===n||n.call(this,p)):"idle"!==this.playState&&(this.frameRequestId=requestAnimationFrame(this.tick))},this.play()}play(){const t=performance.now();this.playState="running",this.pauseTime?this.startTime=t-(this.pauseTime-this.startTime):this.startTime||(this.startTime=t),this.pauseTime=void 0,requestAnimationFrame(this.tick)}pause(){this.playState="paused",this.pauseTime=performance.now()}finish(){this.playState="finished",this.tick(0)}cancel(){var t;this.playState="idle",this.tick(this.cancelTimestamp),null===(t=this.reject)||void 0===t||t.call(this,!1),void 0!==this.frameRequestId&&cancelAnimationFrame(this.frameRequestId)}reverse(){this.rate*=-1}commitStyles(){this.cancelTimestamp=performance.now()}get currentTime(){return this.t}set currentTime(t){this.pauseTime||0===this.rate?this.pauseTime=t:this.startTime=performance.now()-t/this.rate}get playbackRate(){return this.rate}set playbackRate(t){this.rate=t}}const U=t=>(t=>Array.isArray(t)&&r(t[0]))(t)?B(t):t,B=([t,e,n,a])=>`cubic-bezier(${t}, ${e}, ${n}, ${a})`,C=t=>document.createElement("div").animate(t,{duration:.001}),I={cssRegisterProperty:()=>"undefined"!=typeof CSS&&Object.hasOwnProperty.call(CSS,"registerProperty"),waapi:()=>Object.hasOwnProperty.call(Element.prototype,"animate"),partialKeyframes:()=>{try{C({opacity:[1]})}catch(t){return!1}return!0},finished:()=>Boolean(C({opacity:[0,1]}).finished)},z={},G={};for(const t in I)G[t]=()=>(void 0===z[t]&&(z[t]=I[t]()),z[t]);const K=t=>Array.isArray(t)?t:[t];function N(t){return y[t]&&(t=y[t]),x(t)?M(t):t}const X={get:(t,e)=>{e=N(e);let n=j(e)?t.style.getPropertyValue(e):getComputedStyle(t)[e];if(!n&&0!==n){const t=b.get(e);t&&(n=t.initialValue)}return n},set:(t,e,n)=>{e=N(e),j(e)?t.style.setProperty(e,n):t.style[e]=n}};function Y(t){if(t&&"finished"!==t.playState)try{t.commitStyles(),t.cancel()}catch(t){}}function Z(t,n,o,l={}){let u,{duration:h=a.duration,delay:f=a.delay,endDelay:p=a.endDelay,repeat:m=a.repeat,easing:g=a.easing,direction:v,offset:M,allowWebkitAcceleration:w=!1}=l;const S=e(t);let O=G.waapi();const k=x(n);k&&((t,n)=>{y[n]&&(n=y[n]);const{transforms:a}=e(t);var r,i;i=n,-1===(r=a).indexOf(i)&&r.push(i),t.style.transform=T(a)})(t,n);const D=N(n),R=b.get(D);return Y(S.animations[D]),()=>{const e=()=>{var e,n;return null!==(n=null!==(e=X.get(t,D))&&void 0!==e?e:null==R?void 0:R.initialValue)&&void 0!==n?n:0};let n=function(t,e){for(let n=0;n<t.length;n++)null===t[n]&&(t[n]=n?t[n-1]:e());return t}(K(o),e);if(i(g)){const t=g.createAnimation(n,e,k,D,S);g=t.easing,void 0!==t.keyframes&&(n=t.keyframes),void 0!==t.duration&&(h=t.duration)}if(j(D)&&(G.cssRegisterProperty()?function(t){if(!A.has(t)){A.add(t);try{const{syntax:e,initialValue:n}=b.has(t)?b.get(t):{};CSS.registerProperty({name:t,inherits:!1,syntax:e,initialValue:n})}catch(t){}}}(D):O=!1),O){R&&(n=n.map((t=>r(t)?R.toDefaultUnit(t):t))),G.partialKeyframes()||1!==n.length||n.unshift(e());const a={delay:d(f),duration:d(h),endDelay:d(p),easing:s(g)?void 0:U(g),direction:v,iterations:m+1,fill:"both"};u=t.animate({[D]:n,offset:M,easing:s(g)?g.map(U):void 0},a),u.finished||(u.finished=new Promise(((t,e)=>{u.onfinish=t,u.oncancel=e})));const i=n[n.length-1];u.finished.then((()=>{X.set(t,D,i),u.cancel()})).catch(c),w||(u.playbackRate=1.000001)}else if(k&&n.every(r)){1===n.length&&n.unshift(parseFloat(e()));u=new W((e=>{R&&(e=R.toDefaultUnit(e)),X.set(t,D,e)}),n,Object.assign(Object.assign({},l),{duration:h,easing:g}))}else{const e=n[n.length-1];X.set(t,D,R&&r(e)?R.toDefaultUnit(e):e)}return S.animations[D]=u,null==u||u.finished.then((()=>{S.animations[D]=void 0,S.generators[D]=void 0,S.prevGeneratorState[D]=void 0})).catch(c),u}}const _=(t,e)=>t[e]?Object.assign(Object.assign({},t),t[e]):Object.assign({},t);function H(t,e){var n;return"string"==typeof t?e?(null!==(n=e[t])&&void 0!==n||(e[t]=document.querySelectorAll(t)),t=e[t]):t=document.querySelectorAll(t):t instanceof Element&&(t=[t]),Array.from(t)}const J=t=>t(),L=(t,e=a.duration)=>new Proxy({animations:t.map(J).filter(Boolean),duration:e},tt),Q=t=>t.animations[0],tt={get:(t,e)=>{var n,a;switch(e){case"duration":return t.duration;case"currentTime":let r=(null===(n=Q(t))||void 0===n?void 0:n[e])||0;return r?r/1e3:0;case"playbackRate":return null===(a=Q(t))||void 0===a?void 0:a[e];case"finished":return t.finished||(t.finished=Promise.all(t.animations.map(et)).catch(c)),t.finished;case"stop":return()=>t.animations.forEach(Y);default:return()=>t.animations.forEach((t=>t[e]()))}},set:(t,e,n)=>{switch(e){case"currentTime":n=d(n);case"currentTime":case"playbackRate":for(let a=0;a<t.animations.length;a++)t.animations[a][e]=n;return!0}return!1}},et=t=>t.finished;function nt(t=.1,{start:e=0,from:n=0,easing:a}={}){return(i,s)=>{const o=r(n)?n:function(t,e){if("first"===t)return 0;{const n=e-1;return"last"===t?n:n/2}}(n,s),c=Math.abs(o-i);let l=t*c;if(a){const t=s*i;l=q(a)(l/t)*t}return e+l}}function at(t,e,n){return"function"==typeof t?t(e,n):t}function rt(t,e,n={}){const a=(t=H(t)).length,r=[];for(let i=0;i<a;i++){const s=t[i];for(const t in e){const o=_(n,t);o.delay=at(o.delay,i,a);const c=Z(s,t,e[t],o);r.push(c)}}return L(r,n.duration)}var it=function(){};function st(t,e,n,a){var i;return r(e)?e:e.startsWith("-")||e.startsWith("+")?Math.max(0,t+parseFloat(e)):"<"===e?n:null!==(i=a.get(e))&&void 0!==i?i:t}function ot(t,e,a,r,i,s){!function(t,e,a){for(let r=0;r<t.length;r++){const i=t[r];i.at>e&&i.at<a&&(n(t,i),r--)}}(t,i,s);for(let n=0;n<e.length;n++)t.push({value:e[n],at:o(i,s,r[n]),easing:V(a,n)})}function ct(t,e){return t.at===e.at?null===t.value?1:-1:t.at-e.at}function lt(t,e={}){var n;const r=function(t,e={}){var{defaultOptions:n={}}=e,r=function(t,e){var n={};for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&e.indexOf(a)<0&&(n[a]=t[a]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(a=Object.getOwnPropertySymbols(t);r<a.length;r++)e.indexOf(a[r])<0&&Object.prototype.propertyIsEnumerable.call(t,a[r])&&(n[a[r]]=t[a[r]])}return n}(e,["defaultOptions"]);const s=[],o=new Map,c={},l=new Map;let d=0,p=0,m=0;for(let e=0;e<t.length;e++){const[r,s,u={}]=t[e];void 0!==u.at&&(p=st(p,u.at,d,l));let y=0;const g=H(r,c),v=g.length;for(let t=0;t<v;t++){const e=ut(g[t],o);for(const r in s){const o=ht(r,e);let c=K(s[r]);const l=_(u,r);let{duration:d=n.duration||a.duration,easing:g=n.easing||a.easing}=l;if(i(g)){const t=x(r);it(2===c.length||!t,"spring must be provided 2 keyframes within timeline");const e=g.createAnimation(c,(()=>"0"),t);g=e.easing,void 0!==e.keyframes&&(c=e.keyframes),void 0!==e.duration&&(d=e.duration)}const b=at(u.delay,t,v)||0,M=p+b,w=M+d;let{offset:S=f(c.length)}=l;1===S.length&&0===S[0]&&(S[1]=1);const O=length-c.length;O>0&&h(S,O),1===c.length&&c.unshift(null),ot(o,c,g,S,M,w),y=Math.max(b+d,y),m=Math.max(w,m)}}d=p,p+=y}return o.forEach(((t,e)=>{for(const i in t){const o=t[i];o.sort(ct);const c=[],l=[],h=[];for(let t=0;t<o.length;t++){const{at:e,value:n,easing:r}=o[t];c.push(n),l.push(u(0,m,e)),h.push(r||a.easing)}0!==l[0]&&(l.unshift(0),c.unshift(c[0]),h.unshift("linear")),1!==l[l.length-1]&&(l.push(1),c.push(null)),s.push([e,i,c,Object.assign(Object.assign(Object.assign({},n),{duration:m,easing:h,offset:l}),r)])}})),s}(t,e),s=r.map((t=>Z(...t))).filter(Boolean);return L(s,null===(n=r[0])||void 0===n?void 0:n[3].duration)}function ut(t,e){return!e.has(t)&&e.set(t,{}),e.get(t)}function ht(t,e){return e[t]||(e[t]=[]),e[t]}"production"!==process.env.NODE_ENV&&(it=function(t,e){if(!t)throw new Error(e)});function ft(t,e,n){const a=Math.max(e-5,0);return r=n-t(a),(i=5)?r*(1e3/i):0;var r,i}const dt=100,pt=10,mt=1;const yt=({stiffness:t=dt,damping:e=pt,mass:n=mt,from:a=0,to:r=1,velocity:i=0,restSpeed:s=2,restDistance:o=.5}={})=>{i=i?p(i):0;const c={done:!1,hasReachedTarget:!1,current:a,target:r,velocity:i},l=((t=dt,e=pt,n=mt)=>e/(2*Math.sqrt(t*n)))(t,e,n),u=r-a,h=Math.sqrt(t/n)/1e3,f=((t,e)=>t*Math.sqrt(1-e*e))(h,l);let d;return d=l<1?t=>r-Math.exp(-l*h*t)*((l*h*u-i)/f*Math.sin(f*t)+u*Math.cos(f*t)):t=>r-Math.exp(-h*t)*(u+(i+h*u)*t),t=>{c.current=d(t),c.velocity=0===t?i:ft(d,t,c.current);const e=Math.abs(c.velocity)<=s,n=Math.abs(r-c.current)<=o;var l,u,h;return c.done=e&&n,c.hasReachedTarget=(l=a,u=r,h=c.current,l<u&&h>=u||l>u&&h<=u),c}};function gt(t){const e=new WeakMap;return(n={})=>{const a=new Map,r=(e=0,r=100,i=0,s=!1)=>{const o=`${e}-${r}-${i}-${s}`;return a.has(o)||a.set(o,t(Object.assign({from:e,to:r,velocity:i,restSpeed:s?.05:2,restDistance:s?.01:.5},n))),a.get(o)},i=t=>(e.has(t)||e.set(t,function(t){let e,n=10,a=t(0);const r=[a.current];for(;!a.done&&n<1e4;)a=t(n),r.push(a.done?a.target:a.current),void 0===e&&a.hasReachedTarget&&(e=n),n+=10;const i=n-10;return 1===r.length&&r.push(a.current),{keyframes:r,duration:i/1e3,overshootDuration:(null!=e?e:i)/1e3}}(t)),e.get(t));return{createAnimation:(t,e,n,a,s)=>{let o,c;const l=t.length;if(n&&l<=2&&t.every(vt)){const n=a&&s&&s.prevGeneratorState[a],u=n&&(1===l||2===l&&null===t[0])?n.velocity:0,h=t[l-1],f=1===l?null:t[0],d=null===f?n?n.current:parseFloat(e()):f;c=r(d,h,u,null==a?void 0:a.includes("scale"));const p=i(c);o=Object.assign(Object.assign({},p),{easing:"linear"})}else{c=r(0,100);o={easing:"ease",duration:i(c).overshootDuration}}return s&&a&&(s.generators[a]=c),o}}}}const vt=t=>"string"!=typeof t,bt=gt(yt),Mt=gt((({from:t=0,velocity:e=0,power:n=.8,decay:a=.325,bounceDamping:r,bounceStiffness:i,changeTarget:s,min:o,max:c,restDistance:l=.5,restSpeed:u})=>{a=d(a);const h={hasReachedTarget:!1,done:!1,current:t,target:t,velocity:e},f=t=>void 0===o?c:void 0===c||Math.abs(o-t)<Math.abs(c-t)?o:c;let p=n*e;const m=t+p,y=void 0===s?m:s(m);h.target=y,y!==m&&(p=y-t);const g=t=>-p*Math.exp(-t/a),v=t=>y+g(t),b=t=>{const n=g(t),a=v(t);h.done=Math.abs(n)<=l,h.current=h.done?y:a,h.velocity=0===t?e:ft(v,t,h.current)};let M,w;const S=t=>{var e;(e=h.current,void 0!==o&&e<o||void 0!==c&&e>c)&&(M=t,w=yt({from:h.current,to:f(h.current),velocity:h.velocity,damping:r,stiffness:i,restDistance:l,restSpeed:u}))};return S(0),t=>{let e=!1;return w||void 0!==M||(e=!0,b(t),S(t)),void 0!==M&&t>M?(h.hasReachedTarget=!0,w(t-M)):(h.hasReachedTarget=!1,!e&&b(t),h)}}));function wt(t,e){return L([()=>{const n=new W(t,[0,1],e);return n.finished.catch((()=>{})),n}],null==e?void 0:e.duration)}function St(t,e,n){return("function"==typeof t?wt:rt)(t,e,n)}export{St as animate,Mt as glide,bt as spring,nt as stagger,X as style,lt as timeline};
1
+ class t{setAnimation(t){this.animation=t,null==t||t.finished.then((()=>this.clearAnimation())).catch((()=>{}))}clearAnimation(){this.animation=this.generator=void 0}}const e=new WeakMap;function n(t){return e.has(t)||e.set(t,{transforms:[],values:new Map}),e.get(t)}function a(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const i={duration:.3,delay:0,endDelay:0,repeat:0,easing:"ease"},r=t=>"number"==typeof t,s=t=>"object"==typeof t&&Boolean(t.createAnimation),o=t=>Array.isArray(t)&&!r(t[0]),c=(t,e,n)=>-n*t+n*e+t,l=()=>{},u=t=>t,h=(t,e,n)=>e-t==0?1:(n-t)/(e-t);function f(t,e){const n=t[t.length-1];for(let a=1;a<=e;a++){const i=h(0,e,a);t.push(c(n,1,i))}}function d(t){const e=[0];return f(e,t-1),e}const m=t=>1e3*t,p=t=>t/1e3;const g=["","X","Y","Z"],y={x:"translateX",y:"translateY",z:"translateZ"},v={syntax:"<angle>",initialValue:"0deg",toDefaultUnit:t=>t+"deg"},b={translate:{syntax:"<length-percentage>",initialValue:"0px",toDefaultUnit:t=>t+"px"},rotate:v,scale:{syntax:"<number>",initialValue:1,toDefaultUnit:u},skew:v},w=new Map,M=t=>`--motion-${t}`,T=["x","y","z"];["translate","scale","rotate","skew"].forEach((t=>{g.forEach((e=>{T.push(t+e),w.set(M(t+e),b[t])}))}));const S=(t,e)=>T.indexOf(t)-T.indexOf(e),O=new Set(T),x=t=>O.has(t),A=t=>t.sort(S).reduce(k,"").trim(),k=(t,e)=>`${t} ${e}(var(${M(e)}))`,j=t=>t.startsWith("--"),D=new Set;const R=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t;function P(t,e,n,a){if(t===e&&n===a)return u;const i=e=>function(t,e,n,a,i){let r,s,o=0;do{s=e+(n-e)/2,r=R(s,a,i)-t,r>0?n=s:e=s}while(Math.abs(r)>1e-7&&++o<12);return s}(e,0,1,t,n);return t=>0===t||1===t?t:R(i(t),e,a)}const E=(t,e="end")=>n=>{const a=(n="end"===e?Math.min(n,.999):Math.max(n,.001))*t,i="end"===e?Math.floor(a):Math.ceil(a);return r=0,s=1,o=i/t,Math.min(Math.max(o,r),s);var r,s,o},$={ease:P(.25,.1,.25,1),"ease-in":P(.42,0,1,1),"ease-in-out":P(.42,0,.58,1),"ease-out":P(0,0,.58,1)},q=/\((.*?)\)/;function V(t){if("function"==typeof t)return t;if(Array.isArray(t))return P(...t);if($[t])return $[t];if(t.startsWith("steps")){const e=q.exec(t);if(e){const t=e[1].split(",");return E(parseFloat(t[0]),t[1].trim())}}return u}function F(t,e){return o(t)?t[((t,e,n)=>{const a=e-t;return((n-t)%a+a)%a+t})(0,t.length,e)]:t}function W(t,e=d(t.length),n=u){const a=t.length,i=a-e.length;return i>0&&f(e,i),i=>{let r=0;for(;r<a-2&&!(i<e[r+1]);r++);let s=(o=h(e[r],e[r+1],i),Math.min(1,Math.max(o,0)));var o;return s=F(n,r)(s),c(t[r],t[r+1],s)}}class U{constructor(t,e=[0,1],{easing:n=i.easing,duration:a=i.duration,delay:r=i.delay,endDelay:c=i.endDelay,repeat:l=i.repeat,offset:u,direction:h="normal"}={}){if(this.startTime=null,this.rate=1,this.t=0,this.cancelTimestamp=null,this.playState="idle",this.finished=new Promise(((t,e)=>{this.resolve=t,this.reject=e})),s(n)){const t=n.createAnimation(e,(()=>"0"),!0);n=t.easing,void 0!==t.keyframes&&(e=t.keyframes),void 0!==t.duration&&(a=t.duration)}const f=a*(l+1),d=W(e,u,o(n)?n.map(V):V(n));this.tick=e=>{var n;this.pauseTime&&(e=this.pauseTime);let i=(e-this.startTime)*this.rate;this.t=i,i/=1e3,i=Math.max(i-r,0),"finished"===this.playState&&(i=f);const s=i/a;let o=Math.floor(s),l=s%1;!l&&s>=1&&(l=1),1===l&&o--;const u=o%2;("reverse"===h||"alternate"===h&&u||"alternate-reverse"===h&&!u)&&(l=1-l);const m=d(i>=f?1:Math.min(l,1));t(m);"finished"===this.playState||i>=f+c?(this.playState="finished",null===(n=this.resolve)||void 0===n||n.call(this,m)):"idle"!==this.playState&&(this.frameRequestId=requestAnimationFrame(this.tick))},this.play()}play(){var t;const e=performance.now();this.playState="running",this.pauseTime?this.startTime=e-(this.pauseTime-(null!==(t=this.startTime)&&void 0!==t?t:0)):this.startTime||(this.startTime=e),this.cancelTimestamp=this.startTime,this.pauseTime=void 0,requestAnimationFrame(this.tick)}pause(){this.playState="paused",this.pauseTime=performance.now()}finish(){this.playState="finished",this.tick(0)}stop(){var t;this.playState="idle",void 0!==this.frameRequestId&&cancelAnimationFrame(this.frameRequestId),null===(t=this.reject)||void 0===t||t.call(this,!1)}cancel(){this.stop(),this.tick(this.cancelTimestamp)}reverse(){this.rate*=-1}commitStyles(){}get currentTime(){return this.t}set currentTime(t){this.pauseTime||0===this.rate?this.pauseTime=t:this.startTime=performance.now()-t/this.rate}get playbackRate(){return this.rate}set playbackRate(t){this.rate=t}}const B=t=>(t=>Array.isArray(t)&&r(t[0]))(t)?C(t):t,C=([t,e,n,a])=>`cubic-bezier(${t}, ${e}, ${n}, ${a})`,I=t=>document.createElement("div").animate(t,{duration:.001}),z={cssRegisterProperty:()=>"undefined"!=typeof CSS&&Object.hasOwnProperty.call(CSS,"registerProperty"),waapi:()=>Object.hasOwnProperty.call(Element.prototype,"animate"),partialKeyframes:()=>{try{I({opacity:[1]})}catch(t){return!1}return!0},finished:()=>Boolean(I({opacity:[0,1]}).finished)},K={},N={};for(const t in z)N[t]=()=>(void 0===K[t]&&(K[t]=z[t]()),K[t]);const X=t=>Array.isArray(t)?t:[t];function Y(t){return y[t]&&(t=y[t]),x(t)?M(t):t}const Z={get:(t,e)=>{e=Y(e);let n=j(e)?t.style.getPropertyValue(e):getComputedStyle(t)[e];if(!n&&0!==n){const t=w.get(e);t&&(n=t.initialValue)}return n},set:(t,e,n)=>{e=Y(e),j(e)?t.style.setProperty(e,n):t.style[e]=n}};function _(t,e=!0){if(t&&"finished"!==t.playState)try{t.stop?t.stop():(e&&t.commitStyles(),t.cancel())}catch(t){}}function G(e,a,c,u={}){let h,{duration:f=i.duration,delay:d=i.delay,endDelay:p=i.endDelay,repeat:g=i.repeat,easing:v=i.easing,direction:b,offset:M,allowWebkitAcceleration:T=!1}=u;const S=n(e);let O=N.waapi();const k=x(a);k&&((t,e)=>{y[e]&&(e=y[e]);const{transforms:a}=n(t);var i,r;r=e,-1===(i=a).indexOf(r)&&i.push(r),t.style.transform=A(a)})(e,a);const R=Y(a),P=function(e,n){return e.has(n)||e.set(n,new t),e.get(n)}(S.values,R),E=w.get(R);return _(P.animation,!(s(v)&&P.generator)),()=>{const t=()=>{var t,n;return null!==(n=null!==(t=Z.get(e,R))&&void 0!==t?t:null==E?void 0:E.initialValue)&&void 0!==n?n:0};let n=function(t,e){for(let n=0;n<t.length;n++)null===t[n]&&(t[n]=n?t[n-1]:e());return t}(X(c),t);if(s(v)){const e=v.createAnimation(n,t,k,R,P);v=e.easing,void 0!==e.keyframes&&(n=e.keyframes),void 0!==e.duration&&(f=e.duration)}if(j(R)&&(N.cssRegisterProperty()?function(t){if(!D.has(t)){D.add(t);try{const{syntax:e,initialValue:n}=w.has(t)?w.get(t):{};CSS.registerProperty({name:t,inherits:!1,syntax:e,initialValue:n})}catch(t){}}}(R):O=!1),O){E&&(n=n.map((t=>r(t)?E.toDefaultUnit(t):t))),N.partialKeyframes()||1!==n.length||n.unshift(t());const a={delay:m(d),duration:m(f),endDelay:m(p),easing:o(v)?void 0:B(v),direction:b,iterations:g+1,fill:"both"};h=e.animate({[R]:n,offset:M,easing:o(v)?v.map(B):void 0},a),h.finished||(h.finished=new Promise(((t,e)=>{h.onfinish=t,h.oncancel=e})));const i=n[n.length-1];h.finished.then((()=>{Z.set(e,R,i),h.cancel()})).catch(l),T||(h.playbackRate=1.000001)}else if(k&&n.every(r)){1===n.length&&n.unshift(parseFloat(t()));h=new U((t=>{E&&(t=E.toDefaultUnit(t)),Z.set(e,R,t)}),n,Object.assign(Object.assign({},u),{duration:f,easing:v}))}else{const t=n[n.length-1];Z.set(e,R,E&&r(t)?E.toDefaultUnit(t):t)}return P.setAnimation(h),h}}const H=(t,e)=>t[e]?Object.assign(Object.assign({},t),t[e]):Object.assign({},t);function J(t,e){var n;return"string"==typeof t?e?(null!==(n=e[t])&&void 0!==n||(e[t]=document.querySelectorAll(t)),t=e[t]):t=document.querySelectorAll(t):t instanceof Element&&(t=[t]),Array.from(t)}const L=t=>t(),Q=(t,e=i.duration)=>new Proxy({animations:t.map(L).filter(Boolean),duration:e},et),tt=t=>t.animations[0],et={get:(t,e)=>{var n,a;switch(e){case"duration":return t.duration;case"currentTime":let i=(null===(n=tt(t))||void 0===n?void 0:n[e])||0;return i?i/1e3:0;case"playbackRate":return null===(a=tt(t))||void 0===a?void 0:a[e];case"finished":return t.finished||(t.finished=Promise.all(t.animations.map(nt)).catch(l)),t.finished;case"stop":return()=>t.animations.forEach((t=>_(t)));default:return()=>t.animations.forEach((t=>t[e]()))}},set:(t,e,n)=>{switch(e){case"currentTime":n=m(n);case"currentTime":case"playbackRate":for(let a=0;a<t.animations.length;a++)t.animations[a][e]=n;return!0}return!1}},nt=t=>t.finished;function at(t=.1,{start:e=0,from:n=0,easing:a}={}){return(i,s)=>{const o=r(n)?n:function(t,e){if("first"===t)return 0;{const n=e-1;return"last"===t?n:n/2}}(n,s),c=Math.abs(o-i);let l=t*c;if(a){const t=s*i;l=V(a)(l/t)*t}return e+l}}function it(t,e,n){return"function"==typeof t?t(e,n):t}function rt(t,e,n={}){const a=(t=J(t)).length,i=[];for(let r=0;r<a;r++){const s=t[r];for(const t in e){const o=H(n,t);o.delay=it(o.delay,r,a);const c=G(s,t,e[t],o);i.push(c)}}return Q(i,n.duration)}var st=function(){};function ot(t,e,n,a){var i;return r(e)?e:e.startsWith("-")||e.startsWith("+")?Math.max(0,t+parseFloat(e)):"<"===e?n:null!==(i=a.get(e))&&void 0!==i?i:t}function ct(t,e,n,i,r,s){!function(t,e,n){for(let i=0;i<t.length;i++){const r=t[i];r.at>e&&r.at<n&&(a(t,r),i--)}}(t,r,s);for(let a=0;a<e.length;a++)t.push({value:e[a],at:c(r,s,i[a]),easing:F(n,a)})}function lt(t,e){return t.at===e.at?null===t.value?1:-1:t.at-e.at}function ut(t,e={}){var n;const a=function(t,e={}){var{defaultOptions:n={}}=e,a=function(t,e){var n={};for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&e.indexOf(a)<0&&(n[a]=t[a]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(a=Object.getOwnPropertySymbols(t);i<a.length;i++)e.indexOf(a[i])<0&&Object.prototype.propertyIsEnumerable.call(t,a[i])&&(n[a[i]]=t[a[i]])}return n}(e,["defaultOptions"]);const r=[],o=new Map,c={},l=new Map;let u=0,m=0,p=0;for(let e=0;e<t.length;e++){const[a,r,h={}]=t[e];void 0!==h.at&&(m=ot(m,h.at,u,l));let g=0;const y=J(a,c),v=y.length;for(let t=0;t<v;t++){const e=ht(y[t],o);for(const a in r){const o=ft(a,e);let c=X(r[a]);const l=H(h,a);let{duration:u=n.duration||i.duration,easing:y=n.easing||i.easing}=l;if(s(y)){const t=x(a);st(2===c.length||!t,"spring must be provided 2 keyframes within timeline");const e=y.createAnimation(c,(()=>"0"),t);y=e.easing,void 0!==e.keyframes&&(c=e.keyframes),void 0!==e.duration&&(u=e.duration)}const b=it(h.delay,t,v)||0,w=m+b,M=w+u;let{offset:T=d(c.length)}=l;1===T.length&&0===T[0]&&(T[1]=1);const S=length-c.length;S>0&&f(T,S),1===c.length&&c.unshift(null),ct(o,c,y,T,w,M),g=Math.max(b+u,g),p=Math.max(M,p)}}u=m,m+=g}return o.forEach(((t,e)=>{for(const s in t){const o=t[s];o.sort(lt);const c=[],l=[],u=[];for(let t=0;t<o.length;t++){const{at:e,value:n,easing:a}=o[t];c.push(n),l.push(h(0,p,e)),u.push(a||i.easing)}0!==l[0]&&(l.unshift(0),c.unshift(c[0]),u.unshift("linear")),1!==l[l.length-1]&&(l.push(1),c.push(null)),r.push([e,s,c,Object.assign(Object.assign(Object.assign({},n),{duration:p,easing:u,offset:l}),a)])}})),r}(t,e),r=a.map((t=>G(...t))).filter(Boolean);return Q(r,null===(n=a[0])||void 0===n?void 0:n[3].duration)}function ht(t,e){return!e.has(t)&&e.set(t,{}),e.get(t)}function ft(t,e){return e[t]||(e[t]=[]),e[t]}"production"!==process.env.NODE_ENV&&(st=function(t,e){if(!t)throw new Error(e)});function dt(t,e,n){const a=Math.max(e-5,0);return i=n-t(a),(r=e-a)?i*(1e3/r):0;var i,r}const mt=100,pt=10,gt=1;const yt=({stiffness:t=mt,damping:e=pt,mass:n=gt,from:a=0,to:i=1,velocity:r=0,restSpeed:s=2,restDistance:o=.5}={})=>{r=r?p(r):0;const c={done:!1,hasReachedTarget:!1,current:a,target:i},l=i-a,u=Math.sqrt(t/n)/1e3,h=((t=mt,e=pt,n=gt)=>e/(2*Math.sqrt(t*n)))(t,e,n);let f;if(h<1){const t=u*Math.sqrt(1-h*h);f=e=>i-Math.exp(-h*u*e)*((h*u*l-r)/t*Math.sin(t*e)+l*Math.cos(t*e))}else f=t=>i-Math.exp(-u*t)*(l+(u*l-r)*t);return t=>{c.current=f(t);const e=0===t?r:dt(f,t,c.current),n=Math.abs(e)<=s,l=Math.abs(i-c.current)<=o;var u,h,d;return c.done=n&&l,c.hasReachedTarget=(u=a,h=i,d=c.current,u<h&&d>=h||u>h&&d<=h),c}};function vt(t){const e=new WeakMap;return(n={})=>{const a=new Map,i=(e=0,i=100,r=0,s=!1)=>{const o=`${e}-${i}-${r}-${s}`;return a.has(o)||a.set(o,t(Object.assign({from:e,to:i,velocity:r,restSpeed:s?.05:2,restDistance:s?.01:.5},n))),a.get(o)},r=t=>(e.has(t)||e.set(t,function(t){let e,n=10,a=t(0);const i=[a.current];for(;!a.done&&n<1e4;)a=t(n),i.push(a.done?a.target:a.current),void 0===e&&a.hasReachedTarget&&(e=n),n+=10;const r=n-10;return 1===i.length&&i.push(a.current),{keyframes:i,duration:r/1e3,overshootDuration:(null!=e?e:r)/1e3}}(t)),e.get(t));return{createAnimation:(t,e,n,a,s)=>{var o,c;let l;const u=t.length;if(n&&u<=2&&t.every(bt)){const n=t[u-1],h=1===u?null:t[0];let f=0,d=0;const m=null==s?void 0:s.generator;if(m){const{animation:e,generatorStartTime:n}=s,a=(null==e?void 0:e.startTime)||n||0,i=(null==e?void 0:e.currentTime)||performance.now()-a,r=m(i).current;d=null!==(o=h)&&void 0!==o?o:r,(1===u||2===u&&null===t[0])&&(f=dt((t=>m(t).current),i,r))}else d=null!==(c=h)&&void 0!==c?c:parseFloat(e());const p=i(d,n,f,null==a?void 0:a.includes("scale")),g=r(p);l=Object.assign(Object.assign({},g),{easing:"linear"}),s&&(s.generator=p,s.generatorStartTime=performance.now())}else{l={easing:"ease",duration:r(i(0,100)).overshootDuration}}return l}}}}const bt=t=>"string"!=typeof t,wt=vt(yt),Mt=vt((({from:t=0,velocity:e=0,power:n=.8,decay:a=.325,bounceDamping:i,bounceStiffness:r,changeTarget:s,min:o,max:c,restDistance:l=.5,restSpeed:u})=>{a=m(a);const h={hasReachedTarget:!1,done:!1,current:t,target:t},f=t=>void 0===o?c:void 0===c||Math.abs(o-t)<Math.abs(c-t)?o:c;let d=n*e;const p=t+d,g=void 0===s?p:s(p);h.target=g,g!==p&&(d=g-t);const y=t=>-d*Math.exp(-t/a),v=t=>g+y(t),b=t=>{const e=y(t),n=v(t);h.done=Math.abs(e)<=l,h.current=h.done?g:n};let w,M;const T=t=>{var e;(e=h.current,void 0!==o&&e<o||void 0!==c&&e>c)&&(w=t,M=yt({from:h.current,to:f(h.current),velocity:dt(v,t,h.current),damping:i,stiffness:r,restDistance:l,restSpeed:u}))};return T(0),t=>{let e=!1;return M||void 0!==w||(e=!0,b(t),T(t)),void 0!==w&&t>w?(h.hasReachedTarget=!0,M(t-w)):(h.hasReachedTarget=!1,!e&&b(t),h)}}));function Tt(t,e){return Q([()=>{const n=new U(t,[0,1],e);return n.finished.catch((()=>{})),n}],null==e?void 0:e.duration)}function St(t,e,n){return("function"==typeof t?Tt:rt)(t,e,n)}export{St as animate,Mt as glide,wt as spring,at as stagger,Z as style,ut as timeline};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "motion",
3
3
  "description": "A tiny, performant animation library for the web",
4
- "version": "10.6.0-rc.5",
4
+ "version": "10.6.2",
5
5
  "license": "MIT",
6
6
  "author": "Matt Perry",
7
7
  "main": "dist/main.cjs.js",
@@ -19,14 +19,15 @@
19
19
  "sideEffects": false,
20
20
  "scripts": {
21
21
  "build": "rm -rf lib dist types && tsc -p . && rollup -c",
22
- "test": "jest --coverage --config jest.config.js"
22
+ "test": "jest --coverage --config jest.config.js",
23
+ "dev": "rollup -c -w"
23
24
  },
24
25
  "dependencies": {
25
- "@motionone/animation": "^10.6.0-rc.5",
26
- "@motionone/dom": "^10.6.0-rc.5",
27
- "@motionone/react": "^10.6.0-rc.5",
28
- "@motionone/svelte": "^10.6.0-rc.5",
29
- "@motionone/vue": "^10.6.0-rc.5"
26
+ "@motionone/animation": "^10.6.2",
27
+ "@motionone/dom": "^10.6.2",
28
+ "@motionone/react": "^10.6.2",
29
+ "@motionone/svelte": "^10.6.2",
30
+ "@motionone/vue": "^10.6.2"
30
31
  },
31
- "gitHead": "6fc943b6f24709de235d1bff0fb09e0f71de2bfb"
32
+ "gitHead": "b776bc7edd104b5545d2204713f7fb94eba50b21"
32
33
  }