{"version":3,"file":"DragScroll.wLNebjry.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/rhTfZ0DoXKfYXPyYCuQ5/tPocjDkpg9ycKXepWFo8/DragScroll.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{Data,useMotionValue,animate}from\"framer\";import{useRef,useState,useEffect}from\"react\";// 1. Gecentraliseerde data voor minder herberekeningen\nconst controller=Data({scroll:direction=>null});export function TickerWithControls(Component){return props=>{const ref=useRef(null);const[constraints,setConstraints]=useState({left:0,right:0});const x=useMotionValue(0);const isDragging=useRef(false);// --- EFFICIËNTE CONSTRAINTS BEREKENING ---\nuseEffect(()=>{const element=ref.current;if(!element)return;let timer;const updateConstraints=()=>{const viewportWidth=element.parentElement?.offsetWidth||window.innerWidth;const contentWidth=element.scrollWidth;const distance=contentWidth-viewportWidth;const paddingBuffer=64;setConstraints({left:distance>0?-distance-paddingBuffer:0,right:0});};// Gebruik ResizeObserver met een kleine 'debounce'\nconst observer=new ResizeObserver(()=>{clearTimeout(timer);timer=window.setTimeout(updateConstraints,100);});observer.observe(element);if(element.parentElement)observer.observe(element.parentElement);updateConstraints();return()=>{observer.disconnect();clearTimeout(timer);};},[]);// --- GEOPTIMALISEERDE SCROLL LOGICA ---\nuseEffect(()=>{controller.scroll=direction=>{const currentX=x.get();const step=400;const targetX=direction===\"next\"?currentX-step:currentX+step;const clampedX=Math.max(Math.min(targetX,0),constraints.left);animate(x,clampedX,{type:\"spring\",stiffness:250,damping:30,mass:.5});};},[constraints,x]);// --- CENTRALE KLIK-BLOKKADE (Vervangt withSmartItem) ---\n// We meten op de parent of er gesleept is. Veel lichter dan op elk item.\nconst onDragStart=()=>{isDragging.current=true;};const onDragEnd=()=>{// Klein vertragingkje zodat de 'click' event de isDragging nog op true ziet\nsetTimeout(()=>{isDragging.current=false;},50);};return /*#__PURE__*/_jsx(Component,{...props,ref:ref,style:{...props.style,x:x,display:\"flex\",justifyContent:\"flex-start\",paddingRight:\"64px\",width:\"max-content\",overflow:\"visible\",cursor:\"grab\",userSelect:\"none\",WebkitUserSelect:\"none\",// GPU-versnelde image fixes via CSS\ntouchAction:\"pan-y\"},// Drag functionaliteit\ndrag:\"x\",dragConstraints:constraints,dragElastic:.1,dragMomentum:true,onDragStart:onDragStart,onDragEnd:onDragEnd,whileTap:{cursor:\"grabbing\"},// Verhindert ghosting van images zonder JS-loop\nonDragStartCapture:e=>{if(e.target.tagName===\"IMG\")e.preventDefault();},// Blokkeert kliks op links als we slepen\nonClickCapture:e=>{if(isDragging.current){e.preventDefault();e.stopPropagation();}}});};}// 3. KNOPPEN (Onveranderd maar efficiënt)\nexport function ButtonPrev(Component){return props=>/*#__PURE__*/_jsx(Component,{...props,onTap:()=>controller.scroll(\"prev\"),style:{...props.style,cursor:\"pointer\"}});}export function ButtonNext(Component){return props=>/*#__PURE__*/_jsx(Component,{...props,onTap:()=>controller.scroll(\"next\"),style:{...props.style,cursor:\"pointer\"}});}// DEZE IS NU OVERBODIG MAAR WE LATEN HEM LEEG VOOR DE COMPATIBILITEIT\nexport function withSmartItem(Component){return props=>/*#__PURE__*/_jsx(Component,{...props});}\nexport const __FramerMetadata__ = {\"exports\":{\"ButtonNext\":{\"type\":\"reactHoc\",\"name\":\"ButtonNext\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"TickerWithControls\":{\"type\":\"reactHoc\",\"name\":\"TickerWithControls\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"ButtonPrev\":{\"type\":\"reactHoc\",\"name\":\"ButtonPrev\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withSmartItem\":{\"type\":\"reactHoc\",\"name\":\"withSmartItem\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./DragScroll.map"],"mappings":"gPACgD,SAAgB,EAAmB,EAAU,CAAC,MAAO,IAAO,CAAC,IAAM,EAAIA,EAAO,KAAK,CAAM,CAAC,EAAY,GAAgBC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