{"version":3,"file":"VariantOnViewportCenter.SS2StYPv.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/xq1HlMJCmCi0m1js17rq/n6b1t6R4DOHcqqMsIUsg/VariantOnViewportCenter.js"],"sourcesContent":["/**\n * Code built by Kamil Leśniak - Designer & Framer Expert PRO\n * Learn more on digitalkamil.com\n */// Switches a component from its \"Hidden\" variant to its \"Start\" variant once\n// a chosen point of the element (ELEMENT_ANCHOR: 0 = top, 0.5 = center,\n// 1 = bottom) crosses a line placed at VIEWPORT_TRIGGER of the viewport\n// height (0 = top, 1 = bottom).\n//\n// Apply withVariantOnViewportCenter to the element that has the \"Hidden\" and\n// \"Start\" variants. As the user scrolls down and the element's center reaches\n// the trigger line, the variant flips to \"Start\" and stays there.\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useState,useEffect,useRef}from\"react\";import{RenderTarget}from\"framer\";// ── Variables ──────────────────────────────────────────────────────────────\n// Fraction of the viewport height where the trigger line sits.\n// 0.6 = 60% down from the top of the viewport (0 = top, 1 = bottom).\nconst VIEWPORT_TRIGGER=1;// Which point of the element is tested against the trigger line.\n// 0 = top edge, 0.5 = center, 1 = bottom edge.\nconst ELEMENT_ANCHOR=.5;// Variant names must match EXACTLY what they're called in Framer.\nconst HIDDEN_VARIANT=\"Hidden\";const START_VARIANT=\"Start\";/**\n * @framerDisableUnlink\n */export function withVariantOnViewportCenter(Component){return props=>{const ref=useRef(null);const[variant,setVariant]=useState(HIDDEN_VARIANT);// On the Framer canvas, don't hijack the variant — let the designer\n// preview either variant normally.\nconst isCanvas=RenderTarget.current()===RenderTarget.canvas;useEffect(()=>{if(isCanvas||variant===START_VARIANT)return;const check=()=>{const el=ref.current;if(!el)return;const rect=el.getBoundingClientRect();const point=rect.top+rect.height*ELEMENT_ANCHOR;if(point<=window.innerHeight*VIEWPORT_TRIGGER){setVariant(START_VARIANT);}};check()// catch elements already past the line on mount\n;window.addEventListener(\"scroll\",check,{passive:true});window.addEventListener(\"resize\",check);return()=>{window.removeEventListener(\"scroll\",check);window.removeEventListener(\"resize\",check);};},[isCanvas,variant]);if(isCanvas)return /*#__PURE__*/_jsx(Component,{ref:ref,...props});return /*#__PURE__*/_jsx(Component,{ref:ref,...props,variant:variant});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withVariantOnViewportCenter\":{\"type\":\"reactHoc\",\"name\":\"withVariantOnViewportCenter\",\"annotations\":{\"framerContractVersion\":\"1\",\"framerDisableUnlink\":\"\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./VariantOnViewportCenter.map"],"mappings":"2LAmBG,SAAgB,EAA4B,EAAU,CAAC,MAAO,IAAO,CAAC,IAAM,EAAIA,EAAO,IAAI,EAAO,CAAC,EAAQ,GAAYC,EAAS,CAAc,EAE3I,EAAS,EAAa,QAAQ,IAAI,EAAa,OACuO,OADhO,MAAc,CAAC,GAAG,GAAU,IAAU,EAAc,OAAO,IAAM,MAAU,CAAC,IAAM,EAAG,EAAI,QAAQ,GAAG,CAAC,EAAG,OAAO,IAAM,EAAK,EAAG,sBAAsB,EAAc,EAAK,IAAI,EAAK,OAAO,GAAyB,EAAO,YAAY,GAAkB,EAAW,CAAa,CAAG,EAC3O,OAD6O,EAAM,EAClV,EAAO,iBAAiB,SAAS,EAAM,CAAC,QAAQ,EAAI,CAAC,EAAE,EAAO,iBAAiB,SAAS,CAAK,MAAY,CAAC,EAAO,oBAAoB,SAAS,CAAK,EAAE,EAAO,oBAAoB,SAAS,CAAK,CAAE,CAAE,EAAE,CAAC,EAAS,CAAO,CAAC,EAAK,EAA6B,EAAK,EAAU,CAAK,MAAI,GAAG,CAAK,CAAC,EAAsB,EAAK,EAAU,CAAK,MAAI,GAAG,EAAc,SAAO,CAAC,CAAE,CAAE,6BAX3T,IAA6C,IAAiC,EAGlH,EAAiB,EAEjB,EAAe,GACf,EAAe,SAAe,EAAc"}