{"version":3,"file":"VideoOnScreen.5_RDWRhF.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/WCz6HJsY5bFCIsEJKDCF/Uw5Je8ML1NS30BpzXckF/VideoOnScreen.js"],"sourcesContent":["// Video component that only plays when on screen\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useRef,useEffect,useState,startTransition}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";import{useInView}from\"framer-motion\";/**\n * VideoOnScreen\n *\n * Plays video only when in viewport using useInView from framer-motion\n *\n * @framerIntrinsicWidth 640\n * @framerIntrinsicHeight 360\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function VideoOnScreen(props){const{videoFile=\"https://framerusercontent.com/assets/MLWPbW1dUQawJLhhun3dBwpgJak.mp4\",posterFile=\"https://framerusercontent.com/images/GfGkADagM4KEibNcIiRUWlfrR0.jpg\",autoPlay,muted,loop,controls,style}=props;const ref=useRef(null);const videoRef=useRef(null);const[isPlaying,setIsPlaying]=useState(false);const inView=useInView(ref,{amount:.2,once:false});const isStatic=useIsStaticRenderer();useEffect(()=>{if(isStatic)return;const video=videoRef.current;if(!video)return;if(inView){startTransition(()=>setIsPlaying(true));if(autoPlay)video.play().catch(()=>{});}else{startTransition(()=>setIsPlaying(false));video.pause();}},[inView,autoPlay,isStatic]);return /*#__PURE__*/_jsx(\"div\",{ref:ref,style:{width:\"100%\",height:\"100%\",position:\"relative\"},children:/*#__PURE__*/_jsx(\"video\",{ref:videoRef,src:videoFile,poster:posterFile,muted:muted,loop:loop,controls:controls,style:{width:\"100%\",height:\"100%\",display:\"block\",borderRadius:8,...style},playsInline:true})});}addPropertyControls(VideoOnScreen,{videoFile:{type:ControlType.File,allowedFileTypes:[\"mp4\",\"webm\",\"mov\"]},posterFile:{type:ControlType.File,allowedFileTypes:[\"jpg\",\"jpeg\",\"png\",\"webp\"]},autoPlay:{type:ControlType.Boolean,title:\"Autoplay\",defaultValue:true},muted:{type:ControlType.Boolean,title:\"Muted\",defaultValue:true},loop:{type:ControlType.Boolean,title:\"Loop\",defaultValue:false},controls:{type:ControlType.Boolean,title:\"Controls\",defaultValue:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"VideoOnScreen\",\"slots\":[],\"annotations\":{\"framerIntrinsicHeight\":\"360\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"640\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./VideoOnScreen.map"],"mappings":"uPAWG,SAAwB,EAAc,EAAM,CAAC,GAAK,CAAC,YAAU,uEAAuE,aAAW,sEAAsE,WAAS,QAAM,OAAK,WAAS,SAAO,EAAY,EAAIA,EAAO,KAAK,CAAO,EAASA,EAAO,KAAK,CAAM,CAAC,EAAU,GAAcC,EAAS,GAAM,CAAO,EAAO,EAAU,EAAI,CAAC,OAAO,GAAG,KAAK,GAAM,CAAC,CAAO,EAAS,GAAqB,CAAuQ,OAAtQ,MAAc,CAAC,GAAG,EAAS,OAAO,IAAM,EAAM,EAAS,QAAY,IAAgB,GAAQ,MAAoB,EAAa,GAAK,CAAC,CAAI,GAAS,EAAM,MAAM,CAAC,UAAU,GAAG,GAAO,MAAoB,EAAa,GAAM,CAAC,CAAC,EAAM,OAAO,IAAI,CAAC,EAAO,EAAS,EAAS,CAAC,CAAqB,EAAK,MAAM,CAAK,MAAI,MAAM,CAAC,MAAM,OAAO,OAAO,OAAO,SAAS,WAAW,CAAC,SAAsB,EAAK,QAAQ,CAAC,IAAI,EAAS,IAAI,EAAU,OAAO,EAAiB,QAAW,OAAc,WAAS,MAAM,CAAC,MAAM,OAAO,OAAO,OAAO,QAAQ,QAAQ,aAAa,EAAE,GAAG,EAAM,CAAC,YAAY,GAAK,CAAC,CAAC,CAAC,kBAV78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