2 lines
124 KiB
JavaScript
2 lines
124 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){return t&&"object"==typeof t&&"default"in t?t:{default:t}}function i(t){if(t&&t.__esModule)return 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 s=i(e),o=n(e);const r=e.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"}),a=e.createContext({}),l=e.createContext(null),u="undefined"!=typeof document,c=u?e.useLayoutEffect:e.useEffect,h=e.createContext({strict:!1}),d=t=>t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),p="data-"+d("framerAppearId");function m(t){return t&&"object"==typeof t&&Object.prototype.hasOwnProperty.call(t,"current")}function f(t){return"string"==typeof t||Array.isArray(t)}function g(t){return null!==t&&"object"==typeof t&&"function"==typeof t.start}const y=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],v=["initial",...y];function x(t){return g(t.animate)||v.some(e=>f(t[e]))}function P(t){return Boolean(x(t)||t.variants)}function w(t){const{initial:n,animate:i}=function(t,e){if(x(t)){const{initial:e,animate:n}=t;return{initial:!1===e||f(e)?e:void 0,animate:f(n)?n:void 0}}return!1!==t.inherit?e:{}}(t,e.useContext(a));return e.useMemo(()=>({initial:n,animate:i}),[E(n),E(i)])}function E(t){return Array.isArray(t)?t.join(" "):t}const b={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},S={};for(const t in b)S[t]={isEnabled:e=>b[t].some(t=>!!e[t])};function T(t){for(const e in t)S[e]={...S[e],...t[e]}}const A=e.createContext({}),C=e.createContext({}),V=Symbol.for("motionComponentSymbol");function M({preloadedFeatures:t,createVisualElement:n,useRender:i,useVisualState:o,Component:d}){t&&T(t);const f=e.forwardRef((function(f,g){let y;const v={...e.useContext(r),...f,layoutId:D(f)},{isStatic:x}=v,P=w(f),E=o(f,x);if(!x&&u){P.visualElement=function(t,n,i,s){const{visualElement:o}=e.useContext(a),u=e.useContext(h),d=e.useContext(l),m=e.useContext(r).reducedMotion,f=e.useRef();s=s||u.renderer,!f.current&&s&&(f.current=s(t,{visualState:n,parent:o,props:i,presenceContext:d,blockInitialAnimation:!!d&&!1===d.initial,reducedMotionConfig:m}));const g=f.current;e.useInsertionEffect(()=>{g&&g.update(i,d)});const y=e.useRef(Boolean(i[p]&&!window.HandoffComplete));return c(()=>{g&&(g.render(),y.current&&g.animationState&&g.animationState.animateChanges())}),e.useEffect(()=>{g&&(g.updateFeatures(),!y.current&&g.animationState&&g.animationState.animateChanges(),y.current&&(y.current=!1,window.HandoffComplete=!0))}),g}(d,E,v,n);const i=e.useContext(C),s=e.useContext(h).strict;P.visualElement&&(y=P.visualElement.loadFeatures(v,s,t,i))}return s.createElement(a.Provider,{value:P},y&&P.visualElement?s.createElement(y,{visualElement:P.visualElement,...v}):null,i(d,f,function(t,n,i){return e.useCallback(e=>{e&&t.mount&&t.mount(e),n&&(e?n.mount(e):n.unmount()),i&&("function"==typeof i?i(e):m(i)&&(i.current=e))},[n])}(E,P.visualElement,g),E,x,P.visualElement))}));return f[V]=d,f}function D({layoutId:t}){const n=e.useContext(A).id;return n&&void 0!==t?n+"-"+t:t}function R(t){function e(e,n={}){return M(t(e,n))}if("undefined"==typeof Proxy)return e;const n=new Map;return new Proxy(e,{get:(t,i)=>(n.has(i)||n.set(i,e(i)),n.get(i))})}const L=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","p
|