{"version":3,"file":"Transform_Slider.BiijW9Ku.mjs","names":["useRef","useState","useCallback","_Fragment"],"sources":["https:/framerusercontent.com/modules/Plsq5kwxDqA4EUAhuRcj/bjh1pAlW3tLrgILtu632/Transform_Slider.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{useState,useRef,useCallback,useEffect}from\"react\";import{motion}from\"framer-motion\";import{addPropertyControls,ControlType}from\"framer\";const getImageUrl=image=>{if(!image)return\"\";if(typeof image===\"string\")return image;const anyImage=image;if(anyImage.src&&typeof anyImage.src===\"object\"&&typeof anyImage.src.url===\"string\"){return anyImage.src.url;}if(typeof anyImage.src===\"string\")return anyImage.src;if(typeof anyImage.url===\"string\")return anyImage.url;return\"\";};/**\n * @framerDisableUnlink\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n * @framerIntrinsicWidth 400\n * @framerIntrinsicHeight 200\n */export default function TransformSlider(props){const{beforeImage=\"https://images.unsplash.com/photo-1560448204-e02f11c3d0e2?w=800&auto=format&fit=crop&q=80&sat=-100\",afterImage=\"https://images.unsplash.com/photo-1560448204-e02f11c3d0e2?w=800&auto=format&fit=crop&q=80\",sliderThumb,handleColor=\"#ffffff\",borderRadius=12,labelBackground=\"rgba(0, 0, 0, 0.75)\",labelColor=\"#ffffff\",showDivider=true,dividerColor=\"#ffffff\",dividerWidth=2,sliderSize=48,interaction=\"click\",transition={type:\"spring\"}}=props;const containerRef=useRef(null);const[isDragging,setIsDragging]=useState(false);const[sliderPosition,setSliderPosition]=useState(50);const beforeImageUrl=getImageUrl(beforeImage);const afterImageUrl=getImageUrl(afterImage);const sliderThumbUrl=getImageUrl(sliderThumb);const handleDrag=useCallback(clientX=>{if(!containerRef.current)return;const rect=containerRef.current.getBoundingClientRect();const x=clientX-rect.left;const percentage=Math.max(0,Math.min(100,x/rect.width*100));setSliderPosition(percentage);},[]);const handleMouseDown=useCallback(e=>{if(interaction!==\"click\")return;e.preventDefault();setIsDragging(true);handleDrag(e.clientX);},[handleDrag,interaction]);const handleMouseMove=useCallback(e=>{if(interaction===\"hover\"){handleDrag(e.clientX);}},[handleDrag,interaction]);const handleTouchStart=useCallback(e=>{setIsDragging(true);handleDrag(e.touches[0].clientX);},[handleDrag]);const handleTouchMove=useCallback(e=>{if(!isDragging)return;handleDrag(e.touches[0].clientX);},[isDragging,handleDrag]);useEffect(()=>{const handleWindowMouseMove=e=>{if(interaction!==\"click\"||!isDragging)return;handleDrag(e.clientX);};const handleMouseUp=()=>setIsDragging(false);window.addEventListener(\"mousemove\",handleWindowMouseMove);window.addEventListener(\"mouseup\",handleMouseUp);return()=>{window.removeEventListener(\"mousemove\",handleWindowMouseMove);window.removeEventListener(\"mouseup\",handleMouseUp);};},[isDragging,handleDrag,interaction]);const getContrastColor=color=>{if(!color)return\"#333333\";if(color.startsWith(\"rgba\")||color.startsWith(\"rgb\")){const match=color.match(/\\d+/g);if(match&&match.length>=3){const r=Number(match[0]);const g=Number(match[1]);const b=Number(match[2]);const brightness=(r*299+g*587+b*114)/1e3;return brightness>128?\"#333333\":\"#ffffff\";}}if(color.startsWith(\"#\")&&color.length>=7){const hex=color.replace(\"#\",\"\");const r=parseInt(hex.substring(0,2),16);const g=parseInt(hex.substring(2,4),16);const b=parseInt(hex.substring(4,6),16);const brightness=(r*299+g*587+b*114)/1e3;return brightness>128?\"#333333\":\"#ffffff\";}return\"#333333\";};const arrowColor=getContrastColor(handleColor);return /*#__PURE__*/_jsxs(motion.div,{ref:containerRef,style:{position:\"relative\",width:\"100%\",height:\"100%\",overflow:\"hidden\",borderRadius,cursor:interaction===\"hover\"?\"ew-resize\":isDragging?\"grabbing\":\"ew-resize\",userSelect:\"none\",touchAction:\"pan-y\",backgroundColor:\"#f0f0f0\"},onMouseDown:handleMouseDown,onMouseMove:handleMouseMove,onTouchStart:handleTouchStart,onTouchMove:handleTouchMove,onTouchEnd:()=>setIsDragging(false),children:[/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",inset:0,backgroundImage:`url(${afterImageUrl})`,backgroundSize:\"cover\",backgroundPosition:\"center\"}}),/*#__PURE__*/_jsx(motion.div,{style:{position:\"absolute\",inset:0,backgroundImage:`url(${beforeImageUrl})`,backgroundSize:\"cover\",backgroundPosition:\"center\",clipPath:`inset(0 ${100-sliderPosition}% 0 0)`},animate:{clipPath:`inset(0 ${100-sliderPosition}% 0 0)`},transition:transition}),/*#__PURE__*/_jsxs(motion.div,{style:{position:\"absolute\",top:0,bottom:0,left:`${sliderPosition}%`,width:0,zIndex:10},animate:{left:`${sliderPosition}%`},transition:transition,children:[showDivider&&/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",top:0,bottom:0,left:-dividerWidth/2,width:dividerWidth,backgroundColor:dividerColor,boxShadow:\"0 0 12px rgba(0,0,0,0.3)\"}}),/*#__PURE__*/_jsx(motion.div,{style:{position:\"absolute\",top:\"50%\",left:-sliderSize/2,marginTop:-sliderSize/2,width:sliderSize,height:sliderSize,borderRadius:\"50%\",backgroundColor:sliderThumbUrl?\"transparent\":handleColor,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",boxShadow:\"0 2px 8px rgba(0,0,0,0.2), 0 4px 16px rgba(0,0,0,0.15)\",border:\"2px solid rgba(255,255,255,0.2)\",overflow:\"hidden\"},whileHover:{scale:1.1},whileTap:{scale:.95},animate:{scale:isDragging?1.05:1},transition:transition,children:sliderThumbUrl?/*#__PURE__*/_jsx(\"img\",{src:sliderThumbUrl,style:{width:\"100%\",height:\"100%\",objectFit:\"contain\",borderRadius:\"50%\",pointerEvents:\"none\"}}):/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(\"svg\",{width:\"800px\",height:\"800px\",viewBox:\"0 0 1024 1024\",version:\"1.1\",xmlns:\"http://www.w3.org/2000/svg\",children:/*#__PURE__*/_jsx(\"path\",{d:\"M768 903.232l-50.432 56.768L256 512l461.568-448 50.432 56.768L364.928 512z\",fill:\"#000000\"})}),/*#__PURE__*/_jsx(\"svg\",{width:\"800px\",height:\"800px\",viewBox:\"0 0 1024 1024\",version:\"1.1\",xmlns:\"http://www.w3.org/2000/svg\",children:/*#__PURE__*/_jsx(\"path\",{d:\"M256 120.768L306.432 64 768 512l-461.568 448L256 903.232 659.072 512z\",fill:\"#000000\"})})]})})]}),/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",top:16,left:16,padding:\"8px 16px\",backgroundColor:labelBackground,color:labelColor,borderRadius:8,fontSize:14,fontWeight:600,pointerEvents:\"none\"},children:\"Before\"}),/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",top:16,right:16,padding:\"8px 16px\",backgroundColor:labelBackground,color:labelColor,borderRadius:8,fontSize:14,fontWeight:600,pointerEvents:\"none\"},children:\"After\"})]});}addPropertyControls(TransformSlider,{beforeImage:{type:ControlType.Image,title:\"Before Image\"},afterImage:{type:ControlType.Image,title:\"After Image\"},sliderThumb:{type:ControlType.Image,title:\"Slider Thumb\"},interaction:{type:ControlType.Enum,title:\"Interaction\",options:[\"click\",\"hover\"],optionTitles:[\"Click\",\"Hover\"],defaultValue:\"click\"},showDivider:{type:ControlType.Boolean,title:\"Show Divider\",defaultValue:true},dividerColor:{type:ControlType.Color,title:\"Divider Color\",defaultValue:\"#FFFFFF\"},dividerWidth:{type:ControlType.Number,title:\"Divider Width\",defaultValue:2,min:1,max:10},sliderSize:{type:ControlType.Number,title:\"Slider Size\",defaultValue:40,min:30,max:120},borderRadius:{type:ControlType.Number,title:\"Border Radius\",defaultValue:12,min:0,max:100},transition:{type:ControlType.Transition,title:\"Transition\",description:\"by [FramerGeeks](https://www.framergeeks.com)\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TransformSlider\",\"slots\":[],\"annotations\":{\"framerIntrinsicHeight\":\"200\",\"framerDisableUnlink\":\"* @framerSupportedLayoutWidth any\",\"framerIntrinsicWidth\":\"400\",\"framerContractVersion\":\"1\",\"framerSupport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