{"version":3,"file":"ImageZoom_Prod.CZTCeTAJ.mjs","names":["useRef","__esmMin","init_ssg_sandbox_shims","init_npm_react_18_3_1","de","window","init_jsx_runtime","c","p","ce","motion","useSpring","init_framer_motion_DhsWWWsN","useReducedMotion","addPropertyControls","ControlType","init_framer_DKWANagr","ImageZoom","props","rootRef","rectRef","pointerRef","reduceMotion","scale","SPRING","x","y","zoom","zoomLevel","measure","aim","rect","relX","clamp01","clientX","relY","clientY","targetX","targetY","refreshRef","stopTracking","handlePointerEnter","event","handlePointerMove","handlePointerLeave","pointer","layerStyle","imageStyle","image","borderStyle","border","radius","shadows","style","DEFAULT_IMAGE","DEFAULT_BORDER","init_ImageZoom_Prod","value"],"sources":["https:/framerusercontent.com/modules/Dk4BjE6lb32aFuJDx8Kp/pRj4CKGASuNaM9eYS43Y/ImageZoom_Prod.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useRef}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{motion,useReducedMotion,useSpring}from\"framer-motion\";const DEFAULT_IMAGE=\"https://framerusercontent.com/images/H1yOpzGMVETlNCBSaVL3ULIjYo.png?width=1024&height=1024\";const DEFAULT_BORDER={borderWidth:1,borderStyle:\"solid\",borderColor:\"rgba(255, 255, 255, 0.1)\"};const SPRING={stiffness:150,damping:20,mass:.5};const clamp01=value=>Math.min(1,Math.max(0,value));/**\n * @framerIntrinsicWidth 400\n * @framerIntrinsicHeight 400\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n *\n * @framerDisableUnlink\n */export default function ImageZoom(props){const{image,zoomLevel=1.5,radius=\"8px\",border,shadows,style}=props;const rootRef=useRef(null);const rectRef=useRef(null);const pointerRef=useRef(null);const reduceMotion=useReducedMotion();const scale=useSpring(1,SPRING);const x=useSpring(0,SPRING);const y=useSpring(0,SPRING);const zoom=Math.max(1,zoomLevel);const measure=()=>{if(rootRef.current){rectRef.current=rootRef.current.getBoundingClientRect();}};// Aim at the final zoom level, not the mid-animation scale: scale, x and y\n// share one spring, so the image point under the cursor stays put from the\n// first frame instead of zooming to the centre and drifting afterwards.\nconst aim=(clientX,clientY)=>{const rect=rectRef.current;if(!rect||!rect.width||!rect.height)return;const relX=clamp01((clientX-rect.left)/rect.width);const relY=clamp01((clientY-rect.top)/rect.height);const targetX=(.5-relX)*rect.width*(zoom-1);const targetY=(.5-relY)*rect.height*(zoom-1);if(reduceMotion){scale.jump(zoom);x.jump(targetX);y.jump(targetY);}else{scale.set(zoom);x.set(targetX);y.set(targetY);}};const refreshRef=useRef(()=>{if(pointerRef.current)measure();});const stopTracking=()=>{window.removeEventListener(\"scroll\",refreshRef.current,true);window.removeEventListener(\"resize\",refreshRef.current);};const handlePointerEnter=event=>{measure();window.addEventListener(\"scroll\",refreshRef.current,true);window.addEventListener(\"resize\",refreshRef.current);pointerRef.current={x:event.clientX,y:event.clientY};aim(event.clientX,event.clientY);};const handlePointerMove=event=>{if(!pointerRef.current)return;pointerRef.current={x:event.clientX,y:event.clientY};aim(event.clientX,event.clientY);};const handlePointerLeave=()=>{stopTracking();pointerRef.current=null;if(reduceMotion){scale.jump(1);x.jump(0);y.jump(0);}else{scale.set(1);x.set(0);y.set(0);}};// Re-aim when the zoom level is edited while hovered (live canvas edits).\nuseEffect(()=>{const pointer=pointerRef.current;if(pointer){measure();aim(pointer.x,pointer.y);}},[zoom]);useEffect(()=>stopTracking,[]);const layerStyle={width:\"100%\",height:\"100%\"};const imageStyle={display:\"block\",width:\"100%\",height:\"100%\",objectFit:\"cover\",objectPosition:`${image?.positionX||\"50%\"} ${image?.positionY||\"50%\"}`,pointerEvents:\"none\",userSelect:\"none\"};const borderStyle=border?{position:\"absolute\",inset:0,borderRadius:radius,boxSizing:\"border-box\",pointerEvents:\"none\",...border}:null;return /*#__PURE__*/_jsxs(\"div\",{ref:rootRef,style:{position:\"relative\",overflow:\"hidden\",width:\"100%\",height:\"100%\",borderRadius:radius,boxShadow:shadows,userSelect:\"none\",...style},onPointerEnter:handlePointerEnter,onPointerMove:handlePointerMove,onPointerLeave:handlePointerLeave,children:[/*#__PURE__*/_jsx(motion.div,{style:{...layerStyle,scale,x,y},children:/*#__PURE__*/_jsx(\"img\",{src:image?.src||DEFAULT_IMAGE,srcSet:image?.src?image.srcSet:undefined,alt:image?.alt||\"\",draggable:false,style:imageStyle})}),borderStyle&&/*#__PURE__*/_jsx(\"div\",{\"aria-hidden\":\"true\",style:borderStyle})]});}addPropertyControls(ImageZoom,{image:{type:ControlType.ResponsiveImage,title:\"Image\"},zoomLevel:{type:ControlType.Number,title:\"Zoom level\",defaultValue:1.5,min:1,max:10,step:.1,unit:\"x\",displayStepper:true},radius:{type:ControlType.BorderRadius,title:\"Radius\",defaultValue:\"8px\"},border:{type:ControlType.Border,title:\"Border\",defaultValue:DEFAULT_BORDER,optional:true},shadows:{type:ControlType.BoxShadow,title:\"Shadow\",description:\"More components at [Framer University](https://frameruni.link/cc).\"}});ImageZoom.displayName=\"Image Hover Zoom\";\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ImageZoom\",\"slots\":[],\"annotations\":{\"framerIntrinsicHeight\":\"400\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerIntrinsicWidth\":\"400\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerDisableUnlink\":\"\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ImageZoom_Prod.map"],"mappings":"A,wQAQG,SAAwBiB,EAAU,EAAM,CAAC,GAAK,CAAC,QAAM,YAAU,IAAI,SAAO,MAAM,SAAO,UAAQ,SAAOC,EAAYC,EAAQnB,EAAO,IAAI,EAAQoB,EAAQpB,EAAO,IAAI,EAAQqB,EAAWrB,EAAO,IAAI,EAAQsB,EAAaT,EAAiB,EAAQU,EAAMZ,EAAU,EAAEa,CAAM,EAAQC,EAAE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