{"version":3,"file":"Mouse_Draw.CFhQWdCV.mjs","names":["useRef","p"],"sources":["https:/framerusercontent.com/modules/rzpRflHXnEgXQ69JcDww/FFruVFco24XuNBscaWwT/Mouse_Draw.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef}from\"react\";import{addPropertyControls,ControlType}from\"framer\";export default function OrangeTrail(props){const{color,glowColor,lineWidth,fadeDuration,glowBlur}=props;const canvasRef=useRef(null);const pointsRef=useRef([]);const isDrawingRef=useRef(false);const rafRef=useRef();useEffect(()=>{const canvas=canvasRef.current;if(!canvas)return;const ctx=canvas.getContext(\"2d\");if(!ctx)return;const resize=()=>{const dpr=window.devicePixelRatio||1;canvas.width=window.innerWidth*dpr;canvas.height=window.innerHeight*dpr;canvas.style.width=window.innerWidth+\"px\";canvas.style.height=window.innerHeight+\"px\";ctx.setTransform(dpr,0,0,dpr,0,0);};resize();window.addEventListener(\"resize\",resize);// --- Suppress native text/element selection while drawing ---\nconst disableSelection=()=>{document.body.style.userSelect=\"none\";document.body.style.webkitUserSelect=\"none\";document.body.style.msUserSelect=\"none\";};const restoreSelection=()=>{document.body.style.userSelect=\"\";document.body.style.webkitUserSelect=\"\";document.body.style.msUserSelect=\"\";};const MOVE_THRESHOLD=4// px of movement required before drawing starts\n;let mouseIsDown=false;let downX=0;let downY=0;const handlePointerDown=e=>{mouseIsDown=true;isDrawingRef.current=false// not drawing yet — wait for movement\n;downX=e.clientX;downY=e.clientY;};const handlePointerMove=e=>{if(!mouseIsDown)return;if(!isDrawingRef.current){// Check if the mouse has moved enough since mousedown to\n// count as an actual drag, not just a click\nconst dx=e.clientX-downX;const dy=e.clientY-downY;if(Math.hypot(dx,dy)<MOVE_THRESHOLD)return;// Movement confirmed — start drawing, seed the line from\n// the original mousedown point so there's no visual gap\nisDrawingRef.current=true;disableSelection();pointsRef.current.push({x:downX,y:downY,createdAt:performance.now()});}// Prevent the browser's native drag-select from ever starting\ne.preventDefault();pointsRef.current.push({x:e.clientX,y:e.clientY,createdAt:performance.now()});};const handlePointerUp=()=>{mouseIsDown=false;isDrawingRef.current=false;restoreSelection();};// Also kill the browser's native \"selectstart\" event outright\nconst handleSelectStart=e=>{if(isDrawingRef.current)e.preventDefault();};window.addEventListener(\"pointerdown\",handlePointerDown);window.addEventListener(\"pointermove\",handlePointerMove,{passive:false});window.addEventListener(\"pointerup\",handlePointerUp);window.addEventListener(\"pointercancel\",handlePointerUp);document.addEventListener(\"selectstart\",handleSelectStart);const draw=()=>{const now=performance.now();// Drop points that have fully faded out\npointsRef.current=pointsRef.current.filter(p=>now-p.createdAt<fadeDuration);ctx.clearRect(0,0,window.innerWidth,window.innerHeight);const pts=pointsRef.current;if(pts.length>1){ctx.lineCap=\"round\";ctx.lineJoin=\"round\";ctx.shadowColor=glowColor;ctx.shadowBlur=glowBlur;ctx.strokeStyle=color;ctx.lineWidth=lineWidth;// Split into continuous runs (a \"run\" breaks when there's a\n// large time gap, e.g. mouse lifted and pressed elsewhere)\nlet runStart=0;for(let i=1;i<=pts.length;i++){const brokenHere=i===pts.length||pts[i].createdAt-pts[i-1].createdAt>200;if(brokenHere){const run=pts.slice(runStart,i);if(run.length>1){// Use the newest point in the run to drive the\n// fade so the whole visible run reads as one\n// solid line, getting fainter as it ages.\nconst age=now-run[run.length-1].createdAt;const lifeRatio=Math.max(0,1-age/fadeDuration);if(lifeRatio>0){ctx.globalAlpha=lifeRatio;ctx.beginPath();ctx.moveTo(run[0].x,run[0].y);for(let j=1;j<run.length;j++){ctx.lineTo(run[j].x,run[j].y);}ctx.stroke();}}runStart=i;}}ctx.globalAlpha=1;ctx.shadowBlur=0;}rafRef.current=requestAnimationFrame(draw);};rafRef.current=requestAnimationFrame(draw);return()=>{window.removeEventListener(\"resize\",resize);window.removeEventListener(\"pointerdown\",handlePointerDown);window.removeEventListener(\"pointermove\",handlePointerMove);window.removeEventListener(\"pointerup\",handlePointerUp);window.removeEventListener(\"pointercancel\",handlePointerUp);document.removeEventListener(\"selectstart\",handleSelectStart);restoreSelection();if(rafRef.current)cancelAnimationFrame(rafRef.current);};},[color,glowColor,lineWidth,fadeDuration,glowBlur]);return /*#__PURE__*/_jsx(\"div\",{style:{position:\"fixed\",top:0,left:0,width:\"100vw\",height:\"100vh\",pointerEvents:\"none\",zIndex:2147483647},children:/*#__PURE__*/_jsx(\"canvas\",{ref:canvasRef,style:{position:\"fixed\",top:0,left:0,width:\"100vw\",height:\"100vh\",pointerEvents:\"none\"}})});}addPropertyControls(OrangeTrail,{color:{type:ControlType.Color,title:\"Line Color\",defaultValue:\"#FF6A00\"},glowColor:{type:ControlType.Color,title:\"Glow Color\",defaultValue:\"#FF8C1A\"},lineWidth:{type:ControlType.Number,title:\"Line Width\",defaultValue:5,min:1,max:30,step:1},glowBlur:{type:ControlType.Number,title:\"Glow Blur\",defaultValue:16,min:0,max:60,step:1},fadeDuration:{type:ControlType.Number,title:\"Fade Duration (ms)\",defaultValue:1200,min:200,max:5e3,step:100}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"OrangeTrail\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Mouse_Draw.map"],"mappings":"+LAAmI,SAAwB,EAAY,EAAM,CAAC,GAAK,CAAC,QAAM,YAAU,YAAU,eAAa,YAAU,EAAY,EAAUA,EAAO,KAAK,CAAO,EAAUA,EAAO,EAAE,CAAC,CAAO,EAAaA,EAAO,GAAM,CAAO,EAAOA,GAAQ,CAe+gB,OAf9gB,MAAc,CAAC,IAAM,EAAO,EAAU,QAAQ,GAAG,CAAC,EAAO,OAAO,IAAM,EAAI,EAAO,WAAW,KAAK,CAAC,GAAG,CAAC,EAAI,OAAO,IAAM,MAAW,CAAC,IAAM,EAAI,EAAO,kBAAkB,EAAE,EAAO,MAAM,EAAO,WAAW,EAAI,EAAO,OAAO,EAAO,YAAY,EAAI,EAAO,MAAM,MA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