{"version":3,"file":"DrawingBuiltSlider.TG2IFfv4.mjs","names":["useRef","useState","startTransition"],"sources":["https:/framerusercontent.com/modules/8Ss5hQtSsdlmh3uJ5DCY/GpKSJmqv4m1SZ6sOsXu9/DrawingBuiltSlider.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useRef,useState,startTransition}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";import{animate,useInView,useReducedMotion}from\"framer-motion\";/**\n * Drawing / Built Slider\n * Compare a drawing with the finished space. Drag, tap or use the arrow keys.\n *\n * @framerIntrinsicWidth 900\n * @framerIntrinsicHeight 560\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n * @framerDisableUnlink\n */export default function DrawingBuiltSlider(props){const placeholder=\"https://framerusercontent.com/images/GfGkADagM4KEibNcIiRUWlfrR0.jpg\";const{drawing={src:placeholder,alt:\"Section drawing of the living room\"},built={src:placeholder,alt:\"The finished living room\"},drawingLabel=\"Drawing\",builtLabel=\"Built\",start=50,introSweep=true,lineColor=\"#E2522B\",handleColor=\"#E2522B\",handleTextColor=\"#FFFFFF\",labelColor=\"#FFFFFF\",labelFont}=props;const ref=useRef(null);const[pos,setPos]=useState(start);const[dragging,setDragging]=useState(false);const isStatic=useIsStaticRenderer();const reduce=useReducedMotion();const inView=useInView(ref,{once:true,amount:.5});const touched=useRef(false);useEffect(()=>{if(isStatic||reduce||!introSweep||!inView||touched.current)return;const controls=animate(start,[start,18,start],{duration:2.2,ease:[.65,0,.35,1],onUpdate:v=>{if(!touched.current)setPos(v);}});return()=>controls.stop();},[inView,isStatic,reduce,introSweep,start]);const setFromClientX=clientX=>{const el=ref.current;if(!el)return;const r=el.getBoundingClientRect();const p=Math.max(0,Math.min(100,(clientX-r.left)/r.width*100));startTransition(()=>setPos(p));};useEffect(()=>{if(!dragging||isStatic)return;const move=e=>setFromClientX(e.clientX);const up=()=>startTransition(()=>setDragging(false));window.addEventListener(\"pointermove\",move);window.addEventListener(\"pointerup\",up);return()=>{window.removeEventListener(\"pointermove\",move);window.removeEventListener(\"pointerup\",up);};},[dragging,isStatic]);const onPointerDown=e=>{if(isStatic)return;touched.current=true;setFromClientX(e.clientX);startTransition(()=>setDragging(true));};const onKeyDown=e=>{if(e.key===\"ArrowLeft\"||e.key===\"ArrowRight\"){e.preventDefault();touched.current=true;const d=e.key===\"ArrowLeft\"?-5:5;startTransition(()=>setPos(p=>Math.max(0,Math.min(100,p+d))));}};const img={position:\"absolute\",inset:0,width:\"100%\",height:\"100%\",objectFit:\"cover\",display:\"block\",pointerEvents:\"none\",userSelect:\"none\"};const label={position:\"absolute\",top:20,color:labelColor,fontFamily:'\"Switzer\", \"Switzer Placeholder\", sans-serif',fontSize:13,lineHeight:1.35,pointerEvents:\"none\",...labelFont};return /*#__PURE__*/_jsxs(\"div\",{ref:ref,role:\"slider\",tabIndex:0,\"aria-label\":`${drawingLabel} and ${builtLabel} comparison`,\"aria-valuemin\":0,\"aria-valuemax\":100,\"aria-valuenow\":Math.round(pos),onPointerDown:onPointerDown,onKeyDown:onKeyDown,style:{position:\"relative\",width:\"100%\",height:\"100%\",overflow:\"hidden\",cursor:dragging?\"grabbing\":\"ew-resize\",touchAction:\"pan-y\",outline:\"none\"},children:[/*#__PURE__*/_jsx(\"img\",{src:built.src,srcSet:built.srcSet,alt:built.alt||\"\",style:img,draggable:false}),/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",inset:0,clipPath:`inset(0 ${100-pos}% 0 0)`},children:/*#__PURE__*/_jsx(\"img\",{src:drawing.src,srcSet:drawing.srcSet,alt:drawing.alt||\"\",style:img,draggable:false})}),/*#__PURE__*/_jsx(\"span\",{style:{...label,left:20},children:drawingLabel}),/*#__PURE__*/_jsx(\"span\",{style:{...label,right:20},children:builtLabel}),/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",top:0,bottom:0,left:`${pos}%`,width:1,background:lineColor,transform:\"translateX(-0.5px)\",pointerEvents:\"none\"}}),/*#__PURE__*/_jsx(\"div\",{\"aria-hidden\":\"true\",style:{position:\"absolute\",top:\"50%\",left:`${pos}%`,width:56,height:56,borderRadius:56,background:handleColor,color:handleTextColor,transform:\"translate(-50%, -50%)\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",pointerEvents:\"none\"},children:/*#__PURE__*/_jsx(\"svg\",{width:\"22\",height:\"12\",viewBox:\"0 0 22 12\",fill:\"none\",stroke:\"currentColor\",strokeWidth:\"1.5\",children:/*#__PURE__*/_jsx(\"path\",{d:\"M6 1 1 6l5 5M16 1l5 5-5 5M1 6h20\"})})})]});}addPropertyControls(DrawingBuiltSlider,{drawing:{type:ControlType.ResponsiveImage,title:\"Drawing\"},built:{type:ControlType.ResponsiveImage,title:\"Built\"},drawingLabel:{type:ControlType.String,title:\"Left Label\",defaultValue:\"Drawing\"},builtLabel:{type:ControlType.String,title:\"Right Label\",defaultValue:\"Built\"},start:{type:ControlType.Number,title:\"Start\",defaultValue:50,min:0,max:100,unit:\"%\"},introSweep:{type:ControlType.Boolean,title:\"Intro Sweep\",defaultValue:true},lineColor:{type:ControlType.Color,title:\"Line\",defaultValue:\"#E2522B\"},handleColor:{type:ControlType.Color,title:\"Handle\",defaultValue:\"#E2522B\"},handleTextColor:{type:ControlType.Color,title:\"Handle Icon\",defaultValue:\"#FFFFFF\"},labelColor:{type:ControlType.Color,title:\"Labels\",defaultValue:\"#FFFFFF\"},labelFont:{type:ControlType.Font,title:\"Label Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"13px\",lineHeight:\"1.35em\"}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"DrawingBuiltSlider\",\"slots\":[],\"annotations\":{\"framerIntrinsicHeight\":\"560\",\"framerContractVersion\":\"1\",\"framerDisableUnlink\":\"\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerIntrinsicWidth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