{"version":3,"file":"InViewVideo.BcDgiu2P.mjs","names":["useRef","__esmMin","c","init_jsx_runtime","ce","init_npm_react_18_3_1","de","init_framer_Bf4_tcb2","addPropertyControls","ControlType","InViewVideo","props","ref","v","started","io","e","threshold","src","poster","fit","init_InViewVideo"],"sources":["https:/framerusercontent.com/modules/6EBfT6zpIlDjPZdeXmyW/fWP8xKErkgM2UO5xnilU/InViewVideo.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef}from\"react\";import{addPropertyControls,ControlType}from\"framer\";// A video that starts playing only when it scrolls into view and pauses when it leaves. Muted so browsers\n// allow autoplay; controls let visitors unmute, scrub or go full screen. Nothing downloads before it's\n// close to the viewport.\n/**\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n */export default function InViewVideo(props){const{src,poster,controls=true,loop=true,fit=\"contain\",threshold=.5}=props;const ref=useRef(null);useEffect(()=>{const v=ref.current;if(!v)return;if(typeof IntersectionObserver===\"undefined\")return;let started=false;const io=new IntersectionObserver(([e])=>{if(e.isIntersecting&&e.intersectionRatio>=threshold){if(!started){v.preload=\"auto\";started=true;}v.play().catch(()=>{});}else if(!v.paused)v.pause();},{threshold:[0,threshold]});io.observe(v);return()=>io.disconnect();},[src,threshold]);return /*#__PURE__*/_jsx(\"video\",{ref:ref,src:src,poster:poster||undefined,muted:true,playsInline:true,loop:loop,controls:controls,preload:\"none\",style:{width:\"100%\",height:\"100%\",objectFit:fit,display:\"block\",background:\"transparent\"}});}addPropertyControls(InViewVideo,{src:{type:ControlType.String,title:\"Video URL\"},poster:{type:ControlType.String,title:\"Poster URL\"},controls:{type:ControlType.Boolean,title:\"Controls\",defaultValue:true},loop:{type:ControlType.Boolean,title:\"Loop\",defaultValue:true},fit:{type:ControlType.Enum,title:\"Fit\",options:[\"contain\",\"cover\"],defaultValue:\"contain\"},threshold:{type:ControlType.Number,title:\"Visible %\",min:.1,max:1,step:.05,defaultValue:.5}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"InViewVideo\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"fixed\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./InViewVideo.map"],"mappings":"A,iLAMG,SAAwBU,EAAY,EAAM,CAAC,GAAK,CAAC,MAAI,SAAO,WAAS,GAAK,OAAK,GAAK,MAAI,UAAU,YAAU,IAAIC,EAAYC,EAAIZ,EAAO,IAAI,EAA+Y,OAA7YI,MAAc,CAAC,IAAMS,EAAED,EAAI,QAAqB,GAAV,CAACC,GAAY,OAAO,qBAAuB,IAAY,OAAO,IAAIC,EAAQ,GAAYC,EAAG,IAAI,sBAAsB,CAACC,KAAK,CAAIA,EAAE,gBAAgBA,EAAE,mBAAmBC,GAAW,AAA8BH,KAAjB,EAAE,QAAQ,OAAe,IAAMD,EAAE,KAAK,CAAC,CAAC,UAAU,CAAC,CAAC,GAAYA,EAAE,QAAOA,EAAE,MAAM,CAAE,EAAE,CAAC,UAAU,CAAC,EAAEI,CAAS,CAAC,CAAC,EAAgB,OAAdF,EAAG,QAAQF,CAAC,MAAYE,EAAG,WAAW,CAAE,EAAE,CAACG,EAAID,CAAS,CAAC,EAAsB,gBAAK,QAAQ,CAAK,MAAQ,MAAI,OAAOE,GAAQ,IAAA,GAAU,MAAM,GAAK,YAAY,GAAU,OAAc,WAAS,QAAQ,OAAO,MAAM,CAAC,MAAM,OAAO,OAAO,OAAO,UAAUC,EAAI,QAAQ,QAAQ,WAAW,aAAa,CAAC,CAAC,CAAE,C,0CAACZ,EAAoBE,EAAY,CAAC,IAAI,CAAC,KAAKD,EAAY,OAAO,MAAM,WAAW,EAAE,OAAO,CAAC,KAAKA,EAAY,OAAO,MAAM,YAAY,EAAE,SAAS,CAAC,KAAKA,EAAY,QAAQ,MAAM,WAAW,aAAa,EAAI,EAAE,KAAK,CAAC,KAAKA,EAAY,QAAQ,MAAM,OAAO,aAAa,EAAI,EAAE,IAAI,CAAC,KAAKA,EAAY,KAAK,MAAM,MAAM,QAAQ,CAAC,UAAU,OAAO,EAAE,aAAa,SAAS,EAAE,UAAU,CAAC,KAAKA,EAAY,OAAO,MAAM,YAAY,IAAI,GAAG,IAAI,EAAE,KAAK,IAAI,aAAa,EAAE,CAAC,CAAC,C"}