{"version":3,"file":"TextExplosion.BSGk5IXK.mjs","names":["useState","useMemo"],"sources":["https:/framerusercontent.com/modules/AiH9isu9NZtz97I7cOwg/ZFVo2zBRXC6cf6pJ2dTO/TextExplosion.js"],"sourcesContent":["// Piece by Piece text animation with exploding and reforming letters\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{motion,useAnimation}from\"framer-motion\";import{useEffect,useState,useMemo}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";/**\n * Piece by Piece Text Animation\n * \n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function TextExplosion(props){const{text=\"EXPLODE\",font,textColor,animationDuration,staggerDelay,explosionRadius,loop,enableHover,enableClick,style}=props;const[isExploded,setIsExploded]=useState(false);const[isHovered,setIsHovered]=useState(false);const[isClicked,setIsClicked]=useState(false);const controls=useAnimation();const isStatic=useIsStaticRenderer();// Check if component is in responsive mode\nconst isResponsive=style?.width===\"100%\"||style?.height===\"100%\";// Generate random positions for each letter\nconst letterPositions=useMemo(()=>{return text.split(\"\").map(()=>({x:(Math.random()-.5)*explosionRadius*2,y:(Math.random()-.5)*explosionRadius*2,rotate:(Math.random()-.5)*360}));},[text,explosionRadius]);const containerVariants={exploded:{transition:{staggerChildren:staggerDelay,delayChildren:0}},reformed:{transition:{staggerChildren:staggerDelay,delayChildren:0}}};const letterVariants={exploded:i=>({x:letterPositions[i]?.x||0,y:letterPositions[i]?.y||0,rotate:letterPositions[i]?.rotate||0,opacity:.3,scale:.8,transition:{duration:animationDuration,ease:\"easeOut\"}}),reformed:{x:0,y:0,rotate:0,opacity:1,scale:1,transition:{duration:animationDuration,ease:\"easeInOut\"}}};useEffect(()=>{if(isStatic)return;// If hover or click interactions are enabled, don't auto-animate\nif(enableHover||enableClick){// Trigger explosion based on hover or click state\nif(isHovered||isClicked){setIsExploded(true);controls.start(\"exploded\");}else{setIsExploded(false);controls.start(\"reformed\");}return;}// Original loop animation logic\nconst animateSequence=async()=>{// Start with reformed state\nawait controls.start(\"reformed\");await new Promise(resolve=>setTimeout(resolve,1e3));// Explode\nsetIsExploded(true);await controls.start(\"exploded\");await new Promise(resolve=>setTimeout(resolve,800));// Reform\nsetIsExploded(false);await controls.start(\"reformed\");await new Promise(resolve=>setTimeout(resolve,1200));};const runAnimation=()=>{animateSequence().then(()=>{// Continue the loop only if loop is enabled\nif(loop){setTimeout(runAnimation,100);}});};runAnimation();},[controls,animationDuration,isStatic,loop,enableHover,enableClick,isHovered,isClicked]);if(isStatic){return /*#__PURE__*/_jsx(\"div\",{style:{display:\"flex\",justifyContent:\"center\",alignItems:\"center\",width:isResponsive?\"100%\":\"max-content\",height:isResponsive?\"100%\":\"auto\",...style,...font,color:textColor,letterSpacing:\"0.1em\"},children:text.split(\"\").map((letter,index)=>/*#__PURE__*/_jsx(\"span\",{style:{display:\"inline-block\",marginRight:letter===\" \"?\"0.5em\":\"0.05em\"},children:letter===\" \"?\"\\xa0\":letter},index))});}return /*#__PURE__*/_jsx(motion.div,{variants:containerVariants,animate:controls,initial:\"reformed\",onMouseEnter:()=>enableHover&&setIsHovered(true),onMouseLeave:()=>enableHover&&setIsHovered(false),onClick:()=>{if(enableClick){setIsClicked(!isClicked);}},style:{display:\"flex\",justifyContent:\"center\",alignItems:\"center\",width:isResponsive?\"100%\":\"max-content\",height:isResponsive?\"100%\":\"auto\",cursor:enableHover||enableClick?\"pointer\":\"default\",...style,...font,color:textColor,letterSpacing:\"0.1em\"},children:text.split(\"\").map((letter,index)=>/*#__PURE__*/_jsx(motion.span,{custom:index,variants:letterVariants,style:{display:\"inline-block\",marginRight:letter===\" \"?\"0.5em\":\"0.05em\",transformOrigin:\"center\"},children:letter===\" \"?\"\\xa0\":letter},index))});}addPropertyControls(TextExplosion,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"EXPLODE\"},font:{type:ControlType.Font,title:\"Font\",defaultValue:{fontSize:\"48px\",variant:\"Bold\",letterSpacing:\"0.1em\",lineHeight:\"1em\"},controls:\"extended\",defaultFontType:\"sans-serif\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},loop:{type:ControlType.Boolean,title:\"Loop Animation\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"},enableHover:{type:ControlType.Boolean,title:\"Hover Interaction\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},enableClick:{type:ControlType.Boolean,title:\"Click Interaction\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},animationDuration:{type:ControlType.Number,title:\"Animation Duration\",defaultValue:.8,min:.2,max:3,step:.1,unit:\"s\"},staggerDelay:{type:ControlType.Number,title:\"Stagger Delay\",defaultValue:.05,min:0,max:.2,step:.01,unit:\"s\"},explosionRadius:{type:ControlType.Number,title:\"Explosion Radius\",defaultValue:100,min:50,max:300,step:10,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TextExplosion\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TextExplosion.map"],"mappings":"wPAMG,SAAwB,EAAc,EAAM,CAAC,GAAK,CAAC,OAAK,UAAU,OAAK,YAAU,oBAAkB,eAAa,kBAAgB,OAAK,cAAY,cAAY,SAAO,EAAW,CAAC,EAAW,GAAeA,EAAS,GAAM,CAAM,CAAC,EAAU,GAAcA,EAAS,GAAM,CAAM,CAAC,EAAU,GAAcA,EAAS,GAAM,CAAO,EAAS,GAAc,CAAO,EAAS,GAAqB,CACrX,EAAa,GAAO,QAAQ,QAAQ,GAAO,SAAS,OACpD,EAAgBC,MAAoB,EAAK,MAAM,GAAG,CAAC,SAAS,CAAC,GAAG,KAAK,QAAQ,CAAC,IAAI,EAAgB,EAAE,GAAG,KAAK,QAAQ,CAAC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