{"version":3,"file":"ScrollScrubber.CyNB_BJT.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/4Ih7A75DYDjC6Z6eO6x2/LDsiX21JPFM7pw3GKawj/ScrollScrubber.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef,useState}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerIntrinsicWidth 600\n * @framerSupportedLayoutHeight any-prefer-fixed\n * @framerIntrinsicHeight 400\n */export default function ScrollVideo({videoSourceType,videoSrcURL,videoSrcFile,scrollLength,videoAlignment,videoFit}){const videoRef=useRef(null);const containerRef=useRef(null);const[ready,setReady]=useState(false);// Step 1 — load metadata + iOS unlock via autoplay/pause trick\nuseEffect(()=>{const vid=videoRef.current;if(!vid)return;const onMeta=()=>{// Immediately pause and reset — this unlocks currentTime\n// manipulation on iOS without actually playing the video\nvid.pause();vid.currentTime=0;setReady(true);};vid.addEventListener(\"loadedmetadata\",onMeta);// Force load on mobile — some browsers won't fire loadedmetadata\n// without an explicit load() call\nvid.load();return()=>vid.removeEventListener(\"loadedmetadata\",onMeta);},[]);// Step 2 — scrub video on scroll once ready\nuseEffect(()=>{if(!ready)return;const updateTime=()=>{const container=containerRef.current;const vid=videoRef.current;if(!container||!vid||!vid.duration)return;const rect=container.getBoundingClientRect();const scrolled=-rect.top;const total=rect.height-window.innerHeight;const progress=Math.max(0,Math.min(1,scrolled/total));// Guard against NaN on short videos or zero duration\nconst next=progress*vid.duration;if(isFinite(next))vid.currentTime=next;};window.addEventListener(\"scroll\",updateTime,{passive:true});// Run once immediately in case page loads mid-scroll\nupdateTime();return()=>window.removeEventListener(\"scroll\",updateTime);},[ready]);const videoSrc=videoSourceType===\"url\"?videoSrcURL:videoSrcFile;const alignmentStyles={center:{top:\"50%\",transform:\"translateY(-50%)\"},top:{top:0},bottom:{bottom:0}};return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{height:scrollLength,position:\"relative\"},children:/*#__PURE__*/_jsx(\"div\",{style:{position:\"sticky\",top:0,width:\"100%\",height:\"100vh\",overflow:\"hidden\"},children:/*#__PURE__*/_jsx(\"video\",{ref:videoRef,src:videoSrc,style:{position:\"absolute\",width:\"100%\",height:\"100%\",objectFit:videoFit,...alignmentStyles[videoAlignment]},muted:true,playsInline:true,autoPlay:true,preload:\"auto\"})})});}ScrollVideo.defaultProps={videoSourceType:\"url\",videoSrcURL:\"https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4\",scrollLength:2e3,videoAlignment:\"center\",videoFit:\"cover\"};addPropertyControls(ScrollVideo,{videoSourceType:{type:ControlType.Enum,title:\"Source Type\",options:[\"url\",\"file\"],optionTitles:[\"URL\",\"File\"],defaultValue:\"url\"},videoSrcURL:{type:ControlType.String,title:\"Video URL\",hidden:({videoSourceType})=>videoSourceType!==\"url\"},videoSrcFile:{type:ControlType.File,title:\"Video File\",allowedFileTypes:[\"mp4\",\"mov\",\"webm\"],hidden:({videoSourceType})=>videoSourceType!==\"file\"},scrollLength:{type:ControlType.Number,title:\"Scroll Length\",defaultValue:2e3,min:500,max:2e4,step:100},videoAlignment:{type:ControlType.Enum,title:\"Video Alignment\",options:[\"center\",\"top\",\"bottom\"],optionTitles:[\"Center\",\"Top\",\"Bottom\"],defaultValue:\"center\"},videoFit:{type:ControlType.Enum,title:\"Video Fit\",options:[\"cover\",\"contain\",\"fill\"],optionTitles:[\"Cover\",\"Contain\",\"Fill\"],defaultValue:\"cover\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ScrollVideo\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerIntrinsicHeight\":\"400\",\"framerIntrinsicWidth\":\"600\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# source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