2 lines
140 KiB
JavaScript
2 lines
140 KiB
JavaScript
|
|
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Motion={},t.React)}(this,(function(t,e){"use strict";function n(t){var e=Object.create(null);return t&&Object.keys(t).forEach((function(n){if("default"!==n){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}})),e.default=t,Object.freeze(e)}var i=n(e),s=React,o=Symbol.for("react.element"),r=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,l=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};function c(t,e,n){var i,s={},r=null,c=null;for(i in void 0!==n&&(r=""+n),void 0!==e.key&&(r=""+e.key),void 0!==e.ref&&(c=e.ref),e)a.call(e,i)&&!u.hasOwnProperty(i)&&(s[i]=e[i]);if(t&&t.defaultProps)for(i in e=t.defaultProps)void 0===s[i]&&(s[i]=e[i]);return{$$typeof:o,type:t,key:r,ref:c,props:s,_owner:l.current}}const h=r,d=c,p=c,m=e.createContext({});function f(t){return null!==t&&"object"==typeof t&&"function"==typeof t.start}const g=t=>Array.isArray(t);function y(t,e){if(!Array.isArray(e))return!1;const n=e.length;if(n!==t.length)return!1;for(let i=0;i<n;i++)if(e[i]!==t[i])return!1;return!0}function v(t){return"string"==typeof t||Array.isArray(t)}function x(t){const e=[{},{}];return null==t||t.values.forEach((t,n)=>{e[0][n]=t.get(),e[1][n]=t.getVelocity()}),e}function w(t,e,n,i){if("function"==typeof e){const[s,o]=x(i);e=e(void 0!==n?n:t.custom,s,o)}if("string"==typeof e&&(e=t.variants&&t.variants[e]),"function"==typeof e){const[s,o]=x(i);e=e(void 0!==n?n:t.custom,s,o)}return e}function P(t,e,n){const i=t.getProps();return w(i,e,void 0!==n?n:i.custom,t)}const T=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],S=["initial",...T],b=t=>t;let A=b,E=b;function M(t){let e;return()=>(void 0===e&&(e=t()),e)}const C=(t,e,n)=>{const i=e-t;return 0===i?1:(n-t)/i},V=t=>1e3*t,R=t=>t/1e3,D=M(()=>void 0!==window.ScrollTimeline);class k extends class{constructor(t){this.stop=()=>this.runAll("stop"),this.animations=t.filter(Boolean)}get finished(){return Promise.all(this.animations.map(t=>"finished"in t?t.finished:t))}getAll(t){return this.animations[0][t]}setAll(t,e){for(let n=0;n<this.animations.length;n++)this.animations[n][t]=e}attachTimeline(t,e){const n=this.animations.map(n=>D()&&n.attachTimeline?n.attachTimeline(t):"function"==typeof e?e(n):void 0);return()=>{n.forEach((t,e)=>{t&&t(),this.animations[e].stop()})}}get time(){return this.getAll("time")}set time(t){this.setAll("time",t)}get speed(){return this.getAll("speed")}set speed(t){this.setAll("speed",t)}get startTime(){return this.getAll("startTime")}get duration(){let t=0;for(let e=0;e<this.animations.length;e++)t=Math.max(t,this.animations[e].duration);return t}runAll(t){this.animations.forEach(e=>e[t]())}flatten(){this.runAll("flatten")}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}{then(t,e){return Promise.all(this.animations).then(t).catch(e)}}function L(t,e){return t?t[e]||t.default||t:void 0}function B(t){let e=0;let n=t.next(e);for(;!n.done&&e<2e4;)e+=50,n=t.next(e);return e>=2e4?1/0:e}function F(t,e=100,n){const i=n({...t,keyframes:[0,e]}),s=Math.min(B(i),2e4);return{type:"keyframes",ease:t=>i.next(s*t).value/e,duration:R(s)}}function j(t){return"function"==typeof t}function O(t,e){t.timeline=e,t.onfinish=null}const I=t=>Array.isArray(t)&&"number"==typeof t[0],U={linearEasing:void 0};function W(t,e){const n=M(t);return()=>{var t;return null!==(t=U[e])&&void 0!==t?t:n()}}const N=W(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch(t){return!1}return!0},"linearEasing"),z=(t,e,n=10)=>{let i="";const s=Math.max(Math.round(e/n),2);for(let e=0;e<s;e++)i+=t(C(0,s-1,e))+", ";return`linear(${i.substring(0,i.length-2)})`};function $(t){return Boolean("function"==typeof t&&N()||!t||"
|