{"version":3,"file":"Video_Scroller.D82oTPXF.mjs","names":["React.useRef"],"sources":["https:/framerusercontent.com/modules/89ij509skJax5dOhCp0u/w6izRUxGz4Wi5RZNKz5d/Video_Scroller.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType}from\"framer\";export default function CenterScrollVideo(props){const{video,poster,triggerZone,playWhenCentered,pauseWhenOutside,resetWhenOutside,muted,loop,controls,playsInline,objectFit,borderRadius,shadow,opacity,backgroundColor,debug}=props;const wrapperRef=React.useRef(null);const videoRef=React.useRef(null);React.useEffect(()=>{const wrapper=wrapperRef.current;const videoEl=videoRef.current;if(!wrapper||!videoEl)return;let ticking=false;const checkPosition=()=>{const rect=wrapper.getBoundingClientRect();const viewportCenter=window.innerHeight/2;const elementCenter=rect.top+rect.height/2;const distance=Math.abs(elementCenter-viewportCenter);const allowedDistance=window.innerHeight*(triggerZone/100);const isCentered=distance<=allowedDistance;if(isCentered&&playWhenCentered){videoEl.play().catch(()=>{});}if(!isCentered&&pauseWhenOutside){videoEl.pause();if(resetWhenOutside){videoEl.currentTime=0;}}wrapper.dataset.centered=isCentered?\"true\":\"false\";ticking=false;};const onScroll=()=>{if(!ticking){window.requestAnimationFrame(checkPosition);ticking=true;}};window.addEventListener(\"scroll\",onScroll,{passive:true});window.addEventListener(\"resize\",onScroll);checkPosition();return()=>{window.removeEventListener(\"scroll\",onScroll);window.removeEventListener(\"resize\",onScroll);};},[triggerZone,playWhenCentered,pauseWhenOutside,resetWhenOutside]);return /*#__PURE__*/_jsxs(\"div\",{ref:wrapperRef,style:{width:\"100%\",height:\"100%\",position:\"relative\",overflow:\"hidden\",borderRadius,backgroundColor,boxShadow:shadow,opacity},children:[/*#__PURE__*/_jsx(\"video\",{ref:videoRef,src:video,poster:poster,muted:muted,loop:loop,controls:controls,playsInline:playsInline,preload:\"auto\",style:{width:\"100%\",height:\"100%\",objectFit,display:\"block\"}}),debug&&/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",inset:0,pointerEvents:\"none\",border:\"2px dashed red\"}})]});}CenterScrollVideo.defaultProps={triggerZone:12,playWhenCentered:true,pauseWhenOutside:true,resetWhenOutside:false,muted:true,loop:false,controls:false,playsInline:true,objectFit:\"cover\",borderRadius:0,shadow:\"none\",opacity:1,backgroundColor:\"#000000\",debug:false};addPropertyControls(CenterScrollVideo,{video:{type:ControlType.File,title:\"Video\",allowedFileTypes:[\"mp4\",\"webm\",\"mov\"]},poster:{type:ControlType.Image,title:\"Poster\"},triggerZone:{type:ControlType.Number,title:\"Trigger Zone\",min:1,max:50,step:1,unit:\"%\",defaultValue:12},playWhenCentered:{type:ControlType.Boolean,title:\"Play Center\",defaultValue:true},pauseWhenOutside:{type:ControlType.Boolean,title:\"Pause Outside\",defaultValue:true},resetWhenOutside:{type:ControlType.Boolean,title:\"Reset Outside\",defaultValue:false},muted:{type:ControlType.Boolean,title:\"Muted\",defaultValue:true},loop:{type:ControlType.Boolean,title:\"Loop\",defaultValue:false},controls:{type:ControlType.Boolean,title:\"Controls\",defaultValue:false},playsInline:{type:ControlType.Boolean,title:\"Inline\",defaultValue:true},objectFit:{type:ControlType.Enum,title:\"Fit\",options:[\"cover\",\"contain\",\"fill\"],defaultValue:\"cover\"},borderRadius:{type:ControlType.Number,title:\"Radius\",min:0,max:100,step:1,defaultValue:0},shadow:{type:ControlType.String,title:\"Shadow\",defaultValue:\"none\"},opacity:{type:ControlType.Number,title:\"Opacity\",min:0,max:1,step:.05,defaultValue:1},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#000000\"},debug:{type:ControlType.Boolean,title:\"Debug Border\",defaultValue:false}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CenterScrollVideo\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Video_Scroller.map"],"mappings":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