{"version":3,"file":"ImageCompareSlider.CxTP2OhD.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/xiE1JprCSoo9ClaIaiuY/NdQg11qq2vDLdJeN6Lc3/ImageCompareSlider.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,useEffect,useRef}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * https://www.framer.com/developers/#code-components-auto-sizing\n *\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n */export default function ImageCompareSlider(props){const[sliderValue,setSliderValue]=useState(50);const videoRef1=useRef(null);const videoRef2=useRef(null);useEffect(()=>{setTimeout(()=>{if(videoRef1.current&&videoRef2.current){const video1Promise=new Promise(resolve=>{if(videoRef1.current.readyState>=4){resolve();}else{videoRef1.current.addEventListener(\"canplaythrough\",resolve);}});const video2Promise=new Promise(resolve=>{if(videoRef2.current.readyState>=4){resolve();}else{videoRef2.current.addEventListener(\"canplaythrough\",resolve);}});Promise.all([video1Promise,video2Promise]).then(()=>{videoRef1.current.play();videoRef2.current.play();});}},300);},[]);useEffect(()=>{const style=document.createElement(\"style\");style.innerHTML=`\n            .slider::-webkit-slider-runnable-track {\n                height: 100%;\n                background: transparent;\n            }\n            .slider::-webkit-slider-thumb {\n                -webkit-appearance: none;\n                width: 3px;\n                height: 100%;\n                background: white;\n                border: 0;\n                cursor: pointer;\n            }\n            .slider::-moz-range-thumb {\n                width: 3px;\n                height: 100%;\n                background: white;\n                border: 0;\n                cursor: pointer;\n            }\n        `;document.head.appendChild(style);return()=>{document.head.removeChild(style);};},[]);const imgStyle={position:\"absolute\",top:0,left:0,bottom:0,right:0,backgroundRepeat:\"no-repeat\"};const imgFit=props.size===\"cover\"?{backgroundSize:\"cover\",backgroundPosition:\"center\"}:props.size===\"contain\"?{backgroundSize:\"contain\",backgroundPosition:\"center\"}:{};const renderMedia=(url,imageNum)=>{const isVideo=/\\.(mp4|webm)$/i.test(url);if(isVideo){return /*#__PURE__*/_jsx(\"video\",{ref:imageNum===1?videoRef1:videoRef2,style:{...imgStyle,...imgFit,objectFit:props.size,width:\"100%\",height:\"100%\"},preload:\"auto\",loop:true,muted:true,disablePictureInPicture:true,children:/*#__PURE__*/_jsx(\"source\",{src:url,type:\"video/mp4\"})});}else{return /*#__PURE__*/_jsx(\"div\",{style:{...imgStyle,...imgFit,backgroundImage:`url(${url})`}});}};return /*#__PURE__*/_jsxs(\"div\",{style:{position:\"relative\",width:\"100%\",height:\"100%\"},children:[renderMedia(props.video1??props.image1,1),/*#__PURE__*/_jsx(\"div\",{style:{...imgStyle,clipPath:`polygon(0% 0%, ${sliderValue}% 0%, ${sliderValue}% 100%, 0% 100%)`,overflow:\"hidden\"},children:renderMedia(props.video2??props.image2,2)}),/*#__PURE__*/_jsx(\"input\",{type:\"range\",className:\"slider\",min:\"1\",max:\"1000\",defaultValue:sliderValue*10,onChange:e=>setSliderValue(Number(e.target.value)/10),onWheel:e=>e.preventDefault(),onMouseUp:e=>document.activeElement.blur?.(),style:{position:\"absolute\",appearance:\"none\",width:\"100%\",height:\"100%\",background:\"transparent\",outline:\"none\",margin:0,WebkitMaskImage:`radial-gradient(circle at ${sliderValue}% 50%, transparent 30px, black 30.5px)`,maskImage:`radial-gradient(circle at ${sliderValue}% 50%, transparent 30px, black 30.5px)`}}),/*#__PURE__*/_jsxs(\"div\",{className:\"arrows\",style:{display:\"flex\",justifyContent:\"center\",alignItems:\"center\",pointerEvents:\"none\",position:\"absolute\",width:\"60px\",height:\"60px\",borderRadius:\"50%\",border:\"3px solid white\",left:`calc(${sliderValue}% - 30px)`,top:\"calc(50% - 30px)\"},children:[/*#__PURE__*/_jsx(\"div\",{style:{padding:5,display:\"inline-block\",border:\"solid white\",borderWidth:\"0 3px 3px 0\",transform:\"rotate(135deg)\"}}),/*#__PURE__*/_jsx(\"div\",{style:{padding:5,display:\"inline-block\",border:\"solid white\",borderWidth:\"0 3px 3px 0\",transform:\"translateX(-1px) rotate(-45deg)\"}})]}),/*#__PURE__*/_jsxs(\"div\",{className:\"bottomTexts\",style:{position:\"absolute\",left:0,right:0,bottom:0,padding:props.padding,pointerEvents:\"none\"},children:[/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",justifyContent:\"space-between\",marginBottom:8,fontFamily:props.textStyle1.fontFamily,fontSize:props.textStyle1.fontSize,fontWeight:props.textStyle1.fontWeight,color:props.textStyle1.color},children:[/*#__PURE__*/_jsx(\"div\",{children:props.texts.text1}),/*#__PURE__*/_jsx(\"div\",{children:props.texts.text3})]}),/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",justifyContent:\"space-between\",fontFamily:props.textStyle2.fontFamily,fontSize:props.textStyle2.fontSize,fontWeight:props.textStyle2.fontWeight,color:props.textStyle2.color},children:[/*#__PURE__*/_jsx(\"div\",{children:props.texts.text2}),/*#__PURE__*/_jsx(\"div\",{children:props.texts.text4})]})]})]});}ImageCompareSlider.defaultProps={image1:\"https://placekitten.com/1720/880\",image2:\"https://placehold.co/1720x880\",//video1: \"http://oraclevm.antishok.xyz/avc1.mp4\",\n//video2: \"http://oraclevm.antishok.xyz/avc2.mp4\",\n//video1: \"https://framerusercontent.com/assets/tiYORs6wgTecyAtJFeQSrO9d1d8.mp4\",\n//video2: \"https://framerusercontent.com/assets/C2xpYuswWfUxeDGZj87O48T64F0.mp4\",\nsize:\"cover\",texts:{text1:\"Before\",text2:\"7.3 MB\",text3:\"After\",text4:\"1.2 MB\"},textStyle1:{fontFamily:\"Proxima Nova, Arial\",fontSize:24,color:\"#F1ECDF\",fontWeight:\"bolder\"},textStyle2:{fontFamily:\"Proxima Nova, Arial\",fontSize:42,color:\"#F1ECDF\",fontWeight:\"bolder\"},padding:35};addPropertyControls(ImageCompareSlider,{image1:{type:ControlType.Image,title:\"Image 1\"},image2:{type:ControlType.Image,title:\"Image 2\"},video1:{type:ControlType.File,title:\"Video 1\",allowedFileTypes:[\"mp4\",\"webm\"]},video2:{type:ControlType.File,title:\"Video 2\",allowedFileTypes:[\"mp4\",\"webm\"]},size:{type:ControlType.Enum,options:[\"none\",\"cover\",\"contain\"],optionTitles:[\"Original\",\"Cover\",\"Contain\"],title:\"Image size\",defaultValue:ImageCompareSlider.defaultProps.size},texts:{type:ControlType.Object,title:\"Texts\",controls:{text1:{type:ControlType.String,title:\"Top 1\"},text2:{type:ControlType.String,title:\"Bottom 1\"},text3:{type:ControlType.String,title:\"Top 2\"},text4:{type:ControlType.String,title:\"Bottom 2\"}}},textStyle1:{type:ControlType.Object,title:\"Style 1\",controls:{fontFamily:{type:ControlType.String,title:\"Font\",defaultValue:ImageCompareSlider.defaultProps.textStyle1.fontFamily},fontSize:{type:ControlType.Number,title:\"Font Size\",defaultValue:ImageCompareSlider.defaultProps.textStyle1.fontSize,min:6,max:300,step:1},color:{type:ControlType.Color,title:\"Color\",defaultValue:ImageCompareSlider.defaultProps.textStyle1.color},fontWeight:{type:ControlType.Enum,title:\"Font Weight\",options:[\"normal\",\"bold\",\"bolder\",\"lighter\"],defaultValue:ImageCompareSlider.defaultProps.textStyle1.fontWeight}}},textStyle2:{type:ControlType.Object,title:\"Style 2\",controls:{fontFamily:{type:ControlType.String,title:\"Font\",defaultValue:ImageCompareSlider.defaultProps.textStyle2.fontFamily},fontSize:{type:ControlType.Number,title:\"Font Size\",defaultValue:ImageCompareSlider.defaultProps.textStyle2.fontSize,min:6,max:300,step:1},color:{type:ControlType.Color,title:\"Color\",defaultValue:ImageCompareSlider.defaultProps.textStyle2.color},fontWeight:{type:ControlType.Enum,title:\"Font Weight\",options:[\"normal\",\"bold\",\"bolder\",\"lighter\"],defaultValue:ImageCompareSlider.defaultProps.textStyle2.fontWeight}}},padding:{type:ControlType.Number,title:\"Padding\",min:0,max:200,unit:\"px\",defaultValue:ImageCompareSlider.defaultProps.padding}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ImageCompareSlider\",\"slots\":[],\"annotations\":{\"framerContractVersion\":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