{"version":3,"file":"ImageZoom.WMSvsFKf.mjs","names":["useState","useRef"],"sources":["https:/framer.com/m/Framestack-SOWL.js@uaBGH0RSxo4YBCxquaGO","https:/framerusercontent.com/modules/kT9OBYJiTqqBwmWMf90S/WLHsyDCax8qLxHEpzzn2/ImageZoom.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{ControlType}from\"framer\";export function Message({title,subtitle}){return /*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",width:\"100%\",height:\"100%\",placeContent:\"center\",placeItems:\"center\",flexDirection:\"column\",backgroundColor:\"rgba(136, 85, 255, 0.1)\",borderRadius:6,border:\"1px dashed rgb(136, 85, 255)\",color:\"rgb(136, 85, 255)\",fontSize:12,padding:24},children:[/*#__PURE__*/_jsx(\"p\",{style:{margin:0,marginBottom:10,fontWeight:600,textAlign:\"center\"},children:title}),/*#__PURE__*/_jsx(\"p\",{style:{margin:0,opacity:.7,maxWidth:500,lineHeight:1.5,textAlign:\"center\"},children:subtitle})]});}export function borderProp({color=\"#222\"}){return{type:ControlType.Object,optional:true,controls:{color:{type:ControlType.Color,defaultValue:color},width:{type:ControlType.Padding,defaultValue:\"1px\"},style:{type:ControlType.Enum,defaultValue:\"solid\",options:[\"solid\",\"dashed\",\"dotted\",\"double\"],optionTitles:[\"Solid\",\"Dashed\",\"Dotted\",\"Double\"]}}};}export function Border({color,width,style,radius=\"inherit\"}){return /*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",inset:0,borderColor:color,borderWidth:width,borderStyle:style,borderRadius:radius,pointerEvents:\"none\"}});}\nexport const __FramerMetadata__ = {\"exports\":{\"borderProp\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"Message\":{\"type\":\"reactComponent\",\"name\":\"Message\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"Border\":{\"type\":\"reactComponent\",\"name\":\"Border\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Framestack.map","import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useState,useRef}from\"react\";import{borderProp,Border}from\"https://framer.com/m/Framestack-SOWL.js@uaBGH0RSxo4YBCxquaGO\";import{motion}from\"framer-motion\";/**\n * @framerSupportedLayoutWidth fixed\n * @framerIntrinsicWidth 600\n * @framerIntrinsicHeight 400\n */export default function ImageZoom(props){const{action}=props;const[zoom,setZoom]=useState(false);const[origin,setOrigin]=useState([50,50]);const imgRef=useRef(null);const updateOrigin=e=>{const{left,top,width,height}=imgRef.current.getBoundingClientRect();let x=(e.clientX-left)/width*100;let y=(e.clientY-top)/height*100;x=Math.max(0,Math.min(100,x));y=Math.max(0,Math.min(100,y));setOrigin([x,y]);};const handleMouseEnter=()=>{if(action===\"hover\")setZoom(true);};const handleMouseLeave=()=>{if(action===\"hover\")setZoom(false);};const handleMouseUp=e=>{if(action===\"press\"){setZoom(false);updateOrigin(e);document.removeEventListener(\"mousemove\",updateOrigin);document.removeEventListener(\"mouseup\",handleMouseUp);}};const handleMouseDown=e=>{if(action===\"press\"){setZoom(true);updateOrigin(e);document.addEventListener(\"mousemove\",updateOrigin);document.addEventListener(\"mouseup\",handleMouseUp);}};const handleMouseMove=e=>{if(zoom&&action===\"hover\")updateOrigin(e);};const preventDragHandler=e=>e.preventDefault();return /*#__PURE__*/_jsxs(\"div\",{onMouseEnter:handleMouseEnter,onMouseLeave:handleMouseLeave,onMouseDown:handleMouseDown,onMouseUp:handleMouseUp,onMouseMove:handleMouseMove,onDragStart:preventDragHandler,style:{display:\"inline-block\",borderRadius:props.radius,boxShadow:props.shadows,overflow:\"hidden\",position:\"relative\",backgroundColor:props.background,...props.style},children:[/*#__PURE__*/_jsx(motion.img,{ref:imgRef,src:props.image?.src,alt:props.image?.alt,initial:{scale:1},animate:{scale:zoom?props.zoomLevel:1},draggable:\"false\",style:{transformOrigin:`${origin[0]}% ${origin[1]}%`,width:\"100%\",height:props.sizing===\"contain\"?\"auto\":\"100%\",objectFit:props.sizing,userSelect:\"none\",display:\"block\"},transition:props.transition}),/*#__PURE__*/_jsx(Border,{...props.border,radius:props.radius})]});}ImageZoom.displayName=\"Image Zoom\";addPropertyControls(ImageZoom,{image:{type:ControlType.ResponsiveImage},sizing:{type:ControlType.Enum,defaultValue:\"cover\",options:[\"cover\",\"contain\",\"fill\"],optionTitles:[\"Fill\",\"Fit\",\"Stretch\"]},zoomLevel:{type:ControlType.Number,defaultValue:2,min:1,step:.01,unit:\"x\",title:\"Zoom\"},action:{type:ControlType.Enum,options:[\"hover\",\"press\"],optionTitles:[\"Hover\",\"Press\"],displaySegmentedControl:true,title:\"Zoom On\"},radius:{type:ControlType.BorderRadius},border:borderProp({}),shadows:{type:ControlType.BoxShadow},background:{type:ControlType.Color,optional:true},transition:{type:ControlType.Transition,defaultValue:{type:\"spring\",duration:.5,bounce:0}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ImageZoom\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"fixed\",\"framerIntrinsicHeight\":\"400\",\"framerIntrinsicWidth\":\"600\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ImageZoom.map"],"mappings":"iWAAspB,SAAgB,EAAW,CAAC,QAAM,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,EAAY,OAAO,SAAS,GAAK,SAAS,CAAC,MAAM,CAAC,KAAK,EAAY,MAAM,aAAa,EAAM,CAAC,MAAM,CAAC,KAAK,EAAY,QAAQ,aAAa,MAAM,CAAC,MAAM,CAAC,KAAK,EAAY,KAAK,aAAa,QAAQ,QAAQ,CAAC,QAAQ,SAAS,SAAS,SAAS,CAAC,aAAa,CAAC,QAAQ,SAAS,SAAS,SAAS,CAAC,CAAC,CAAC,AAAE,UAAgB,E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