motion 10.11.0 → 10.11.1

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,12 @@
2
2
 
3
3
  Motion One adheres to [Semantic Versioning](http://semver.org/).
4
4
 
5
+ ## [10.11.1] [2022-07-06]
6
+
7
+ ### Added
8
+
9
+ - In supported browsers, `inView` will use `document` as the default value for `root` to ensure `rootMargin` works within iframes.
10
+
5
11
  ## [10.11.0] [2022-06-24]
6
12
 
7
13
  ### Added
File without changes
File without changes
package/dist/main.cjs.js CHANGED
File without changes
package/dist/main.es.js CHANGED
File without changes
@@ -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";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=>"string"==typeof t,c=t=>"object"==typeof t&&Boolean(t.createAnimation),l=t=>Array.isArray(t)&&!s(t[0]),u=(t,e,n)=>-n*t+n*e+t,h=()=>{},f=t=>t,d=(t,e,n)=>e-t==0?1:(n-t)/(e-t);function p(t,e){const n=t[t.length-1];for(let a=1;a<=e;a++){const i=d(0,e,a);t.push(u(n,1,i))}}function m(t){const e=[0];return p(e,t-1),e}const g=t=>1e3*t,y=t=>t/1e3;const v=["","X","Y","Z"],b={x:"translateX",y:"translateY",z:"translateZ"},M={syntax:"<angle>",initialValue:"0deg",toDefaultUnit:t=>t+"deg"},w={translate:{syntax:"<length-percentage>",initialValue:"0px",toDefaultUnit:t=>t+"px"},rotate:M,scale:{syntax:"<number>",initialValue:1,toDefaultUnit:f},skew:M},T=new Map,O=t=>`--motion-${t}`,S=["x","y","z"];["translate","scale","rotate","skew"].forEach((t=>{v.forEach((e=>{S.push(t+e),T.set(O(t+e),w[t])}))}));const x=(t,e)=>S.indexOf(t)-S.indexOf(e),A=new Set(S),k=t=>A.has(t),j=t=>t.sort(x).reduce(D,"").trim(),D=(t,e)=>`${t} ${e}(var(${O(e)}))`,R=t=>t.startsWith("--"),P=new Set;const E=(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 f;const i=e=>function(t,e,n,a,i){let r,s,o=0;do{s=e+(n-e)/2,r=E(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:E(i(t),e,a)}const V=(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:$(.25,.1,.25,1),"ease-in":$(.42,0,1,1),"ease-in-out":$(.42,0,.58,1),"ease-out":$(0,0,.58,1)},I=/\((.*?)\)/;function F(t){if("function"==typeof t)return t;if(Array.isArray(t))return $(...t);if(q[t])return q[t];if(t.startsWith("steps")){const e=I.exec(t);if(e){const t=e[1].split(",");return V(parseFloat(t[0]),t[1].trim())}}return f}function W(t,e){return l(t)?t[((t,e,n)=>{const a=e-t;return((n-t)%a+a)%a+t})(0,t.length,e)]:t}function _(t,e=m(t.length),n=f){const a=t.length,i=a-e.length;return i>0&&p(e,i),i=>{let r=0;for(;r<a-2&&!(i<e[r+1]);r++);let s=(o=d(e[r],e[r+1],i),Math.min(1,Math.max(o,0)));var o;return s=W(n,r)(s),u(t[r],t[r+1],s)}}class U{constructor(t,e=[0,1],{easing:n=r.easing,duration:a=r.duration,delay:i=r.delay,endDelay:s=r.endDelay,repeat:o=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})),c(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=l(n)?f:F(n),p=a*(o+1),m=_(e,u,l(n)?n.map(F):f);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=p);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 f=r>=p?1:Math.min(l,1),g=m(d(f));t(g);"finished"===this.playState||r>=p+s?(this.playState="finished",null===(n=this.resolve)||void 0===n||n.call(this,g)):"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)&&s(t[0]))(t)?C(t):t,C=([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 L(t){return b[t]&&(t=b[t]),k(t)?O(t):t}const N={get:(t,e)=>{e=L(e);let n=R(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=L(e),R(e)?t.style.setProperty(e,n):t.style[e]=n}};function G(t,e=!0){if(t&&"finished"!==t.playState)try{t.stop?t.stop():(e&&t.commitStyles(),t.cancel())}catch(t){}}function H(t,n,i,o={}){const u=window.__MOTION_DEV_TOOLS_RECORD,f=!1!==o.record&&u;let d,{duration:p=r.duration,delay:m=r.delay,endDelay:y=r.endDelay,repeat:v=r.repeat,easing:M=r.easing,direction:w,offset:O,allowWebkitAcceleration:S=!1}=o;const x=a(t);let A=Y.waapi();const D=k(n);D&&((t,e)=>{b[e]&&(e=b[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 E=L(n),$=function(t,n){return t.has(n)||t.set(n,new e),t.get(n)}(x.values,E),V=T.get(E);return G($.animation,!(c(M)&&$.generator)&&!1!==o.record),()=>{const e=()=>{var e,n;return null!==(n=null!==(e=N.get(t,E))&&void 0!==e?e:null==V?void 0:V.initialValue)&&void 0!==n?n:0};let a=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(c(M)){const t=M.createAnimation(a,e,D,E,$);M=t.easing,void 0!==t.keyframes&&(a=t.keyframes),void 0!==t.duration&&(p=t.duration)}if(R(E)&&(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){}}}(E):A=!1),A){V&&(a=a.map((t=>s(t)?V.toDefaultUnit(t):t))),1!==a.length||Y.partialKeyframes()&&!f||a.unshift(e());const n={delay:g(m),duration:g(p),endDelay:g(y),easing:l(M)?void 0:B(M),direction:w,iterations:v+1,fill:"both"};d=t.animate({[E]:a,offset:O,easing:l(M)?M.map(B):void 0},n),d.finished||(d.finished=new Promise(((t,e)=>{d.onfinish=t,d.oncancel=e})));const i=a[a.length-1];d.finished.then((()=>{N.set(t,E,i),d.cancel()})).catch(h),S||(d.playbackRate=1.000001)}else if(D){a=a.map((t=>"string"==typeof t?parseFloat(t):t)),1===a.length&&a.unshift(parseFloat(e()));d=new U((e=>{V&&(e=V.toDefaultUnit(e)),N.set(t,E,e)}),a,Object.assign(Object.assign({},o),{duration:p,easing:M}))}else{const e=a[a.length-1];N.set(t,E,V&&s(e)?V.toDefaultUnit(e):e)}return f&&u(t,n,a,{duration:p,delay:m,easing:M,repeat:v,offset:O},"motion-one"),$.setAnimation(d),d}}const J=(t,e)=>t[e]?Object.assign(Object.assign({},t),t[e]):Object.assign({},t);function Q(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 tt=t=>t(),et=(t,e=r.duration)=>new Proxy({animations:t.map(tt).filter(Boolean),duration:e},nt),nt={get:(t,e)=>{const n=t.animations[0];switch(e){case"duration":return t.duration;case"currentTime":let a=(null==n?void 0:n[e])||0;return a?a/1e3:0;case"playbackRate":case"playState":return null==n?void 0:n[e];case"finished":return t.finished||(t.finished=Promise.all(t.animations.map(at)).catch(h)),t.finished;case"stop":return()=>t.animations.forEach((t=>G(t)));default:return void 0===(null==n?void 0:n[e])?void 0:()=>t.animations.forEach((t=>t[e]()))}},set:(t,e,n)=>{switch(e){case"currentTime":n=g(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=Q(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=it(o.delay,r,a);const c=H(s,t,e[t],o);i.push(c)}}return et(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:u(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,pt=1;const mt=({stiffness:t=ft,damping:e=dt,mass:n=pt,from:a=0,to:i=1,velocity:r=0,restSpeed:s=2,restDistance:o=.5}={})=>{r=r?y(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=pt)=>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 p=null==s?void 0:s.generator;if(p){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=p(i).current;d=null!==(o=h)&&void 0!==o?o:r,(1===u||2===u&&null===t[0])&&(f=ht((t=>p(t).current),i,r))}else d=null!==(c=h)&&void 0!==c?c:parseFloat(e());const m=i(d,n,f,null==a?void 0:a.includes("scale")),g=r(m);l=Object.assign(Object.assign({},g),{easing:"linear"}),s&&(s.generator=m,s.generatorStartTime=performance.now())}else{l={easing:"ease",duration:r(i(0,100)).overshootDuration}}return l}}}}const yt=t=>"string"!=typeof t,vt=gt(mt),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=g(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,m=void 0===s?p:s(p);h.target=m,m!==p&&(d=m-t);const y=t=>-d*Math.exp(-t/a),v=t=>m+y(t),b=t=>{const e=y(t),n=v(t);h.done=Math.abs(e)<=l,h.current=h.done?m:n};let M,w;const T=t=>{var e;(e=h.current,void 0!==o&&e<o||void 0!==c&&e>c)&&(M=t,w=mt({from:h.current,to:f(h.current),velocity:ht(v,t,h.current),damping:i,stiffness:r,restDistance:l,restSpeed:u}))};return T(0),t=>{let e=!1;return w||void 0!==M||(e=!0,b(t),T(t)),void 0!==M&&t>M?(h.hasReachedTarget=!0,w(t-M)):(h.hasReachedTarget=!1,!e&&b(t),h)}})),Mt={any:0,all:1};function wt(t,e){return et([()=>{const n=new U(t,[0,1],e);return n.finished.catch((()=>{})),n}],null==e?void 0:e.duration)}t.MotionValue=e,t.animate=function(t,e,n){return("function"==typeof t?wt:rt)(t,e,n)},t.glide=bt,t.inView=function(t,e,{root:n,margin:a,amount:i="any"}={}){if("undefined"==typeof IntersectionObserver)return()=>{};const r=Q(t),s=new WeakMap,o=new IntersectionObserver((t=>{t.forEach((t=>{const n=s.get(t.target);if(t.isIntersecting!==Boolean(n))if(t.isIntersecting){const n=e(t);"function"==typeof n?s.set(t.target,n):o.unobserve(t.target)}else n&&(n(t),s.delete(t.target))}))}),{root:n,rootMargin:a,threshold:"number"==typeof i?i:Mt[i]});return r.forEach((t=>o.observe(t))),()=>o.disconnect()},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 e=r*t;l=F(a)(l/e)*e}return e+l}},t.style=N,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,l={},u=new Map;let h=0,f=0,g=0;for(let e=0;e<t.length;e++){const a=t[e];if(o(a)){u.set(a,f);continue}if(!Array.isArray(a)){u.set(a.name,st(f,a.at,h,u));continue}const[i,d,y={}]=a;void 0!==y.at&&(f=st(f,y.at,h,u));let v=0;const b=Q(i,l),M=b.length;for(let t=0;t<M;t++){const e=lt(b[t],s);for(const a in d){const i=ut(a,e);let s=Z(d[a]);const o=J(y,a);let{duration:l=n.duration||r.duration,easing:u=n.easing||r.easing}=o;if(c(u)){const t=k(a);s.length;const e=u.createAnimation(s,(()=>"0"),t);u=e.easing,void 0!==e.keyframes&&(s=e.keyframes),void 0!==e.duration&&(l=e.duration)}const h=it(y.delay,t,M)||0,b=f+h,w=b+l;let{offset:T=m(s.length)}=o;1===T.length&&0===T[0]&&(T[1]=1);const O=length-s.length;O>0&&p(T,O),1===s.length&&s.unshift(null),ot(i,s,u,T,b,w),v=Math.max(h+l,v),g=Math.max(w,g)}}h=f,f+=v}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(d(0,g,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:g,easing:u,offset:l}),a)])}})),i}(t,e),i=a.map((t=>H(...t))).filter(Boolean);return et(i,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=>"string"==typeof t,c=t=>"object"==typeof t&&Boolean(t.createAnimation),l=t=>Array.isArray(t)&&!s(t[0]),u=(t,e,n)=>-n*t+n*e+t,f=()=>{},h=t=>t,d=(t,e,n)=>e-t==0?1:(n-t)/(e-t);function p(t,e){const n=t[t.length-1];for(let a=1;a<=e;a++){const i=d(0,e,a);t.push(u(n,1,i))}}function m(t){const e=[0];return p(e,t-1),e}const g=t=>1e3*t,y=t=>t/1e3;const v=["","X","Y","Z"],b={x:"translateX",y:"translateY",z:"translateZ"},M={syntax:"<angle>",initialValue:"0deg",toDefaultUnit:t=>t+"deg"},w={translate:{syntax:"<length-percentage>",initialValue:"0px",toDefaultUnit:t=>t+"px"},rotate:M,scale:{syntax:"<number>",initialValue:1,toDefaultUnit:h},skew:M},O=new Map,T=t=>`--motion-${t}`,S=["x","y","z"];["translate","scale","rotate","skew"].forEach((t=>{v.forEach((e=>{S.push(t+e),O.set(T(t+e),w[t])}))}));const x=(t,e)=>S.indexOf(t)-S.indexOf(e),A=new Set(S),k=t=>A.has(t),j=t=>t.sort(x).reduce(D,"").trim(),D=(t,e)=>`${t} ${e}(var(${T(e)}))`,R=t=>t.startsWith("--"),P=new Set;const E=(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=E(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:E(i(t),e,a)}const V=(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:$(.25,.1,.25,1),"ease-in":$(.42,0,1,1),"ease-in-out":$(.42,0,.58,1),"ease-out":$(0,0,.58,1)},I=/\((.*?)\)/;function F(t){if("function"==typeof t)return t;if(Array.isArray(t))return $(...t);if(q[t])return q[t];if(t.startsWith("steps")){const e=I.exec(t);if(e){const t=e[1].split(",");return V(parseFloat(t[0]),t[1].trim())}}return h}function W(t,e){return l(t)?t[((t,e,n)=>{const a=e-t;return((n-t)%a+a)%a+t})(0,t.length,e)]:t}function _(t,e=m(t.length),n=h){const a=t.length,i=a-e.length;return i>0&&p(e,i),i=>{let r=0;for(;r<a-2&&!(i<e[r+1]);r++);let s=(o=d(e[r],e[r+1],i),Math.min(1,Math.max(o,0)));var o;return s=W(n,r)(s),u(t[r],t[r+1],s)}}class U{constructor(t,e=[0,1],{easing:n=r.easing,duration:a=r.duration,delay:i=r.delay,endDelay:s=r.endDelay,repeat:o=r.repeat,offset:u,direction:f="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})),c(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=l(n)?h:F(n),p=a*(o+1),m=_(e,u,l(n)?n.map(F):h);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=p);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"===f||"alternate"===f&&u||"alternate-reverse"===f&&!u)&&(l=1-l);const h=r>=p?1:Math.min(l,1),g=m(d(h));t(g);"finished"===this.playState||r>=p+s?(this.playState="finished",null===(n=this.resolve)||void 0===n||n.call(this,g)):"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)&&s(t[0]))(t)?C(t):t,C=([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 L(t){return b[t]&&(t=b[t]),k(t)?T(t):t}const N={get:(t,e)=>{e=L(e);let n=R(e)?t.style.getPropertyValue(e):getComputedStyle(t)[e];if(!n&&0!==n){const t=O.get(e);t&&(n=t.initialValue)}return n},set:(t,e,n)=>{e=L(e),R(e)?t.style.setProperty(e,n):t.style[e]=n}};function G(t,e=!0){if(t&&"finished"!==t.playState)try{t.stop?t.stop():(e&&t.commitStyles(),t.cancel())}catch(t){}}function H(t,n,i,o={}){const u=window.__MOTION_DEV_TOOLS_RECORD,h=!1!==o.record&&u;let d,{duration:p=r.duration,delay:m=r.delay,endDelay:y=r.endDelay,repeat:v=r.repeat,easing:M=r.easing,direction:w,offset:T,allowWebkitAcceleration:S=!1}=o;const x=a(t);let A=Y.waapi();const D=k(n);D&&((t,e)=>{b[e]&&(e=b[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 E=L(n),$=function(t,n){return t.has(n)||t.set(n,new e),t.get(n)}(x.values,E),V=O.get(E);return G($.animation,!(c(M)&&$.generator)&&!1!==o.record),()=>{const e=()=>{var e,n;return null!==(n=null!==(e=N.get(t,E))&&void 0!==e?e:null==V?void 0:V.initialValue)&&void 0!==n?n:0};let a=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(c(M)){const t=M.createAnimation(a,e,D,E,$);M=t.easing,void 0!==t.keyframes&&(a=t.keyframes),void 0!==t.duration&&(p=t.duration)}if(R(E)&&(Y.cssRegisterProperty()?function(t){if(!P.has(t)){P.add(t);try{const{syntax:e,initialValue:n}=O.has(t)?O.get(t):{};CSS.registerProperty({name:t,inherits:!1,syntax:e,initialValue:n})}catch(t){}}}(E):A=!1),A){V&&(a=a.map((t=>s(t)?V.toDefaultUnit(t):t))),1!==a.length||Y.partialKeyframes()&&!h||a.unshift(e());const n={delay:g(m),duration:g(p),endDelay:g(y),easing:l(M)?void 0:B(M),direction:w,iterations:v+1,fill:"both"};d=t.animate({[E]:a,offset:T,easing:l(M)?M.map(B):void 0},n),d.finished||(d.finished=new Promise(((t,e)=>{d.onfinish=t,d.oncancel=e})));const i=a[a.length-1];d.finished.then((()=>{N.set(t,E,i),d.cancel()})).catch(f),S||(d.playbackRate=1.000001)}else if(D){a=a.map((t=>"string"==typeof t?parseFloat(t):t)),1===a.length&&a.unshift(parseFloat(e()));d=new U((e=>{V&&(e=V.toDefaultUnit(e)),N.set(t,E,e)}),a,Object.assign(Object.assign({},o),{duration:p,easing:M}))}else{const e=a[a.length-1];N.set(t,E,V&&s(e)?V.toDefaultUnit(e):e)}return h&&u(t,n,a,{duration:p,delay:m,easing:M,repeat:v,offset:T},"motion-one"),$.setAnimation(d),d}}const J=(t,e)=>t[e]?Object.assign(Object.assign({},t),t[e]):Object.assign({},t);function Q(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 tt=t=>t(),et=(t,e=r.duration)=>new Proxy({animations:t.map(tt).filter(Boolean),duration:e},nt),nt={get:(t,e)=>{const n=t.animations[0];switch(e){case"duration":return t.duration;case"currentTime":let a=(null==n?void 0:n[e])||0;return a?a/1e3:0;case"playbackRate":case"playState":return null==n?void 0:n[e];case"finished":return t.finished||(t.finished=Promise.all(t.animations.map(at)).catch(f)),t.finished;case"stop":return()=>t.animations.forEach((t=>G(t)));default:return void 0===(null==n?void 0:n[e])?void 0:()=>t.animations.forEach((t=>t[e]()))}},set:(t,e,n)=>{switch(e){case"currentTime":n=g(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=Q(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=it(o.delay,r,a);const c=H(s,t,e[t],o);i.push(c)}}return et(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:u(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 ft(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 ht=100,dt=10,pt=1;const mt=({stiffness:t=ht,damping:e=dt,mass:n=pt,from:a=0,to:i=1,velocity:r=0,restSpeed:s=2,restDistance:o=.5}={})=>{r=r?y(r):0;const c={done:!1,hasReachedTarget:!1,current:a,target:i},l=i-a,u=Math.sqrt(t/n)/1e3,f=((t=ht,e=dt,n=pt)=>e/(2*Math.sqrt(t*n)))(t,e,n);let h;if(f<1){const t=u*Math.sqrt(1-f*f);h=e=>i-Math.exp(-f*u*e)*((f*u*l-r)/t*Math.sin(t*e)+l*Math.cos(t*e))}else h=t=>i-Math.exp(-u*t)*(l+(u*l-r)*t);return t=>{c.current=h(t);const e=0===t?r:ft(h,t,c.current),n=Math.abs(e)<=s,l=Math.abs(i-c.current)<=o;var u,f,d;return c.done=n&&l,c.hasReachedTarget=(u=a,f=i,d=c.current,u<f&&d>=f||u>f&&d<=f),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],f=1===u?null:t[0];let h=0,d=0;const p=null==s?void 0:s.generator;if(p){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=p(i).current;d=null!==(o=f)&&void 0!==o?o:r,(1===u||2===u&&null===t[0])&&(h=ft((t=>p(t).current),i,r))}else d=null!==(c=f)&&void 0!==c?c:parseFloat(e());const m=i(d,n,h,null==a?void 0:a.includes("scale")),g=r(m);l=Object.assign(Object.assign({},g),{easing:"linear"}),s&&(s.generator=m,s.generatorStartTime=performance.now())}else{l={easing:"ease",duration:r(i(0,100)).overshootDuration}}return l}}}}const yt=t=>"string"!=typeof t,vt=gt(mt),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=g(a);const f={hasReachedTarget:!1,done:!1,current:t,target:t},h=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,m=void 0===s?p:s(p);f.target=m,m!==p&&(d=m-t);const y=t=>-d*Math.exp(-t/a),v=t=>m+y(t),b=t=>{const e=y(t),n=v(t);f.done=Math.abs(e)<=l,f.current=f.done?m:n};let M,w;const O=t=>{var e;(e=f.current,void 0!==o&&e<o||void 0!==c&&e>c)&&(M=t,w=mt({from:f.current,to:h(f.current),velocity:ft(v,t,f.current),damping:i,stiffness:r,restDistance:l,restSpeed:u}))};return O(0),t=>{let e=!1;return w||void 0!==M||(e=!0,b(t),O(t)),void 0!==M&&t>M?(f.hasReachedTarget=!0,w(t-M)):(f.hasReachedTarget=!1,!e&&b(t),f)}}));let Mt;function wt(){if(void 0===Mt)try{new IntersectionObserver(f,{root:document}),Mt=!0}catch(t){Mt=!1}return Mt?document:void 0}const Ot={any:0,all:1};function Tt(t,e){return et([()=>{const n=new U(t,[0,1],e);return n.finished.catch((()=>{})),n}],null==e?void 0:e.duration)}t.MotionValue=e,t.animate=function(t,e,n){return("function"==typeof t?Tt:rt)(t,e,n)},t.glide=bt,t.inView=function(t,e,{root:n,margin:a,amount:i="any"}={}){if("undefined"==typeof IntersectionObserver)return()=>{};const r=Q(t),s=new WeakMap,o=new IntersectionObserver((t=>{t.forEach((t=>{const n=s.get(t.target);if(t.isIntersecting!==Boolean(n))if(t.isIntersecting){const n=e(t);"function"==typeof n?s.set(t.target,n):o.unobserve(t.target)}else n&&(n(t),s.delete(t.target))}))}),{root:n||wt(),rootMargin:a,threshold:"number"==typeof i?i:Ot[i]});return r.forEach((t=>o.observe(t))),()=>o.disconnect()},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 e=r*t;l=F(a)(l/e)*e}return e+l}},t.style=N,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,l={},u=new Map;let f=0,h=0,g=0;for(let e=0;e<t.length;e++){const a=t[e];if(o(a)){u.set(a,h);continue}if(!Array.isArray(a)){u.set(a.name,st(h,a.at,f,u));continue}const[i,d,y={}]=a;void 0!==y.at&&(h=st(h,y.at,f,u));let v=0;const b=Q(i,l),M=b.length;for(let t=0;t<M;t++){const e=lt(b[t],s);for(const a in d){const i=ut(a,e);let s=Z(d[a]);const o=J(y,a);let{duration:l=n.duration||r.duration,easing:u=n.easing||r.easing}=o;if(c(u)){const t=k(a);s.length;const e=u.createAnimation(s,(()=>"0"),t);u=e.easing,void 0!==e.keyframes&&(s=e.keyframes),void 0!==e.duration&&(l=e.duration)}const f=it(y.delay,t,M)||0,b=h+f,w=b+l;let{offset:O=m(s.length)}=o;1===O.length&&0===O[0]&&(O[1]=1);const T=length-s.length;T>0&&p(O,T),1===s.length&&s.unshift(null),ot(i,s,u,O,b,w),v=Math.max(f+l,v),g=Math.max(w,g)}}f=h,h+=v}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(d(0,g,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:g,easing:u,offset:l}),a)])}})),i}(t,e),i=a.map((t=>H(...t))).filter(Boolean);return et(i,null===(n=a[0])||void 0===n?void 0:n[3].duration)},Object.defineProperty(t,"__esModule",{value:!0})}));
@@ -1373,6 +1373,19 @@
1373
1373
 
1374
1374
  const glide = createGeneratorEasing(glide$1);
1375
1375
 
1376
+ let supportsDocumentRoot;
1377
+ function getDefaultRoot() {
1378
+ if (supportsDocumentRoot === undefined) {
1379
+ try {
1380
+ new IntersectionObserver(noop, { root: document });
1381
+ supportsDocumentRoot = true;
1382
+ }
1383
+ catch (e) {
1384
+ supportsDocumentRoot = false;
1385
+ }
1386
+ }
1387
+ return supportsDocumentRoot ? document : undefined;
1388
+ }
1376
1389
  const thresholds = {
1377
1390
  any: 0,
1378
1391
  all: 1,
@@ -1414,7 +1427,7 @@
1414
1427
  });
1415
1428
  };
1416
1429
  const observer = new IntersectionObserver(onIntersectionChange, {
1417
- root,
1430
+ root: root || getDefaultRoot(),
1418
1431
  rootMargin,
1419
1432
  threshold: typeof amount === "number" ? amount : thresholds[amount],
1420
1433
  });
package/dist/react.cjs.js CHANGED
File without changes
package/dist/react.es.js CHANGED
File without changes
@@ -1 +1 @@
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 r={duration:.3,delay:0,endDelay:0,repeat:0,easing:"ease"},i=t=>"number"==typeof t,s=t=>"string"==typeof t,o=t=>"object"==typeof t&&Boolean(t.createAnimation),c=t=>Array.isArray(t)&&!i(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 r=f(0,e,a);t.push(l(n,1,r))}}function p(t){const e=[0];return d(e,t-1),e}const m=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"},w={translate:{syntax:"<length-percentage>",initialValue:"0px",toDefaultUnit:t=>t+"px"},rotate:b,scale:{syntax:"<number>",initialValue:1,toDefaultUnit:h},skew:b},M=new Map,O=t=>`--motion-${t}`,T=["x","y","z"];["translate","scale","rotate","skew"].forEach((t=>{y.forEach((e=>{T.push(t+e),M.set(O(t+e),w[t])}))}));const S=(t,e)=>T.indexOf(t)-T.indexOf(e),x=new Set(T),A=t=>x.has(t),k=t=>t.sort(S).reduce(D,"").trim(),D=(t,e)=>`${t} ${e}(var(${O(e)}))`,j=t=>t.startsWith("--"),R=new Set;const E=(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 h;const r=e=>function(t,e,n,a,r){let i,s,o=0;do{s=e+(n-e)/2,i=E(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:E(r(t),e,a)}const $=(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},q={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)},V=/\((.*?)\)/;function I(t){if("function"==typeof t)return t;if(Array.isArray(t))return P(...t);if(q[t])return q[t];if(t.startsWith("steps")){const e=V.exec(t);if(e){const t=e[1].split(",");return $(parseFloat(t[0]),t[1].trim())}}return h}function F(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 W(t,e=p(t.length),n=h){const a=t.length,r=a-e.length;return r>0&&d(e,r),r=>{let i=0;for(;i<a-2&&!(r<e[i+1]);i++);let s=(o=f(e[i],e[i+1],r),Math.min(1,Math.max(o,0)));var o;return s=F(n,i)(s),l(t[i],t[i+1],s)}}class U{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:f="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 d=c(n)?h:I(n),p=a*(l+1),m=W(e,u,c(n)?n.map(I):h);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=p);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"===f||"alternate"===f&&u||"alternate-reverse"===f&&!u)&&(l=1-l);const h=r>=p?1:Math.min(l,1),g=m(d(h));t(g);"finished"===this.playState||r>=p+s?(this.playState="finished",null===(n=this.resolve)||void 0===n||n.call(this,g)):"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 _=t=>(t=>Array.isArray(t)&&i(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}),z={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)},N={},K={};for(const t in z)K[t]=()=>(void 0===N[t]&&(N[t]=z[t]()),N[t]);const X=t=>Array.isArray(t)?t:[t];function Y(t){return v[t]&&(t=v[t]),A(t)?O(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=M.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 L(t,e=!0){if(t&&"finished"!==t.playState)try{t.stop?t.stop():(e&&t.commitStyles(),t.cancel())}catch(t){}}function G(e,a,s,l={}){const h=window.__MOTION_DEV_TOOLS_RECORD,f=!1!==l.record&&h;let d,{duration:p=r.duration,delay:g=r.delay,endDelay:y=r.endDelay,repeat:b=r.repeat,easing:w=r.easing,direction:O,offset:T,allowWebkitAcceleration:S=!1}=l;const x=n(e);let D=K.waapi();const E=A(a);E&&((t,e)=>{v[e]&&(e=v[e]);const{transforms:a}=n(t);var r,i;i=e,-1===(r=a).indexOf(i)&&r.push(i),t.style.transform=k(a)})(e,a);const P=Y(a),$=function(e,n){return e.has(n)||e.set(n,new t),e.get(n)}(x.values,P),q=M.get(P);return L($.animation,!(o(w)&&$.generator)&&!1!==l.record),()=>{const t=()=>{var t,n;return null!==(n=null!==(t=Z.get(e,P))&&void 0!==t?t:null==q?void 0:q.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(s),t);if(o(w)){const e=w.createAnimation(n,t,E,P,$);w=e.easing,void 0!==e.keyframes&&(n=e.keyframes),void 0!==e.duration&&(p=e.duration)}if(j(P)&&(K.cssRegisterProperty()?function(t){if(!R.has(t)){R.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){}}}(P):D=!1),D){q&&(n=n.map((t=>i(t)?q.toDefaultUnit(t):t))),1!==n.length||K.partialKeyframes()&&!f||n.unshift(t());const a={delay:m(g),duration:m(p),endDelay:m(y),easing:c(w)?void 0:_(w),direction:O,iterations:b+1,fill:"both"};d=e.animate({[P]:n,offset:T,easing:c(w)?w.map(_):void 0},a),d.finished||(d.finished=new Promise(((t,e)=>{d.onfinish=t,d.oncancel=e})));const r=n[n.length-1];d.finished.then((()=>{Z.set(e,P,r),d.cancel()})).catch(u),S||(d.playbackRate=1.000001)}else if(E){n=n.map((t=>"string"==typeof t?parseFloat(t):t)),1===n.length&&n.unshift(parseFloat(t()));d=new U((t=>{q&&(t=q.toDefaultUnit(t)),Z.set(e,P,t)}),n,Object.assign(Object.assign({},l),{duration:p,easing:w}))}else{const t=n[n.length-1];Z.set(e,P,q&&i(t)?q.toDefaultUnit(t):t)}return f&&h(e,a,n,{duration:p,delay:g,easing:w,repeat:b,offset:T},"motion-one"),$.setAnimation(d),d}}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 Q=t=>t(),tt=(t,e=r.duration)=>new Proxy({animations:t.map(Q).filter(Boolean),duration:e},et),et={get:(t,e)=>{const n=t.animations[0];switch(e){case"duration":return t.duration;case"currentTime":let a=(null==n?void 0:n[e])||0;return a?a/1e3:0;case"playbackRate":case"playState":return null==n?void 0:n[e];case"finished":return t.finished||(t.finished=Promise.all(t.animations.map(nt)).catch(u)),t.finished;case"stop":return()=>t.animations.forEach((t=>L(t)));default:return void 0===(null==n?void 0:n[e])?void 0:()=>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(r,s)=>{const o=i(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-r);let l=t*c;if(a){const e=s*t;l=I(a)(l/e)*e}return e+l}}function rt(t,e,n){return"function"==typeof t?t(e,n):t}function it(t,e,n={}){const a=(t=J(t)).length,r=[];for(let i=0;i<a;i++){const s=t[i];for(const t in e){const o=H(n,t);o.delay=rt(o.delay,i,a);const c=G(s,t,e[t],o);r.push(c)}}return tt(r,n.duration)}var st=function(){};function ot(t,e,n,a){var r;return i(e)?e:e.startsWith("-")||e.startsWith("+")?Math.max(0,t+parseFloat(e)):"<"===e?n:null!==(r=a.get(e))&&void 0!==r?r:t}function ct(t,e,n,r,i,s){!function(t,e,n){for(let r=0;r<t.length;r++){const i=t[r];i.at>e&&i.at<n&&(a(t,i),r--)}}(t,i,s);for(let a=0;a<e.length;a++)t.push({value:e[a],at:l(i,s,r[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 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 i=[],c=new Map,l={},u=new Map;let h=0,m=0,g=0;for(let e=0;e<t.length;e++){const a=t[e];if(s(a)){u.set(a,m);continue}if(!Array.isArray(a)){u.set(a.name,ot(m,a.at,h,u));continue}const[i,f,y={}]=a;void 0!==y.at&&(m=ot(m,y.at,h,u));let v=0;const b=J(i,l),w=b.length;for(let t=0;t<w;t++){const e=ht(b[t],c);for(const a in f){const i=ft(a,e);let s=X(f[a]);const c=H(y,a);let{duration:l=n.duration||r.duration,easing:u=n.easing||r.easing}=c;if(o(u)){const t=A(a);st(2===s.length||!t,"spring must be provided 2 keyframes within timeline");const e=u.createAnimation(s,(()=>"0"),t);u=e.easing,void 0!==e.keyframes&&(s=e.keyframes),void 0!==e.duration&&(l=e.duration)}const h=rt(y.delay,t,w)||0,b=m+h,M=b+l;let{offset:O=p(s.length)}=c;1===O.length&&0===O[0]&&(O[1]=1);const T=length-s.length;T>0&&d(O,T),1===s.length&&s.unshift(null),ct(i,s,u,O,b,M),v=Math.max(h+l,v),g=Math.max(M,g)}}h=m,m+=v}return c.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(f(0,g,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:g,easing:u,offset:l}),a)])}})),i}(t,e),i=a.map((t=>G(...t))).filter(Boolean);return tt(i,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 r=n-t(a),(i=e-a)?r*(1e3/i):0;var r,i}const pt=100,mt=10,gt=1;const yt=({stiffness:t=pt,damping:e=mt,mass:n=gt,from:a=0,to:r=1,velocity:i=0,restSpeed:s=2,restDistance:o=.5}={})=>{i=i?g(i):0;const c={done:!1,hasReachedTarget:!1,current:a,target:r},l=r-a,u=Math.sqrt(t/n)/1e3,h=((t=pt,e=mt,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=>r-Math.exp(-h*u*e)*((h*u*l-i)/t*Math.sin(t*e)+l*Math.cos(t*e))}else f=t=>r-Math.exp(-u*t)*(l+(u*l-i)*t);return t=>{c.current=f(t);const e=0===t?i:dt(f,t,c.current),n=Math.abs(e)<=s,l=Math.abs(r-c.current)<=o;var u,h,d;return c.done=n&&l,c.hasReachedTarget=(u=a,h=r,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,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)=>{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 p=null==s?void 0:s.generator;if(p){const{animation:e,generatorStartTime:n}=s,a=(null==e?void 0:e.startTime)||n||0,r=(null==e?void 0:e.currentTime)||performance.now()-a,i=p(r).current;d=null!==(o=h)&&void 0!==o?o:i,(1===u||2===u&&null===t[0])&&(f=dt((t=>p(t).current),r,i))}else d=null!==(c=h)&&void 0!==c?c:parseFloat(e());const m=r(d,n,f,null==a?void 0:a.includes("scale")),g=i(m);l=Object.assign(Object.assign({},g),{easing:"linear"}),s&&(s.generator=m,s.generatorStartTime=performance.now())}else{l={easing:"ease",duration:i(r(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:r,bounceStiffness:i,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 O=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:r,stiffness:i,restDistance:l,restSpeed:u}))};return O(0),t=>{let e=!1;return M||void 0!==w||(e=!0,b(t),O(t)),void 0!==w&&t>w?(h.hasReachedTarget=!0,M(t-w)):(h.hasReachedTarget=!1,!e&&b(t),h)}})),Ot={any:0,all:1};function Tt(t,e,{root:n,margin:a,amount:r="any"}={}){if("undefined"==typeof IntersectionObserver)return()=>{};const i=J(t),s=new WeakMap,o=new IntersectionObserver((t=>{t.forEach((t=>{const n=s.get(t.target);if(t.isIntersecting!==Boolean(n))if(t.isIntersecting){const n=e(t);"function"==typeof n?s.set(t.target,n):o.unobserve(t.target)}else n&&(n(t),s.delete(t.target))}))}),{root:n,rootMargin:a,threshold:"number"==typeof r?r:Ot[r]});return i.forEach((t=>o.observe(t))),()=>o.disconnect()}function St(t,e){return tt([()=>{const n=new U(t,[0,1],e);return n.finished.catch((()=>{})),n}],null==e?void 0:e.duration)}function xt(t,e,n){return("function"==typeof t?St:it)(t,e,n)}export{t as MotionValue,xt as animate,Mt as glide,Tt as inView,wt as spring,at as stagger,Z as style,ut 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 r={duration:.3,delay:0,endDelay:0,repeat:0,easing:"ease"},i=t=>"number"==typeof t,s=t=>"string"==typeof t,o=t=>"object"==typeof t&&Boolean(t.createAnimation),c=t=>Array.isArray(t)&&!i(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 r=f(0,e,a);t.push(l(n,1,r))}}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"},w={translate:{syntax:"<length-percentage>",initialValue:"0px",toDefaultUnit:t=>t+"px"},rotate:b,scale:{syntax:"<number>",initialValue:1,toDefaultUnit:h},skew:b},M=new Map,O=t=>`--motion-${t}`,T=["x","y","z"];["translate","scale","rotate","skew"].forEach((t=>{y.forEach((e=>{T.push(t+e),M.set(O(t+e),w[t])}))}));const S=(t,e)=>T.indexOf(t)-T.indexOf(e),x=new Set(T),A=t=>x.has(t),k=t=>t.sort(S).reduce(D,"").trim(),D=(t,e)=>`${t} ${e}(var(${O(e)}))`,j=t=>t.startsWith("--"),R=new Set;const E=(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 h;const r=e=>function(t,e,n,a,r){let i,s,o=0;do{s=e+(n-e)/2,i=E(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:E(r(t),e,a)}const $=(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},q={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)},I=/\((.*?)\)/;function V(t){if("function"==typeof t)return t;if(Array.isArray(t))return P(...t);if(q[t])return q[t];if(t.startsWith("steps")){const e=I.exec(t);if(e){const t=e[1].split(",");return $(parseFloat(t[0]),t[1].trim())}}return h}function F(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 W(t,e=m(t.length),n=h){const a=t.length,r=a-e.length;return r>0&&d(e,r),r=>{let i=0;for(;i<a-2&&!(r<e[i+1]);i++);let s=(o=f(e[i],e[i+1],r),Math.min(1,Math.max(o,0)));var o;return s=F(n,i)(s),l(t[i],t[i+1],s)}}class U{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:f="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 d=c(n)?h:V(n),m=a*(l+1),p=W(e,u,c(n)?n.map(V):h);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=m);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"===f||"alternate"===f&&u||"alternate-reverse"===f&&!u)&&(l=1-l);const h=r>=m?1:Math.min(l,1),g=p(d(h));t(g);"finished"===this.playState||r>=m+s?(this.playState="finished",null===(n=this.resolve)||void 0===n||n.call(this,g)):"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 _=t=>(t=>Array.isArray(t)&&i(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}),z={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)},N={},K={};for(const t in z)K[t]=()=>(void 0===N[t]&&(N[t]=z[t]()),N[t]);const X=t=>Array.isArray(t)?t:[t];function Y(t){return v[t]&&(t=v[t]),A(t)?O(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=M.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 L(t,e=!0){if(t&&"finished"!==t.playState)try{t.stop?t.stop():(e&&t.commitStyles(),t.cancel())}catch(t){}}function G(e,a,s,l={}){const h=window.__MOTION_DEV_TOOLS_RECORD,f=!1!==l.record&&h;let d,{duration:m=r.duration,delay:g=r.delay,endDelay:y=r.endDelay,repeat:b=r.repeat,easing:w=r.easing,direction:O,offset:T,allowWebkitAcceleration:S=!1}=l;const x=n(e);let D=K.waapi();const E=A(a);E&&((t,e)=>{v[e]&&(e=v[e]);const{transforms:a}=n(t);var r,i;i=e,-1===(r=a).indexOf(i)&&r.push(i),t.style.transform=k(a)})(e,a);const P=Y(a),$=function(e,n){return e.has(n)||e.set(n,new t),e.get(n)}(x.values,P),q=M.get(P);return L($.animation,!(o(w)&&$.generator)&&!1!==l.record),()=>{const t=()=>{var t,n;return null!==(n=null!==(t=Z.get(e,P))&&void 0!==t?t:null==q?void 0:q.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(s),t);if(o(w)){const e=w.createAnimation(n,t,E,P,$);w=e.easing,void 0!==e.keyframes&&(n=e.keyframes),void 0!==e.duration&&(m=e.duration)}if(j(P)&&(K.cssRegisterProperty()?function(t){if(!R.has(t)){R.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){}}}(P):D=!1),D){q&&(n=n.map((t=>i(t)?q.toDefaultUnit(t):t))),1!==n.length||K.partialKeyframes()&&!f||n.unshift(t());const a={delay:p(g),duration:p(m),endDelay:p(y),easing:c(w)?void 0:_(w),direction:O,iterations:b+1,fill:"both"};d=e.animate({[P]:n,offset:T,easing:c(w)?w.map(_):void 0},a),d.finished||(d.finished=new Promise(((t,e)=>{d.onfinish=t,d.oncancel=e})));const r=n[n.length-1];d.finished.then((()=>{Z.set(e,P,r),d.cancel()})).catch(u),S||(d.playbackRate=1.000001)}else if(E){n=n.map((t=>"string"==typeof t?parseFloat(t):t)),1===n.length&&n.unshift(parseFloat(t()));d=new U((t=>{q&&(t=q.toDefaultUnit(t)),Z.set(e,P,t)}),n,Object.assign(Object.assign({},l),{duration:m,easing:w}))}else{const t=n[n.length-1];Z.set(e,P,q&&i(t)?q.toDefaultUnit(t):t)}return f&&h(e,a,n,{duration:m,delay:g,easing:w,repeat:b,offset:T},"motion-one"),$.setAnimation(d),d}}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 Q=t=>t(),tt=(t,e=r.duration)=>new Proxy({animations:t.map(Q).filter(Boolean),duration:e},et),et={get:(t,e)=>{const n=t.animations[0];switch(e){case"duration":return t.duration;case"currentTime":let a=(null==n?void 0:n[e])||0;return a?a/1e3:0;case"playbackRate":case"playState":return null==n?void 0:n[e];case"finished":return t.finished||(t.finished=Promise.all(t.animations.map(nt)).catch(u)),t.finished;case"stop":return()=>t.animations.forEach((t=>L(t)));default:return void 0===(null==n?void 0:n[e])?void 0:()=>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=.1,{start:e=0,from:n=0,easing:a}={}){return(r,s)=>{const o=i(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-r);let l=t*c;if(a){const e=s*t;l=V(a)(l/e)*e}return e+l}}function rt(t,e,n){return"function"==typeof t?t(e,n):t}function it(t,e,n={}){const a=(t=J(t)).length,r=[];for(let i=0;i<a;i++){const s=t[i];for(const t in e){const o=H(n,t);o.delay=rt(o.delay,i,a);const c=G(s,t,e[t],o);r.push(c)}}return tt(r,n.duration)}var st=function(){};function ot(t,e,n,a){var r;return i(e)?e:e.startsWith("-")||e.startsWith("+")?Math.max(0,t+parseFloat(e)):"<"===e?n:null!==(r=a.get(e))&&void 0!==r?r:t}function ct(t,e,n,r,i,s){!function(t,e,n){for(let r=0;r<t.length;r++){const i=t[r];i.at>e&&i.at<n&&(a(t,i),r--)}}(t,i,s);for(let a=0;a<e.length;a++)t.push({value:e[a],at:l(i,s,r[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 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 i=[],c=new Map,l={},u=new Map;let h=0,p=0,g=0;for(let e=0;e<t.length;e++){const a=t[e];if(s(a)){u.set(a,p);continue}if(!Array.isArray(a)){u.set(a.name,ot(p,a.at,h,u));continue}const[i,f,y={}]=a;void 0!==y.at&&(p=ot(p,y.at,h,u));let v=0;const b=J(i,l),w=b.length;for(let t=0;t<w;t++){const e=ht(b[t],c);for(const a in f){const i=ft(a,e);let s=X(f[a]);const c=H(y,a);let{duration:l=n.duration||r.duration,easing:u=n.easing||r.easing}=c;if(o(u)){const t=A(a);st(2===s.length||!t,"spring must be provided 2 keyframes within timeline");const e=u.createAnimation(s,(()=>"0"),t);u=e.easing,void 0!==e.keyframes&&(s=e.keyframes),void 0!==e.duration&&(l=e.duration)}const h=rt(y.delay,t,w)||0,b=p+h,M=b+l;let{offset:O=m(s.length)}=c;1===O.length&&0===O[0]&&(O[1]=1);const T=length-s.length;T>0&&d(O,T),1===s.length&&s.unshift(null),ct(i,s,u,O,b,M),v=Math.max(h+l,v),g=Math.max(M,g)}}h=p,p+=v}return c.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(f(0,g,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:g,easing:u,offset:l}),a)])}})),i}(t,e),i=a.map((t=>G(...t))).filter(Boolean);return tt(i,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 r=n-t(a),(i=e-a)?r*(1e3/i):0;var r,i}const mt=100,pt=10,gt=1;const yt=({stiffness:t=mt,damping:e=pt,mass:n=gt,from:a=0,to:r=1,velocity:i=0,restSpeed:s=2,restDistance:o=.5}={})=>{i=i?g(i):0;const c={done:!1,hasReachedTarget:!1,current:a,target:r},l=r-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=>r-Math.exp(-h*u*e)*((h*u*l-i)/t*Math.sin(t*e)+l*Math.cos(t*e))}else f=t=>r-Math.exp(-u*t)*(l+(u*l-i)*t);return t=>{c.current=f(t);const e=0===t?i:dt(f,t,c.current),n=Math.abs(e)<=s,l=Math.abs(r-c.current)<=o;var u,h,d;return c.done=n&&l,c.hasReachedTarget=(u=a,h=r,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,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)=>{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,r=(null==e?void 0:e.currentTime)||performance.now()-a,i=m(r).current;d=null!==(o=h)&&void 0!==o?o:i,(1===u||2===u&&null===t[0])&&(f=dt((t=>m(t).current),r,i))}else d=null!==(c=h)&&void 0!==c?c:parseFloat(e());const p=r(d,n,f,null==a?void 0:a.includes("scale")),g=i(p);l=Object.assign(Object.assign({},g),{easing:"linear"}),s&&(s.generator=p,s.generatorStartTime=performance.now())}else{l={easing:"ease",duration:i(r(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:r,bounceStiffness:i,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 w,M;const O=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:r,stiffness:i,restDistance:l,restSpeed:u}))};return O(0),t=>{let e=!1;return M||void 0!==w||(e=!0,b(t),O(t)),void 0!==w&&t>w?(h.hasReachedTarget=!0,M(t-w)):(h.hasReachedTarget=!1,!e&&b(t),h)}}));let Ot;function Tt(){if(void 0===Ot)try{new IntersectionObserver(u,{root:document}),Ot=!0}catch(t){Ot=!1}return Ot?document:void 0}const St={any:0,all:1};function xt(t,e,{root:n,margin:a,amount:r="any"}={}){if("undefined"==typeof IntersectionObserver)return()=>{};const i=J(t),s=new WeakMap,o=new IntersectionObserver((t=>{t.forEach((t=>{const n=s.get(t.target);if(t.isIntersecting!==Boolean(n))if(t.isIntersecting){const n=e(t);"function"==typeof n?s.set(t.target,n):o.unobserve(t.target)}else n&&(n(t),s.delete(t.target))}))}),{root:n||Tt(),rootMargin:a,threshold:"number"==typeof r?r:St[r]});return i.forEach((t=>o.observe(t))),()=>o.disconnect()}function At(t,e){return tt([()=>{const n=new U(t,[0,1],e);return n.finished.catch((()=>{})),n}],null==e?void 0:e.duration)}function kt(t,e,n){return("function"==typeof t?At:it)(t,e,n)}export{t as MotionValue,kt as animate,Mt as glide,xt as inView,wt as spring,at as stagger,Z as style,ut as timeline};
package/dist/vue.cjs.js CHANGED
File without changes
package/dist/vue.es.js CHANGED
File without changes
package/lib/animate.js CHANGED
File without changes
File without changes
package/lib/index.js CHANGED
File without changes
package/lib/index.js.map CHANGED
File without changes
package/lib/react.js CHANGED
File without changes
package/lib/react.js.map CHANGED
File without changes
package/lib/vue.js CHANGED
File without changes
package/lib/vue.js.map CHANGED
File without changes
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.11.0",
4
+ "version": "10.11.1",
5
5
  "license": "MIT",
6
6
  "author": "Matt Perry",
7
7
  "main": "dist/main.cjs.js",
@@ -24,11 +24,11 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@motionone/animation": "^10.10.1",
27
- "@motionone/dom": "^10.11.0",
28
- "@motionone/react": "^10.11.0",
29
- "@motionone/svelte": "^10.11.0",
27
+ "@motionone/dom": "^10.11.1",
28
+ "@motionone/react": "^10.11.1",
29
+ "@motionone/svelte": "^10.11.1",
30
30
  "@motionone/types": "^10.9.0",
31
- "@motionone/vue": "^10.11.0"
31
+ "@motionone/vue": "^10.11.1"
32
32
  },
33
- "gitHead": "d6306f38611747ab6ad98739f58b4db017be5a5b"
33
+ "gitHead": "25a8e264f860ca7b52f857fa48d1242542699542"
34
34
  }
File without changes
File without changes
package/types/index.d.ts CHANGED
File without changes
File without changes
package/types/react.d.ts CHANGED
File without changes
File without changes
package/types/vue.d.ts CHANGED
File without changes
File without changes