{"version":3,"file":"ClipPathReveal.DdnrpyTP.mjs","names":["React.useRef","React.useState","React.useMemo","React.useCallback","p"],"sources":["https:/framerusercontent.com/modules/UmxlCFwag9XwlsEYBjbo/C4XmUiEXRZ5NQNfQwvMB/ClipPathReveal.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";import{motion}from\"framer-motion\";/**\n * Instructions:\n * Create a Framer component that follows the Framer component rules and achieves the user's goal.\n * Goal:\n * Build a fully customizable Clip-Path Image Reveal Component for Framer using CSS clip-path and Framer Motion.\n * This component should allow users to create content swap / image reveal animations where images are revealed by animating the clip-path from a specified direction.\n * Component Name: ClipPath Reveal\n * Core Functionality:\n * Create a component that reveals an image by animating its CSS clip-path from hidden to fully visible.\n * The component must support:\n * Reveal on scroll into view\n * Reveal on appear\n * Reveal on hover (optional toggle)\n *//**\n * @framerIntrinsicWidth 600\n * @framerIntrinsicHeight 400\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function ClipPathReveal(props){const{image={src:\"https://framerusercontent.com/images/f9RiWoNpmlCMqVRIHz8l8wYfeI.jpg\",alt:\"Gradient 5 - Green\"},direction,trigger,revealOnHover,hoverBehavior,scrollOnce,inViewAmount,transition,delay,borderRadius,backgroundColor,objectFit,staticPreview,style}=props;const isStatic=useIsStaticRenderer();const ref=React.useRef(null);const[inView,setInView]=React.useState(false);const[revealed,setRevealed]=React.useState(false);const[hovered,setHovered]=React.useState(false);// Replace framer-motion's useInView with an SSR-safe IntersectionObserver.\nReact.useEffect(()=>{if(isStatic)return;if(typeof window===\"undefined\")return;if(revealOnHover)return;if(trigger!==\"scroll\")return;const node=ref.current;if(!node)return;const amount=Math.max(0,Math.min(1,inViewAmount));let raf=0;const observer=new IntersectionObserver(entries=>{const entry=entries[0];// Throttle state updates slightly to avoid noisy observers in Canvas.\nif(raf)cancelAnimationFrame(raf);raf=requestAnimationFrame(()=>{React.startTransition(()=>setInView(!!entry?.isIntersecting&&entry.intersectionRatio>=amount));});},{threshold:[amount]});observer.observe(node);return()=>{if(raf)cancelAnimationFrame(raf);observer.disconnect();};},[isStatic,revealOnHover,trigger,inViewAmount]);const hiddenClipPath=React.useMemo(()=>{switch(direction){case\"left\":return\"inset(0 100% 0 0)\";case\"right\":return\"inset(0 0 0 100%)\";case\"top\":return\"inset(100% 0 0 0)\";case\"bottom\":return\"inset(0 0 100% 0)\";case\"center\":return\"inset(50% 50% 50% 50%)\";default:return\"inset(0 100% 0 0)\";}},[direction]);React.useEffect(()=>{if(isStatic)return;if(revealOnHover)return;if(trigger===\"appear\"){React.startTransition(()=>setRevealed(true));}},[isStatic,revealOnHover,trigger]);React.useEffect(()=>{if(isStatic)return;if(revealOnHover)return;if(trigger!==\"scroll\")return;if(inView){React.startTransition(()=>setRevealed(true));}else if(!scrollOnce){React.startTransition(()=>setRevealed(false));}},[isStatic,revealOnHover,trigger,inView,scrollOnce]);const isRevealed=React.useMemo(()=>{if(isStatic)return staticPreview===\"revealed\";if(revealOnHover){if(hoverBehavior===\"reveal-stay\")return hovered||revealed;return hovered;}return revealed;},[isStatic,staticPreview,revealOnHover,hoverBehavior,hovered,revealed]);const resolvedTransition=React.useMemo(()=>{const t=transition??{};const d=typeof delay===\"number\"?Math.max(0,delay):0;return{...t,delay:(t?.delay??0)+d};},[transition,delay]);const onMouseEnter=React.useCallback(()=>{if(!revealOnHover||isStatic)return;React.startTransition(()=>{setHovered(true);if(hoverBehavior===\"reveal-stay\")setRevealed(true);});},[revealOnHover,hoverBehavior,isStatic]);const onMouseLeave=React.useCallback(()=>{if(!revealOnHover||isStatic)return;React.startTransition(()=>{setHovered(false);});},[revealOnHover,isStatic]);return /*#__PURE__*/_jsx(\"div\",{ref:ref,style:{position:\"relative\",width:\"100%\",height:\"100%\",overflow:\"hidden\",borderRadius,backgroundColor,...style},onMouseEnter:onMouseEnter,onMouseLeave:onMouseLeave,\"aria-label\":image?.alt||\"Revealed image\",role:\"img\",children:/*#__PURE__*/_jsx(motion.img,{src:image?.src,srcSet:image?.srcSet,alt:image?.alt??\"\",style:{position:\"absolute\",inset:0,width:\"100%\",height:\"100%\",objectFit,display:\"block\",clipPath:isRevealed?\"inset(0 0 0 0)\":hiddenClipPath,willChange:isStatic?undefined:\"clip-path\",transform:\"translateZ(0)\"},animate:isStatic?undefined:{clipPath:isRevealed?\"inset(0 0 0 0)\":hiddenClipPath},transition:isStatic?undefined:resolvedTransition,draggable:false})});}addPropertyControls(ClipPathReveal,{image:{type:ControlType.ResponsiveImage,title:\"Image\"},direction:{type:ControlType.Enum,title:\"Direction\",options:[\"left\",\"right\",\"top\",\"bottom\",\"center\"],optionTitles:[\"Left\",\"Right\",\"Top\",\"Bottom\",\"Center\"],defaultValue:\"left\",displaySegmentedControl:true},trigger:{type:ControlType.Enum,title:\"Trigger\",options:[\"scroll\",\"appear\"],optionTitles:[\"Scroll Into View\",\"On Appear\"],defaultValue:\"scroll\",displaySegmentedControl:true,hidden:p=>!!p.revealOnHover},revealOnHover:{type:ControlType.Boolean,title:\"Hover Reveal\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},hoverBehavior:{type:ControlType.Enum,title:\"Hover Mode\",options:[\"reveal-hide\",\"reveal-stay\"],optionTitles:[\"Reveal / Hide\",\"Reveal / Stay\"],defaultValue:\"reveal-hide\",displaySegmentedControl:true,hidden:p=>!p.revealOnHover},scrollOnce:{type:ControlType.Boolean,title:\"Scroll Once\",defaultValue:true,enabledTitle:\"Once\",disabledTitle:\"Repeat\",hidden:p=>p.revealOnHover||p.trigger!==\"scroll\"},inViewAmount:{type:ControlType.Number,title:\"In View\",defaultValue:.35,min:0,max:1,step:.05,hidden:p=>p.revealOnHover||p.trigger!==\"scroll\"},transition:{type:ControlType.Transition,title:\"Transition\",defaultValue:{type:\"tween\",duration:.8,ease:[.22,1,.36,1]}},delay:{type:ControlType.Number,title:\"Delay\",defaultValue:0,min:0,max:3,step:.05,unit:\"s\"},objectFit:{type:ControlType.Enum,title:\"Fit\",options:[\"cover\",\"contain\"],optionTitles:[\"Cover\",\"Contain\"],defaultValue:\"cover\",displaySegmentedControl:true},borderRadius:{type:ControlType.BorderRadius,title:\"Radius\",defaultValue:\"0px\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#FFFFFF\"},staticPreview:{type:ControlType.Enum,title:\"Canvas Preview\",options:[\"revealed\",\"hidden\"],optionTitles:[\"Revealed\",\"Hidden\"],defaultValue:\"revealed\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ClipPathReveal\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerIntrinsicHeight\":\"400\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerIntrinsicWidth\":\"600\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ClipPathReveal.map"],"mappings":"oRAmBG,SAAwB,EAAe,EAAM,CAAC,GAAK,CAAC,QAAM,CAAC,IAAI,sEAAsE,IAAI,qBAAqB,CAAC,YAAU,UAAQ,gBAAc,gBAAc,aAAW,eAAa,aAAW,QAAM,eAAa,kBAAgB,YAAU,gBAAc,SAAO,EAAY,EAAS,GAAqB,CAAO,EAAIA,EAAa,KAAK,CAAM,CAAC,EAAO,GAAWC,EAAe,GAAM,CAAM,CAAC,EAAS,GAAaA,EAAe,GAAM,CAAM,CAAC,EAAQ,GAAYA,EAAe,GAAM,CAC5gB,MAAoB,CAAkF,GAA9E,GAA0B,IAAS,QAAsB,GAAwB,IAAU,SAAS,OAAO,IAAM,EAAK,EAAI,QAAQ,GAAG,CAAC,EAAK,OAAO,IAAM,EAAO,KAAK,IAAI,EAAE,KAAK,IAAI,EAAE,EAAa,CAAC,CAAK,EAAI,EAAQ,EAAS,IAAI,qBAAqB,GAAS,CAAC,IAA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