{"version":3,"file":"Trigger_scroll_popup.BUI3EfQd.mjs","names":[],"sources":["https:/framerusercontent.com/modules/teZ96Da2MDtdPsxQ3XLf/5LeUrLs52kkpRlJzduXX/Trigger_scroll_popup.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef,useEffect}from\"react\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";// ============================\n// CONFIGURATION\n// ============================\n// Seuil de déclenchement en pourcentage de la hauteur totale scrollable (0-100)\n// Exemple : 50 = la popup apparaît quand l'utilisateur a scrollé 50% de la page\nconst SCROLL_THRESHOLD_PERCENT=50;// Si true, la popup n'apparaît qu'une seule fois par session\nconst SHOW_ONCE=true;// ============================\n// STORE PARTAGÉ\n// ============================\nconst usePopupStore=createStore({isOpen:false,hasBeenShown:false});// ============================\n// OVERRIDE 1 : TRIGGER\n// À appliquer sur le Body ou une section de la page\n// ============================\nexport const withScrollTrigger=Component=>{return /*#__PURE__*/forwardRef((props,ref)=>{const[store,setStore]=usePopupStore();useEffect(()=>{const handleScroll=()=>{const scrollTop=window.pageYOffset||document.documentElement.scrollTop;const scrollHeight=document.documentElement.scrollHeight-window.innerHeight;if(scrollHeight<=0)return;const scrolledPercent=scrollTop/scrollHeight*100;if(scrolledPercent>=SCROLL_THRESHOLD_PERCENT){if(SHOW_ONCE&&store.hasBeenShown)return;if(!store.isOpen){setStore({isOpen:true,hasBeenShown:true});}}};window.addEventListener(\"scroll\",handleScroll,{passive:true});handleScroll()// Check initial au cas où la page est déjà scrollée\n;return()=>window.removeEventListener(\"scroll\",handleScroll);},[store.isOpen,store.hasBeenShown]);return /*#__PURE__*/_jsx(Component,{ref:ref,...props});});};// ============================\n// OVERRIDE 2 : POPUP\n// À appliquer sur le frame de ta popup\n// ============================\nexport const withScrollPopup=Component=>{return /*#__PURE__*/forwardRef((props,ref)=>{const[store,setStore]=usePopupStore();const handleClose=e=>{e?.stopPropagation?.();setStore({isOpen:false});};return /*#__PURE__*/_jsx(Component,{ref:ref,...props,onClick:handleClose,style:{...props?.style,opacity:store.isOpen?1:0,pointerEvents:store.isOpen?\"auto\":\"none\",transform:store.isOpen?\"translateY(0)\":\"translateY(20px)\",transition:\"opacity 0.4s ease, transform 0.4s ease\"}});});};\nexport const __FramerMetadata__ = {\"exports\":{\"withScrollPopup\":{\"type\":\"reactHoc\",\"name\":\"withScrollPopup\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withScrollTrigger\":{\"type\":\"reactHoc\",\"name\":\"withScrollTrigger\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Trigger_scroll_popup.map"],"mappings":"uNAA2C,IAAwC,IAAqE,CAKlJ,EAAyB,GAIzB,EAAc,EAAY,CAAC,OAAO,GAAM,aAAa,GAAM,CAAC,CAIrD,EAAkB,GAAgC,GAAY,EAAM,IAAM,CAAC,GAAK,CAAC,EAAM,GAAU,GAAe,CAC3B,OAD4B,MAAc,CAAC,IAAM,MAAiB,CAAC,IAAM,EAAU,EAAO,aAAa,SAAS,gBAAgB,UAAgB,EAAa,SAAS,gBAAgB,aAAa,EAAO,YAAe,QAAc,IAA+B,EAAU,EAAa,KAAwB,EAAyB,CAAC,GAAc,EAAM,aAAa,OAAW,EAAM,QAAQ,EAAS,CAAC,OAAO,GAAK,aAAa,GAAK,CAAC,GACnhB,OADwhB,EAAO,iBAAiB,SAAS,EAAa,CAAC,QAAQ,GAAK,CAAC,CAAC,GAAc,KAC1lB,EAAO,oBAAoB,SAAS,EAAa,EAAG,CAAC,EAAM,OAAO,EAAM,aAAa,CAAC,CAAqB,EAAK,EAAU,CAAK,MAAI,GAAG,EAAM,CAAC,EAAG,CAI9I,EAAgB,GAAgC,GAAY,EAAM,IAAM,CAAC,GAAK,CAAC,EAAM,GAAU,GAAe,CAAO,EAAY,GAAG,CAAC,GAAG,mBAAmB,CAAC,EAAS,CAAC,OAAO,GAAM,CAAC,EAAG,OAAoB,EAAK,EAAU,CAAK,MAAI,GAAG,EAAM,QAAQ,EAAY,MAAM,CAAC,GAAG,GAAO,MAAM,QAAQ,EAAM,OAAO,EAAE,EAAE,cAAc,EAAM,OAAO,OAAO,OAAO,UAAU,EAAM,OAAO,gBAAgB,mBAAmB,WAAW,yCAAyC,CAAC,CAAC,EAAG"}