{"version":3,"file":"ImageMagnifier.D0GSFmTe.mjs","names":["useRef","useState","useCallback","e"],"sources":["https:/framerusercontent.com/modules/j97xCjH7bcY4gxqE0w4H/lFbBlEjnmvouNDhtQuHp/ImageMagnifier.js"],"sourcesContent":["// Image upload component with circular magnifier effect on hover\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useRef,useState,startTransition,useCallback,useEffect}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";import React from\"react\";/**\n * Image upload with circular magnifier on hover\n * @framerIntrinsicWidth 360\n * @framerIntrinsicHeight 240\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function ImageMagnifier(props){const{imageFile=\"https://framerusercontent.com/images/GfGkADagM4KEibNcIiRUWlfrR0.jpg\",zoom,diameter,borderColor,borderWidth,background,style,magnifierDiameterMobile}=props;const containerRef=useRef(null);const[hovered,setHovered]=useState(false);const[mouse,setMouse]=useState({x:0,y:0});// Add smoothMouse state for interpolation\n// const [smoothMouse, setSmoothMouse] = useState({ x: 0, y: 0 })\nconst[uploadedImage,setUploadedImage]=useState();const[containerSize,setContainerSize]=useState({width:0,height:0});const isStatic=useIsStaticRenderer();// Track window size for mobile\nconst[isMobile,setIsMobile]=useState(false);useEffect(()=>{function handleResize(){if(typeof window!==\"undefined\"){setIsMobile(window.innerWidth<=600);}}handleResize();if(typeof window!==\"undefined\"){window.addEventListener(\"resize\",handleResize);}return()=>{if(typeof window!==\"undefined\"){window.removeEventListener(\"resize\",handleResize);}};},[]);const src=uploadedImage||imageFile;// New effect to update container size in the browser only\nReact.useEffect(()=>{if(typeof window!==\"undefined\"&&containerRef.current){const width=containerRef.current.offsetWidth;const height=containerRef.current.offsetHeight;setContainerSize({width,height});}},[zoom,hovered]);// Smoothly interpolate smoothMouse towards mouse on every frame while hovered\n/*useEffect(() => {\n    if (!hovered) return\n    let animationId: number\n    const ease = 0.22 // Easing factor (smaller = smoother, larger = faster)\n    function animate() {\n      setSmoothMouse(prev => {\n        const dx = mouse.x - prev.x\n        const dy = mouse.y - prev.y\n        // Use exponential decay for smooth interpolation\n        const nextX = Math.abs(dx) < 0.2 ? mouse.x : prev.x + dx * ease\n        const nextY = Math.abs(dy) < 0.2 ? mouse.y : prev.y + dy * ease\n        return { x: nextX, y: nextY }\n      })\n      animationId = requestAnimationFrame(animate)\n    }\n    animationId = requestAnimationFrame(animate)\n    return () => cancelAnimationFrame(animationId)\n  }, [hovered, mouse.x, mouse.y])*/const handleUpload=e=>{if(e.target.files&&e.target.files.length>0){const file=e.target.files[0];const reader=new FileReader;reader.onload=evt=>{if(evt.target&&typeof evt.target.result===\"string\"){startTransition(()=>setUploadedImage(evt.target.result));}};reader.readAsDataURL(file);}};const onMouseMove=useCallback(e=>{if(!containerRef.current)return;const rect=containerRef.current.getBoundingClientRect();const x=e.clientX-rect.left;const y=e.clientY-rect.top;startTransition(()=>setMouse({x,y}));},[]);// Render\nreturn /*#__PURE__*/_jsxs(\"div\",{ref:containerRef,style:{...style,position:\"relative\",overflow:\"visible\",display:\"flex\",justifyContent:\"center\",alignItems:\"center\",width:\"100%\",height:\"100%\",background,borderRadius:props.cornerRadius,touchAction:\"none\"},onMouseEnter:()=>!isStatic&&setHovered(true),onMouseLeave:()=>!isStatic&&setHovered(false),onMouseMove:isStatic?undefined:onMouseMove,onTouchStart:e=>{if(isStatic)return;setHovered(true);const touch=e.touches[0];if(touch&&containerRef.current){const rect=containerRef.current.getBoundingClientRect();const x=touch.clientX-rect.left;const y=touch.clientY-rect.top;setMouse({x,y});}},onTouchMove:e=>{if(isStatic)return;const touch=e.touches[0];if(touch&&containerRef.current){const rect=containerRef.current.getBoundingClientRect();const x=touch.clientX-rect.left;const y=touch.clientY-rect.top;setMouse({x,y});}},onTouchEnd:()=>!isStatic&&setHovered(false),tabIndex:0,children:[/*#__PURE__*/_jsx(\"img\",{src:src,style:{width:\"100%\",height:\"100%\",objectFit:\"contain\",transition:\"filter 0.12s\",display:\"block\"},alt:\"Uploaded\",draggable:false}),hovered&&!isStatic&&/*#__PURE__*/_jsx(\"div\",{style:{pointerEvents:\"none\",position:\"absolute\",left:mouse.x-(isMobile?magnifierDiameterMobile:diameter)/2,top:mouse.y-(isMobile?magnifierDiameterMobile:diameter)/2,width:isMobile?magnifierDiameterMobile:diameter,height:isMobile?magnifierDiameterMobile:diameter,borderRadius:\"50%\",border:`${borderWidth}px solid ${borderColor}`,boxSizing:\"border-box\",boxShadow:\"0 2px 12px 0 rgba(0,0,0,0.20)\",background:\"transparent\",overflow:\"hidden\",zIndex:9,backgroundClip:\"padding-box\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\"},children:/*#__PURE__*/_jsx(\"img\",{src:src,alt:\"MagZoom\",style:{position:\"absolute\",left:`-${mouse.x*zoom-(isMobile?magnifierDiameterMobile:diameter)/2}px`,top:`-${mouse.y*zoom-(isMobile?magnifierDiameterMobile:diameter)/2}px`,width:`${containerSize.width*zoom}px`,height:`${containerSize.height*zoom}px`,pointerEvents:\"none\",userSelect:\"none\",objectFit:\"fill\"},draggable:false})})]});}addPropertyControls(ImageMagnifier,{imageFile:{type:ControlType.File,allowedFileTypes:[\"jpg\",\"jpeg\",\"png\",\"gif\",\"webp\",\"svg\"]},zoom:{type:ControlType.Number,title:\"Zoom\",defaultValue:2,min:1.1,max:8,step:.1,displayStepper:false},diameter:{type:ControlType.Number,title:\"Magnifier Size\",defaultValue:120,min:60,max:260,unit:\"px\",step:4},borderColor:{type:ControlType.Color,title:\"Border Color\",defaultValue:\"#fff\"},borderWidth:{type:ControlType.Number,title:\"Border Width\",defaultValue:2,min:0,max:8,step:1,unit:\"px\"},background:{type:ControlType.Color,title:\"Background\",defaultValue:\"#eeeeee\"},cornerRadius:{type:ControlType.Number,title:\"Corner Radius\",defaultValue:16,min:0,max:64,step:1,unit:\"px\"},magnifierDiameterMobile:{type:ControlType.Number,title:\"Magnifier Size (Mobile)\",defaultValue:90,min:48,max:200,step:4,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ImageMagnifier\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"360\",\"framerIntrinsicHeight\":\"240\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ImageMagnifier.map"],"mappings":"0OAOG,SAAwB,EAAe,EAAM,CAAC,GAAK,CAAC,YAAU,sEAAsE,OAAK,WAAS,cAAY,cAAY,aAAW,QAAM,2BAAyB,EAAY,EAAaA,EAAO,KAAK,CAAM,CAAC,EAAQ,GAAYC,EAAS,GAAM,CAAM,CAAC,EAAM,GAAUA,EAAS,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAE3U,CAAC,EAAc,GAAkBA,GAAU,CAAM,CAAC,EAAc,GAAkBA,EAAS,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAAO,EAAS,GAAqB,CACnJ,CAAC,EAAS,GAAaA,EAAS,GAAM,CAAC,MAAc,CAAC,SAAS,GAAc,CAAW,IAAS,QAAa,EAAY,EAAO,YAAY,IAAI,CAAkG,OAA/F,GAAc,CAAW,IAAS,QAAa,EAAO,iBAAiB,SAAS,EAAa,KAAY,CAAW,IAAS,QAAa,EAAO,oBAAoB,SAAS,EAAa,GAAM,EAAE,CAAC,CAAC,IAAM,EAAI,GAAe,EACvX,EAAM,cAAc,CAAC,GAAU,IAAS,QAAa,EAAa,QAAQ,CAAC,IAAM,EAAM,EAAa,QAAQ,YAAkB,EAAO,EAAa,QAAQ,aAAa,EAAiB,CAAC,QAAM,SAAO,CAAC,GAAI,CAAC,EAAK,EAAQ,CAAC,CAkBuG,IAAM,EAAYC,EAAY,GAAG,CAAC,GAAG,CAAC,EAAa,QAAQ,OAAO,IAAM,EAAK,EAAa,QAAQ,uBAAuB,C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