{"version":3,"file":"BeforeAfterSlider.BO9CdDMd.mjs","names":["useRef","useState","useCallback"],"sources":["https:/framerusercontent.com/modules/Thos9cjgLTqlNbnbxU7q/MqBsZt404nj6UzHvZfBG/BeforeAfterSlider.js"],"sourcesContent":["// Before and after comparison component with interactive draggable divider\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";import{useCallback,useEffect,useRef,useState,startTransition}from\"react\";/**\n * @framerIntrinsicWidth 500\n * @framerIntrinsicHeight 300\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function BeforeAfterSlider(props){const{beforeImage={src:\"https://framerusercontent.com/images/GfGkADagM4KEibNcIiRUWlfrR0.jpg\",alt:\"Before image\"},afterImage={src:\"https://framerusercontent.com/images/aNsAT3jCvt4zglbWCUoFe33Q.jpg\",alt:\"After image\"},orientation,initialPosition,dividerColor,dividerWidth,showHandle,handleBackgroundColor,handleBorderColor,handleArrowColor,handleSize,arrowSize,borderRadius}=props;const isHorizontal=orientation===\"horizontal\";const containerRef=useRef(null);const[position,setPosition]=useState(initialPosition);const[isDragging,setIsDragging]=useState(false);const isStatic=useIsStaticRenderer();const updatePositionFromEvent=useCallback(e=>{if(!containerRef.current)return;const rect=containerRef.current.getBoundingClientRect();// Get clientX and clientY from either mouse or touch event\nconst clientX=\"touches\"in e?e.touches[0]?.clientX||e.changedTouches[0]?.clientX:e.clientX;const clientY=\"touches\"in e?e.touches[0]?.clientY||e.changedTouches[0]?.clientY:e.clientY;if(isHorizontal){const x=clientX-rect.left;const newPosition=Math.max(0,Math.min(100,x/rect.width*100));startTransition(()=>setPosition(newPosition));}else{const y=clientY-rect.top;const newPosition=Math.max(0,Math.min(100,y/rect.height*100));startTransition(()=>setPosition(newPosition));}},[isHorizontal]);const handleClick=useCallback(e=>{if(!isDragging){updatePositionFromEvent(e);}},[isDragging,updatePositionFromEvent]);const handleMouseDown=e=>{e.preventDefault();startTransition(()=>setIsDragging(true));};const handleTouchStart=e=>{e.preventDefault();startTransition(()=>setIsDragging(true));};const handleMouseMove=useCallback(e=>{if(!isDragging||!containerRef.current)return;updatePositionFromEvent(e);},[isDragging,updatePositionFromEvent]);const handleTouchMove=useCallback(e=>{if(!isDragging||!containerRef.current)return;e.preventDefault();updatePositionFromEvent(e);},[isDragging,updatePositionFromEvent]);const handleMouseUp=useCallback(()=>{startTransition(()=>setIsDragging(false));},[]);const handleTouchEnd=useCallback(()=>{startTransition(()=>setIsDragging(false));},[]);useEffect(()=>{if(isStatic)return;if(isDragging){const handleGlobalMouseMove=e=>handleMouseMove(e);const handleGlobalMouseUp=()=>handleMouseUp();const handleGlobalTouchMove=e=>handleTouchMove(e);const handleGlobalTouchEnd=()=>handleTouchEnd();window.addEventListener(\"mousemove\",handleGlobalMouseMove);window.addEventListener(\"mouseup\",handleGlobalMouseUp);window.addEventListener(\"touchmove\",handleGlobalTouchMove,{passive:false});window.addEventListener(\"touchend\",handleGlobalTouchEnd);return()=>{window.removeEventListener(\"mousemove\",handleGlobalMouseMove);window.removeEventListener(\"mouseup\",handleGlobalMouseUp);window.removeEventListener(\"touchmove\",handleGlobalTouchMove);window.removeEventListener(\"touchend\",handleGlobalTouchEnd);};}},[isDragging,handleMouseMove,handleMouseUp,handleTouchMove,handleTouchEnd,isStatic]);return /*#__PURE__*/_jsxs(\"div\",{ref:containerRef,style:{position:\"relative\",width:\"100%\",height:\"100%\",minWidth:\"200px\",minHeight:\"150px\",overflow:\"hidden\",borderRadius:`${borderRadius}px`,cursor:isDragging?isHorizontal?\"ew-resize\":\"ns-resize\":\"pointer\",userSelect:\"none\",...props.style},onClick:isStatic?undefined:handleClick,onMouseDown:isStatic?undefined:handleMouseDown,role:\"slider\",\"aria-valuenow\":position,\"aria-valuemin\":0,\"aria-valuemax\":100,\"aria-orientation\":orientation,tabIndex:0,children:[/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",top:0,left:0,width:\"100%\",height:\"100%\",backgroundImage:`url(${afterImage.src})`,backgroundSize:\"cover\",backgroundPosition:\"center\"},\"aria-label\":afterImage.alt,role:\"img\"}),/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",top:0,left:0,width:\"100%\",height:\"100%\",backgroundImage:`url(${beforeImage.src})`,backgroundSize:\"cover\",backgroundPosition:\"center\",clipPath:isHorizontal?`inset(0 ${100-position}% 0 0)`:`inset(0 0 ${100-position}% 0)`},\"aria-label\":beforeImage.alt,role:\"img\"}),/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",top:isHorizontal?0:`${position}%`,left:isHorizontal?`${position}%`:0,width:isHorizontal?`${dividerWidth}px`:\"100%\",height:isHorizontal?\"100%\":`${dividerWidth}px`,backgroundColor:dividerColor,boxShadow:\"0 0 5px rgba(0, 0, 0, 0.3)\",transform:isHorizontal?`translateX(-${dividerWidth/2}px)`:`translateY(-${dividerWidth/2}px)`,cursor:isHorizontal?\"ew-resize\":\"ns-resize\",zIndex:2},onMouseDown:isStatic?undefined:handleMouseDown}),showHandle&&/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",top:isHorizontal?`calc(50% - ${handleSize/2}px)`:`${position}%`,left:isHorizontal?`${position}%`:`calc(50% - ${handleSize/2}px)`,width:`${handleSize}px`,height:`${handleSize}px`,borderRadius:\"50%\",backgroundColor:handleBackgroundColor,border:`2px solid ${handleBorderColor}`,boxShadow:\"0 2px 8px rgba(0, 0, 0, 0.2)\",transform:isHorizontal?`translateX(-${handleSize/2}px)`:`translateY(-${handleSize/2}px)`,cursor:isHorizontal?\"ew-resize\":\"ns-resize\",zIndex:3,display:\"flex\",justifyContent:\"center\",alignItems:\"center\",touchAction:\"none\"},onMouseDown:isStatic?undefined:handleMouseDown,onTouchStart:isStatic?undefined:handleTouchStart,children:/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",justifyContent:\"center\",alignItems:\"center\",gap:\"2px\",transform:isHorizontal?\"rotate(0deg)\":\"rotate(90deg)\"},children:[/*#__PURE__*/_jsx(\"svg\",{width:arrowSize,height:arrowSize,viewBox:\"0 0 24 24\",fill:\"none\",stroke:handleArrowColor,strokeWidth:\"2.5\",strokeLinecap:\"round\",strokeLinejoin:\"round\",children:/*#__PURE__*/_jsx(\"path\",{d:\"M15 18l-6-6 6-6\"})}),/*#__PURE__*/_jsx(\"svg\",{width:arrowSize,height:arrowSize,viewBox:\"0 0 24 24\",fill:\"none\",stroke:handleArrowColor,strokeWidth:\"2.5\",strokeLinecap:\"round\",strokeLinejoin:\"round\",children:/*#__PURE__*/_jsx(\"path\",{d:\"M9 18l6-6-6-6\"})})]})})]});}addPropertyControls(BeforeAfterSlider,{beforeImage:{type:ControlType.ResponsiveImage,title:\"Before Image\"},afterImage:{type:ControlType.ResponsiveImage,title:\"After Image\"},orientation:{type:ControlType.Enum,title:\"Orientation\",options:[\"horizontal\",\"vertical\"],optionTitles:[\"Horizontal\",\"Vertical\"],defaultValue:\"horizontal\",displaySegmentedControl:true},initialPosition:{type:ControlType.Number,title:\"Initial Position\",defaultValue:50,min:0,max:100,step:1,unit:\"%\"},dividerColor:{type:ControlType.Color,title:\"Divider Color\",defaultValue:\"#FFFFFF\"},dividerWidth:{type:ControlType.Number,title:\"Divider Width\",defaultValue:3,min:1,max:10,step:1,unit:\"px\"},showHandle:{type:ControlType.Boolean,title:\"Show Handle\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},handleBackgroundColor:{type:ControlType.Color,title:\"Handle Background\",defaultValue:\"#FFFFFF\",hidden:({showHandle})=>!showHandle},handleBorderColor:{type:ControlType.Color,title:\"Handle Border\",defaultValue:\"#E0E0E0\",hidden:({showHandle})=>!showHandle},handleArrowColor:{type:ControlType.Color,title:\"Arrow Color\",defaultValue:\"#666666\",hidden:({showHandle})=>!showHandle},arrowSize:{type:ControlType.Number,title:\"Arrow Size\",defaultValue:12,min:6,max:30,step:1,unit:\"px\",hidden:({showHandle})=>!showHandle},handleSize:{type:ControlType.Number,title:\"Handle Size\",defaultValue:40,min:20,max:80,step:2,unit:\"px\",hidden:({showHandle})=>!showHandle},borderRadius:{type:ControlType.Number,title:\"Border Radius\",defaultValue:8,min:0,max:50,step:1,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"BeforeAfterSlider\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerIntrinsicHeight\":\"300\",\"framerIntrinsicWidth\":\"500\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./BeforeAfterSlider.map"],"mappings":"8NAMG,SAAwB,EAAkB,EAAM,CAAC,GAAK,CAAC,cAAY,CAAC,IAAI,sEAAsE,IAAI,cAAc,EAAE,aAAW,CAAC,IAAI,oEAAoE,IAAI,aAAa,EAAE,cAAY,kBAAgB,eAAa,eAAa,aAAW,wBAAsB,oBAAkB,mBAAiB,aAAW,YAAU,gBAAc,EAAY,EAAa,IAAc,aAAmB,EAAaA,EAAO,IAAI,EAAO,CAAC,EAAS,GAAaC,EAAS,CAAe,EAAO,CAAC,EAAW,GAAeA,EAAS,EAAK,EAAQ,EAAS,EAAoB,EAAQ,EAAwBC,EAAY,GAAG,CAAC,GAAG,CAAC,EAAa,QAAQ,OAAO,IAAM,EAAK,EAAa,QAAQ,sBAAsB,EACtwB,EAAQ,YAAY,EAAE,EAAE,QAAQ,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,EAAE,QAAQ,EAAE,QAAc,EAAQ,YAAY,EAAE,EAAE,QAAQ,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,EAAE,QAAQ,EAAE,QAAQ,GAAG,EAAa,CAAC,IAAM,EAAE,EAAQ,EAAK,KAAW,EAAY,KAAK,IAAI,EAAE,KAAK,IAAI,IAAI,EAAE,EAAK,MAAM,GAAG,CAAC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