{"version":3,"file":"BeforeAfterSlider_1.DjPyTp8m.mjs","names":["useRef","useState","useCallback","startTransition"],"sources":["https:/framerusercontent.com/modules/f7XtoIRusL0ZgaCfFM5O/ddi46o3eqOq0RYnGIzbg/BeforeAfterSlider_1.js"],"sourcesContent":["// Image before-and-after slider with customizable images and center arrow icon\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useRef,useState,useCallback,useEffect,startTransition}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";const defaultBefore={src:\"https://framerusercontent.com/images/GfGkADagM4KEibNcIiRUWlfrR0.jpg\",alt:\"Before image\"};const defaultAfter={src:\"https://framerusercontent.com/images/aNsAT3jCvt4zglbWCUoFe33Q.jpg\",alt:\"After image\"};/**\n * Image Before-After Slider\n *\n * @framerIntrinsicWidth 500\n * @framerIntrinsicHeight 300\n *\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n */export default function BeforeAfterSlider(props){const{beforeImage=defaultBefore,afterImage=defaultAfter,arrowColor,arrowSize,arrowBackground,dividerColor,dividerWidth,style}=props;const containerRef=useRef(null);const[position,setPosition]=useState(50);const[dragging,setDragging]=useState(false);const isStatic=useIsStaticRenderer();const updatePosition=useCallback(e=>{if(!containerRef.current)return;const rect=containerRef.current.getBoundingClientRect();const x=e.touches?e.touches[0].clientX:e.clientX;const rel=Math.max(0,Math.min(1,(x-rect.left)/rect.width));startTransition(()=>setPosition(rel*100));},[]);useEffect(()=>{if(!dragging||isStatic)return;const move=e=>updatePosition(e);const up=()=>startTransition(()=>setDragging(false));window.addEventListener(\"mousemove\",move);window.addEventListener(\"mouseup\",up);window.addEventListener(\"touchmove\",move);window.addEventListener(\"touchend\",up);return()=>{window.removeEventListener(\"mousemove\",move);window.removeEventListener(\"mouseup\",up);window.removeEventListener(\"touchmove\",move);window.removeEventListener(\"touchend\",up);};},[dragging,updatePosition,isStatic]);const handleDown=e=>{e.preventDefault();startTransition(()=>setDragging(true));};const handleClick=e=>{if(!dragging)updatePosition(e);};return /*#__PURE__*/_jsxs(\"div\",{ref:containerRef,style:{position:\"relative\",width:\"100%\",height:\"100%\",overflow:\"hidden\",cursor:dragging?\"ew-resize\":\"pointer\",...style},onMouseDown:isStatic?undefined:handleDown,onTouchStart:isStatic?undefined:handleDown,onClick:isStatic?undefined:handleClick,tabIndex:0,role:\"slider\",\"aria-valuenow\":position,\"aria-valuemin\":0,\"aria-valuemax\":100,\"aria-orientation\":\"horizontal\",children:[/*#__PURE__*/_jsx(\"img\",{src:afterImage.src,alt:afterImage.alt,style:{position:\"absolute\",top:0,left:0,width:\"100%\",height:\"100%\",objectFit:\"cover\",pointerEvents:\"none\"}}),/*#__PURE__*/_jsx(\"img\",{src:beforeImage.src,alt:beforeImage.alt,style:{position:\"absolute\",top:0,left:0,width:\"100%\",height:\"100%\",objectFit:\"cover\",clipPath:`inset(0 ${100-position}% 0 0)`,pointerEvents:\"none\"}}),/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",top:0,left:`${position}%`,width:dividerWidth,height:\"100%\",background:dividerColor,transform:`translateX(-${dividerWidth/2}px)`,zIndex:2,pointerEvents:\"none\"}}),/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",top:\"50%\",left:`${position}%`,transform:`translate(-50%, -50%)`,width:arrowSize,height:arrowSize,background:arrowBackground,borderRadius:\"50%\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",boxShadow:\"0 2px 8px rgba(0,0,0,0.08)\",zIndex:3,cursor:isStatic?\"default\":\"ew-resize\",border:`1px solid ${dividerColor}`},onMouseDown:isStatic?undefined:handleDown,onTouchStart:isStatic?undefined:handleDown,\"aria-label\":\"Drag to compare\",children:/*#__PURE__*/_jsxs(\"svg\",{width:arrowSize*.6,height:arrowSize*.6,viewBox:\"0 0 32 32\",fill:\"none\",stroke:arrowColor,strokeWidth:\"3\",strokeLinecap:\"round\",strokeLinejoin:\"round\",\"aria-hidden\":\"true\",children:[/*#__PURE__*/_jsx(\"polyline\",{points:\"12 8 4 16 12 24\"}),/*#__PURE__*/_jsx(\"polyline\",{points:\"20 8 28 16 20 24\"})]})})]});}addPropertyControls(BeforeAfterSlider,{beforeImage:{type:ControlType.ResponsiveImage,title:\"Before Image\"},afterImage:{type:ControlType.ResponsiveImage,title:\"After Image\"},arrowColor:{type:ControlType.Color,title:\"Arrow Color\",defaultValue:\"#222\"},arrowSize:{type:ControlType.Number,title:\"Arrow Size\",defaultValue:48,min:24,max:96,step:1,unit:\"px\"},arrowBackground:{type:ControlType.Color,title:\"Arrow BG\",defaultValue:\"#fff\"},dividerColor:{type:ControlType.Color,title:\"Divider Color\",defaultValue:\"#fff\"},dividerWidth:{type:ControlType.Number,title:\"Divider Width\",defaultValue:2,min:1,max:12,step:1,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"BeforeAfterSlider\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"fixed\",\"framerIntrinsicHeight\":\"300\",\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"500\",\"framerSupportedLayoutHeight\":\"fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./BeforeAfterSlider_1.map"],"mappings":"mOASG,SAAwB,EAAkB,EAAM,CAAC,GAAK,CAAC,cAAY,EAAc,aAAW,EAAa,aAAW,YAAU,kBAAgB,eAAa,eAAa,SAAO,EAAY,EAAaA,EAAO,KAAK,CAAM,CAAC,EAAS,GAAaC,EAAS,GAAG,CAAM,CAAC,EAAS,GAAaA,EAAS,GAAM,CAAO,EAAS,GAAqB,CAAO,EAAeC,EAAY,GAAG,CAAC,GAAG,CAAC,EAAa,QAAQ,OAAO,IAAM,EAAK,EAAa,QAAQ,uBAAuB,CAAO,EAAE,EAAE,QAAQ,EAAE,QAAQ,GAAG,QAAQ,EAAE,QAAc,EAAI,KAAK,IAAI,EAAE,KAAK,IAAI,GAAG,EAAE,EA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