{"version":3,"file":"Tilt_Image.Cfbs8JYZ.mjs","names":["useRef","useState","useCallback","_Fragment"],"sources":["https:/framerusercontent.com/modules/4GeKoRaLNTDdB1j1ShXq/FuIRH3fr7bOyVzc2RyPh/Tilt_Image.js"],"sourcesContent":["// 3D tilt card with editable image that tilts based on cursor position with shadow transform\nimport{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{useRef,useState,useCallback,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{motion,useMotionValue,useSpring,useTransform}from\"framer-motion\";/**\n * 3D Tilt Image\n *\n * @framerIntrinsicWidth 300\n * @framerIntrinsicHeight 400\n *\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n */export default function TiltImage3D(props){const{image,tiltIntensity=15,enableShine=true,shineIntensity=.3,enable3DDepth=true,depthIntensity=30,tiltX=0,tiltY=0,rotationZ=0,innerPaddingX=0,innerPaddingY=0,imageFit=\"cover\"}=props;const cardRef=useRef(null);const[isHovered,setIsHovered]=useState(false);const[isDragging,setIsDragging]=useState(false);const rotateX=useMotionValue(tiltX);const rotateY=useMotionValue(tiltY);const shineX=useMotionValue(50);const shineY=useMotionValue(50);const springConfig={damping:20,stiffness:300};const rotateXSpring=useSpring(rotateX,springConfig);const rotateYSpring=useSpring(rotateY,springConfig);const shineGradient=useTransform([shineX,shineY],([x,y])=>`radial-gradient(circle at ${x}% ${y}%, rgba(255, 255, 255, ${shineIntensity}) 0%, transparent 50%)`);const handleMouseMove=useCallback(e=>{if(!cardRef.current)return;const rect=cardRef.current.getBoundingClientRect();const centerX=rect.left+rect.width/2;const centerY=rect.top+rect.height/2;const mouseX=e.clientX-centerX;const mouseY=e.clientY-centerY;const rotateYValue=tiltY+mouseX/(rect.width/2)*tiltIntensity;const rotateXValue=tiltX-mouseY/(rect.height/2)*tiltIntensity;const shineXValue=(e.clientX-rect.left)/rect.width*100;const shineYValue=(e.clientY-rect.top)/rect.height*100;rotateX.set(rotateXValue);rotateY.set(rotateYValue);shineX.set(shineXValue);shineY.set(shineYValue);},[tiltIntensity,rotateX,rotateY,shineX,shineY,tiltX,tiltY]);const handleMouseEnter=useCallback(()=>{startTransition(()=>setIsHovered(true));},[]);const handleMouseLeave=useCallback(()=>{startTransition(()=>setIsHovered(false));rotateX.set(tiltX);rotateY.set(tiltY);shineX.set(50);shineY.set(50);},[rotateX,rotateY,shineX,shineY,tiltX,tiltY]);const handleDragOver=useCallback(e=>{e.preventDefault();startTransition(()=>setIsDragging(true));},[]);const handleDragLeave=useCallback(()=>{startTransition(()=>setIsDragging(false));},[]);const handleDrop=useCallback(e=>{e.preventDefault();startTransition(()=>setIsDragging(false));},[]);const showPlaceholder=!image?.src||isDragging;const imageBackgroundSize=imageFit===\"fill\"?\"100% 100%\":\"cover\";return /*#__PURE__*/_jsx(\"div\",{ref:cardRef,onMouseMove:handleMouseMove,onMouseEnter:handleMouseEnter,onMouseLeave:handleMouseLeave,onDragOver:handleDragOver,onDragLeave:handleDragLeave,onDrop:handleDrop,style:{width:\"100%\",height:\"100%\",perspective:1500,padding:`${innerPaddingY}px ${innerPaddingX}px`,boxSizing:\"border-box\",overflow:\"visible\"},children:/*#__PURE__*/_jsx(motion.div,{style:{width:\"100%\",height:\"100%\",transformStyle:\"preserve-3d\",rotateX:rotateXSpring,rotateY:rotateYSpring,rotateZ:rotationZ,position:\"relative\"},animate:{scale:isHovered?1.05:1},transition:{duration:.3},children:showPlaceholder?/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",width:\"100%\",height:\"100%\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",backgroundColor:\"#F5F5F5\",border:\"2px dashed #CCCCCC\",borderRadius:\"8px\",color:\"#666666\",fontSize:\"16px\",fontWeight:500,textAlign:\"center\",padding:\"20px\"},children:isDragging?\"Drop Image Here\":\"Upload Image\"}):enable3DDepth?/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",width:\"100%\",height:\"100%\",backgroundImage:`url(${image.src})`,backgroundSize:imageBackgroundSize,backgroundRepeat:\"no-repeat\",backgroundPosition:\"center\",transformStyle:\"preserve-3d\",transform:`translateZ(-${depthIntensity}px) scale(1.05)`,filter:\"blur(2px) brightness(0.8)\",opacity:.7}}),/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",width:\"100%\",height:\"100%\",backgroundImage:`url(${image.src})`,backgroundSize:imageBackgroundSize,backgroundRepeat:\"no-repeat\",backgroundPosition:\"center\",transformStyle:\"preserve-3d\",transform:`translateZ(${depthIntensity/2}px)`,overflow:\"hidden\"},role:\"img\",\"aria-label\":image.alt,children:enableShine&&/*#__PURE__*/_jsx(motion.div,{style:{position:\"absolute\",top:0,left:0,width:\"100%\",height:\"100%\",pointerEvents:\"none\",backgroundImage:shineGradient},animate:{opacity:isHovered?1:0},transition:{duration:.3}})})]}):/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",width:\"100%\",height:\"100%\",backgroundImage:`url(${image.src})`,backgroundSize:imageBackgroundSize,backgroundRepeat:\"no-repeat\",backgroundPosition:\"center\",transformStyle:\"preserve-3d\",overflow:\"hidden\"},role:\"img\",\"aria-label\":image.alt,children:enableShine&&/*#__PURE__*/_jsx(motion.div,{style:{position:\"absolute\",top:0,left:0,width:\"100%\",height:\"100%\",pointerEvents:\"none\",backgroundImage:shineGradient},animate:{opacity:isHovered?1:0},transition:{duration:.3}})})})});}addPropertyControls(TiltImage3D,{image:{type:ControlType.ResponsiveImage,title:\"Image\"},enable3DDepth:{type:ControlType.Boolean,title:\"3D Depth\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"},depthIntensity:{type:ControlType.Number,title:\"Depth Intensity\",defaultValue:30,min:0,max:100,step:1,unit:\"px\",hidden:({enable3DDepth})=>!enable3DDepth},imageFit:{type:ControlType.Enum,title:\"Image Fit\",defaultValue:\"cover\",options:[\"cover\",\"fill\"],optionTitles:[\"Cover\",\"Fill\"]},tiltX:{type:ControlType.Number,title:\"Vertical Tilt\",defaultValue:0,min:-45,max:45,step:1,unit:\"deg\"},tiltY:{type:ControlType.Number,title:\"Horizontal Tilt\",defaultValue:0,min:-45,max:45,step:1,unit:\"deg\"},rotationZ:{type:ControlType.Number,title:\"Rotation\",defaultValue:0,min:-180,max:180,step:1,unit:\"deg\"},tiltIntensity:{type:ControlType.Number,title:\"Tilt Intensity\",defaultValue:15,min:0,max:30,step:1,unit:\"deg\"},enableShine:{type:ControlType.Boolean,title:\"Shine Effect\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"},shineIntensity:{type:ControlType.Number,title:\"Shine Intensity\",defaultValue:.3,min:0,max:1,step:.1,hidden:({enableShine})=>!enableShine},innerPaddingX:{type:ControlType.Number,title:\"Padding X\",defaultValue:0,min:0,max:120,step:1,unit:\"px\"},innerPaddingY:{type:ControlType.Number,title:\"Padding Y\",defaultValue:0,min:0,max:120,step:1,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TiltImage3D\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"fixed\",\"framerIntrinsicHeight\":\"400\",\"framerSupportedLayoutHeight\":\"fixed\",\"framerIntrinsicWidth\":\"300\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Tilt_Image.map"],"mappings":"mRASG,SAAwB,EAAY,EAAM,CAAC,GAAK,CAAC,QAAM,gBAAc,GAAG,cAAY,GAAK,iBAAe,GAAG,gBAAc,GAAK,iBAAe,GAAG,QAAM,EAAE,QAAM,EAAE,YAAU,EAAE,gBAAc,EAAE,gBAAc,EAAE,WAAS,SAAS,EAAY,EAAQA,EAAO,KAAK,CAAM,CAAC,EAAU,GAAcC,EAAS,GAAM,CAAM,CAAC,EAAW,GAAeA,EAAS,GAAM,CAAO,EAAQ,EAAe,EAAM,CAAO,EAAQ,EAAe,EAAM,CAAO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