{"version":3,"file":"Examples.PcwqFjNk.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/zs8sr5g8Fwes55hI5s7o/aPcTyxwSPhbEv2shrT61/Examples.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{motion,useSpring}from\"framer-motion\";import{useState,useRef,useEffect}from\"react\";// Learn more: https://www.framer.com/docs/guides/overrides/\n//Spring animation parameters\nconst spring={type:\"spring\",stiffness:300,damping:40};/**\n * 3D Flip\n * Created By Joshua Guo, Adapted by Ethan Wang\n *\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n */export function withHover(Component){return props=>{const[isFlipped,setIsFlipped]=useState(false);const handleMouseEnter=()=>{setIsFlipped(true);};const handleMouseLeave=()=>{setIsFlipped(false);};const[rotateXaxis,setRotateXaxis]=useState(0);const[rotateYaxis,setRotateYaxis]=useState(0);const ref=useRef(null);const handleMouseMove=event=>{const element=ref.current;const elementRect=element.getBoundingClientRect();const elementWidth=elementRect.width;const elementHeight=elementRect.height;const elementCenterX=elementWidth/2;const elementCenterY=elementHeight/2;const mouseX=event.clientY-elementRect.y-elementCenterY;const mouseY=event.clientX-elementRect.x-elementCenterX;const degreeX=mouseX/elementWidth*20//The number is the rotation factor\n;const degreeY=mouseY/elementHeight*20//The number is the rotation factor\n;setRotateXaxis(degreeX);setRotateYaxis(degreeY);};const handleMouseEnd=()=>{setRotateXaxis(0);setRotateYaxis(0);};const dx=useSpring(0,spring);const dy=useSpring(0,spring);useEffect(()=>{dx.set(-rotateXaxis);dy.set(rotateYaxis);},[rotateXaxis,rotateYaxis]);return /*#__PURE__*/_jsx(motion.div,{onMouseEnter:handleMouseEnter,onMouseLeave:handleMouseLeave,style:{perspective:\"1200px\",transformStyle:\"preserve-3d\",width:`${props.width}`,height:`${props.height}`},children:/*#__PURE__*/_jsx(motion.div,{ref:ref,whileHover:{scale:1.2},onMouseMove:handleMouseMove,onMouseLeave:handleMouseEnd,transition:spring,style:{width:\"100%\",height:\"100%\",rotateX:dx,rotateY:dy},children:/*#__PURE__*/_jsxs(\"div\",{style:{perspective:\"1200px\",transformStyle:\"preserve-3d\",width:\"100%\",height:\"100%\"},children:[/*#__PURE__*/_jsx(motion.div,{animate:{rotateY:isFlipped?-180:0},transition:spring,style:{width:\"100%\",height:\"100%\",zIndex:isFlipped?0:1,backfaceVisibility:\"hidden\",position:\"absolute\"},children:/*#__PURE__*/_jsx(Component,{...props,variant:\"Front\",style:{width:\"100%\",height:\"100%\"}})}),/*#__PURE__*/_jsx(motion.div,{initial:{rotateY:180},animate:{rotateY:isFlipped?0:180},transition:spring,style:{width:\"100%\",height:\"100%\",zIndex:isFlipped?1:0,backfaceVisibility:\"hidden\",position:\"absolute\"},children:/*#__PURE__*/_jsx(Component,{...props,variant:\"Back\",style:{width:\"100%\",height:\"100%\"}})})]})})});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withHover\":{\"type\":\"reactHoc\",\"name\":\"withHover\",\"annotations\":{\"framerSupportedLayoutWidth\":\"fixed\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Examples.map"],"mappings":"0LAQG,SAAgB,EAAU,EAAU,CAAC,MAAO,IAAO,CAAC,GAAK,CAAC,EAAU,GAAcA,EAAS,GAAM,CAAO,MAAqB,CAAC,EAAa,GAAK,EAAS,MAAqB,CAAC,EAAa,GAAM,EAAQ,CAAC,EAAY,GAAgBA,EAAS,EAAE,CAAM,CAAC,EAAY,GAAgBA,EAAS,EAAE,CAAO,EAAIC,EAAO,KAAK,CAAO,EAAgB,GAAO,CAA2B,IAAM,EAAlB,EAAI,QAAkC,uBAAuB,CAAO,EAAa,EAAY,MAAY,EAAc,EAAY,OAAa,EAAe,EAAa,EAAQ,EAAe,EAAc,EAAQ,EAAO,EAAM,QAAQ,EAAY,EAAE,EAAqB,EAAO,EAAM,QAAQ,EAAY,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