{"version":3,"file":"Befor_After_Slider.DLkRLuIe.mjs","names":["React.useRef","React.useState"],"sources":["https:/framerusercontent.com/modules/QxoYb5f6DAQe5mYDbWRk/B9dSbP7GdyzyZCUfZOjM/Befor_After_Slider.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{Frame,useMotionValue,useTransform,motion,animate,addPropertyControls,ControlType}from\"framer\";/**\n * BEFORE AFTER SLIDER\n * Fully responsive with default size\n *\n * @framerDisableUnlink\n *\n * @framerIntrinsicWidth 600\n * @framerIntrinsicHeight 500\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */function BeforeAfterSlider(props){return /*#__PURE__*/_jsx(Frame,{width:\"100%\",height:\"100%\",background:\"transparent\",style:{position:\"relative\",overflow:\"hidden\"},children:/*#__PURE__*/_jsx(SliderContent,{...props})});}function SliderContent({beforeImage=\"\",afterImage=\"\",initialSliderPosition=.11,isVertical=false,borderRadius=12,showLabels=true,labelBackgroundColor=\"rgba(0, 0, 0, 0.6)\",labelTextColor=\"#FFFFFF\",labelBlur=5,beforeLabelText=\"BEFORE\",afterLabelText=\"AFTER\"}){const containerRef=React.useRef(null);const position=useMotionValue(0);const[fontSize,setFontSize]=React.useState(\"16px\")// State for font size\n;const[logoSize,setLogoSize]=React.useState(\"120px\")// State for logo size\n;React.useEffect(()=>{const updateSizes=entries=>{for(let entry of entries){if(entry.target){const{width,height}=entry.contentRect;const baseSize=Math.min(width,height)// Use the smaller dimension\n;// Update font size (clamped between 14px and 18px)\nconst calculatedFontSize=baseSize*.04// 4% of the smaller dimension\n;setFontSize(`${Math.min(Math.max(calculatedFontSize,14),18)}px`);// Update logo size (clamped between 32px and 120px)\nconst calculatedLogoSize=baseSize*.2// 20% of the smaller dimension\n;setLogoSize(`${Math.min(Math.max(calculatedLogoSize,32),120)}px`);}}};const observer=new ResizeObserver(updateSizes);if(containerRef.current){observer.observe(containerRef.current);}return()=>{if(containerRef.current){observer.unobserve(containerRef.current);}};},[]);React.useEffect(()=>{if(containerRef.current){const containerSize=isVertical?containerRef.current.offsetHeight:containerRef.current.offsetWidth;position.set(containerSize*initialSliderPosition);}},[initialSliderPosition,isVertical]);const clipPath=useTransform(position,val=>isVertical?`inset(${val}px 0 0 0)`:`inset(0 0 0 ${val}px)`);const beforeTagOpacity=useTransform(position,val=>{if(!containerRef.current||!showLabels)return 0;const size=isVertical?containerRef.current.offsetHeight:containerRef.current.offsetWidth;return val/size>.1?1:0;});const afterTagOpacity=useTransform(position,val=>{if(!containerRef.current||!showLabels)return 0;const size=isVertical?containerRef.current.offsetHeight:containerRef.current.offsetWidth;return val/size<.9?1:0;});const handleContainerClick=event=>{if(containerRef.current){const bounds=containerRef.current.getBoundingClientRect();const clickPosition=isVertical?event.clientY-bounds.top:event.clientX-bounds.left;animate(position,clickPosition,{type:\"spring\",stiffness:200,damping:25});}};if(!beforeImage&&!afterImage){return /*#__PURE__*/_jsxs(\"div\",{ref:containerRef,style:{width:\"100%\",height:\"100%\",display:\"flex\",flexDirection:\"column\",alignItems:\"center\",justifyContent:\"center\",backgroundColor:\"#F0F6FF\",position:\"relative\",overflow:\"hidden\",borderRadius:`${borderRadius}px`},children:[/*#__PURE__*/_jsx(\"img\",{src:\"https://raw.githubusercontent.com/Muhammadrashed29/mrframerlogo/refs/heads/main/MRFRAMER.svg\",alt:\"MRFramer Logo\",style:{width:logoSize,height:\"auto\",marginBottom:\"16px\"}}),/*#__PURE__*/_jsx(\"p\",{style:{color:\"#000000\",fontSize:fontSize,fontWeight:\"500\",margin:\"0\",textAlign:\"center\"},children:\"Upload 2 Images to Continue\"})]});}if(!beforeImage||!afterImage){const image=beforeImage||afterImage;return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{width:\"100%\",height:\"100%\",position:\"relative\",overflow:\"hidden\",borderRadius:`${borderRadius}px`},children:/*#__PURE__*/_jsx(\"div\",{style:{backgroundImage:`url(${image})`,backgroundSize:\"cover\",backgroundPosition:\"center\",position:\"absolute\",width:\"100%\",height:\"100%\"}})});}return /*#__PURE__*/_jsxs(\"div\",{ref:containerRef,style:{width:\"100%\",height:\"100%\",position:\"relative\",overflow:\"hidden\",borderRadius:`${borderRadius}px`},onClick:handleContainerClick,children:[/*#__PURE__*/_jsx(\"div\",{style:{backgroundImage:`url(${beforeImage})`,backgroundSize:\"cover\",backgroundPosition:\"center\",position:\"absolute\",width:\"100%\",height:\"100%\"}}),/*#__PURE__*/_jsx(motion.div,{style:{backgroundImage:`url(${afterImage})`,backgroundSize:\"cover\",backgroundPosition:\"center\",position:\"absolute\",width:\"100%\",height:\"100%\",clipPath:clipPath}}),showLabels&&/*#__PURE__*/_jsx(motion.div,{style:{position:\"absolute\",top:isVertical?\"20px\":\"unset\",bottom:isVertical?\"unset\":\"20px\",left:\"20px\",background:labelBackgroundColor,color:labelTextColor,padding:\"5px 10px\",borderRadius:\"5px\",fontSize:\"12px\",fontWeight:\"bold\",textTransform:\"uppercase\",opacity:beforeTagOpacity,transition:\"opacity 0.3s ease\",backdropFilter:`blur(${labelBlur}px)`,WebkitBackdropFilter:`blur(${labelBlur}px)`},children:afterLabelText}),showLabels&&/*#__PURE__*/_jsx(motion.div,{style:{position:\"absolute\",bottom:\"20px\",right:\"20px\",background:labelBackgroundColor,color:labelTextColor,padding:\"5px 10px\",borderRadius:\"5px\",fontSize:\"12px\",fontWeight:\"bold\",textTransform:\"uppercase\",opacity:afterTagOpacity,transition:\"opacity 0.3s ease\",backdropFilter:`blur(${labelBlur}px)`,WebkitBackdropFilter:`blur(${labelBlur}px)`},children:beforeLabelText}),/*#__PURE__*/_jsx(SliderHandle,{position:position,containerRef:containerRef,isVertical:isVertical})]});}function SliderHandle({position,containerRef,isVertical}){const handleSize=40;const lineThickness=4;return /*#__PURE__*/_jsx(motion.div,{drag:isVertical?\"y\":\"x\",dragConstraints:containerRef,dragElastic:0,style:{[isVertical?\"y\":\"x\"]:position,position:\"absolute\",top:isVertical?`${-lineThickness/2}px`:\"0\",bottom:isVertical?`${-lineThickness/2}px`:\"0\",left:isVertical?\"0\":`${-lineThickness/2}px`,right:isVertical?\"0\":`${-lineThickness/2}px`,width:isVertical?\"100%\":`${lineThickness}px`,height:isVertical?`${lineThickness}px`:\"100%\",background:\"rgba(255, 255, 255, 0.4)\",cursor:isVertical?\"ns-resize\":\"ew-resize\"},transition:{type:\"spring\",stiffness:200,damping:25},children:/*#__PURE__*/_jsx(\"div\",{style:{width:`${handleSize}px`,height:`${handleSize}px`,borderRadius:\"50%\",background:\"rgba(0, 0, 0, 0.6)\",backdropFilter:\"blur(10px)\",WebkitBackdropFilter:\"blur(10px)\",position:\"absolute\",top:\"50%\",left:\"50%\",transform:`translate(-50%, -50%) rotate(${isVertical?\"0deg\":\"90deg\"})`,display:\"flex\",alignItems:\"center\",justifyContent:\"center\"},children:/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",flexDirection:\"column\",justifyContent:\"space-between\",alignItems:\"center\",height:\"60%\"},children:[/*#__PURE__*/_jsx(\"div\",{style:{width:0,height:0,borderLeft:\"6px solid transparent\",borderRight:\"6px solid transparent\",borderBottom:\"8px solid #FFF\"}}),/*#__PURE__*/_jsx(\"div\",{style:{width:0,height:0,borderLeft:\"6px solid transparent\",borderRight:\"6px solid transparent\",borderTop:\"8px solid #FFF\"}})]})})});}// Add property controls for Framer UI customization\naddPropertyControls(BeforeAfterSlider,{beforeImage:{type:ControlType.Image,title:\"Image 1\"},afterImage:{type:ControlType.Image,title:\"Image 2\"},initialSliderPosition:{type:ControlType.Number,title:\"Initial Position\",defaultValue:.11,min:0,max:1,step:.01},isVertical:{type:ControlType.Boolean,title:\"Vertical Slider\",defaultValue:false},borderRadius:{type:ControlType.Number,title:\"Radius\",defaultValue:0,min:0},showLabels:{type:ControlType.Boolean,title:\"Show Labels\",defaultValue:true,description:\"Use it to show or hide labels\"},labelBackgroundColor:{type:ControlType.Color,title:\"Label Background\",defaultValue:\"rgba(0, 0, 0, 0.6)\"},labelTextColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#FFFFFF\"},labelBlur:{type:ControlType.Number,title:\"Label Blur\",defaultValue:5,min:0,max:10,description:\"[Mr. Framer](https://mrframer.com), Get Free High Quality Framer Resources.\"},beforeLabelText:{type:ControlType.String,title:\"Right Label\",defaultValue:\"BEFORE\"},afterLabelText:{type:ControlType.String,title:\"Left Label\",defaultValue:\"AFTER\"}});// Set display name for Framer UI\nBeforeAfterSlider.displayName=\"Before After Slider\";export default BeforeAfterSlider;\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"BeforeAfterSlider\",\"slots\":[],\"annotations\":{\"framerIntrinsicHeight\":\"500\",\"framerContractVersion\":\"1\",\"framerDisableUnlink\":\"*\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerIntrinsicWidth\":\"600\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Befor_After_Slider.map"],"mappings":"qQAUG,SAAS,EAAkB,EAAM,CAAC,OAAoB,EAAK,EAAM,CAAC,MAAM,OAAO,OAAO,OAAO,WAAW,cAAc,MAAM,CAAC,SAAS,WAAW,SAAS,SAAS,CAAC,SAAsB,EAAK,EAAc,CAAC,GAAG,EAAM,CAAC,CAAC,CAAC,CAAE,SAAS,EAAc,CAAC,cAAY,GAAG,aAAW,GAAG,wBAAsB,IAAI,aAAW,GAAM,eAAa,GAAG,aAAW,GAAK,uBAAqB,qBAAqB,iBAAe,UAAU,YAAU,EAAE,kBAAgB,SAAS,iBAAe,SAAS,CAAC,IAAM,EAAaA,EAAa,KAAK,CAAO,EAAS,EAAe,EAAE,CAAM,CAAC,EAAS,GAAaC,EAAe,OAAO,CACnlB,CAAC,EAAS,GAAaA,EAAe,QAAQ,CACnD,MAAoB,CAKkD,IAAM,EAAS,IAAI,eALlD,GAAS,CAAC,IAAI,IAAI,KA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