{"version":3,"file":"ScrollScrubber.CxcIUP6d.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/wn4rasfx5ioAY8XQ9SMY/ProyxmsNH9AYxBuOAMnV/ScrollScrubber.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef,useState}from\"react\";import{useViewportScroll,useTransform,motion}from\"framer-motion\";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,startOn,videoFit}){const videoRef=useRef(null);const containerRef=useRef(null);const{scrollY}=useViewportScroll();const[containerTop,setContainerTop]=useState(0);const[containerHeight,setContainerHeight]=useState(0);useEffect(()=>{if(containerRef.current){const rect=containerRef.current.getBoundingClientRect();setContainerTop(window.pageYOffset+rect.top);setContainerHeight(rect.height);}},[]);const videoProgress=useTransform(scrollY,[containerTop,containerTop+containerHeight],[0,1]);useEffect(()=>{let observer;let options={};if(startOn===\"top\"){options={threshold:0};}else if(startOn===\"center\"){options={threshold:.5};}else if(startOn===\"bottom\"){options={threshold:1};}observer=new IntersectionObserver(([entry])=>{if(entry.isIntersecting&&videoRef.current){const scrollPosition=window.pageYOffset+entry.boundingClientRect.top;const progress=(scrollPosition-containerTop)/containerHeight;videoRef.current.currentTime=progress*videoRef.current.duration;}},options);if(videoRef.current){observer.observe(videoRef.current);}return()=>{if(videoRef.current){observer.unobserve(videoRef.current);}};},[startOn,containerTop,containerHeight]);useEffect(()=>{const updateVideoTime=()=>{if(videoRef.current){const scrollPosition=window.pageYOffset;const progress=(scrollPosition-containerTop)/containerHeight;videoRef.current.currentTime=Math.max(0,Math.min(1,progress))*videoRef.current.duration;}};window.addEventListener(\"scroll\",updateVideoTime);return()=>window.removeEventListener(\"scroll\",updateVideoTime);},[containerTop,containerHeight]);const videoSrc=videoSourceType===\"url\"?videoSrcURL:videoSrcFile;const alignmentStyles={center:{top:\"50%\",transform:\"translateY(-50%)\"},top:{top:0},bottom:{bottom:0}};return /*#__PURE__*/_jsx(motion.div,{ref:containerRef,style:{height:scrollLength,position:\"relative\"},children:/*#__PURE__*/_jsx(\"video\",{ref:videoRef,src:videoSrc,style:{width:\"100%\",height:\"100vh\",position:\"sticky\",objectFit:videoFit,...alignmentStyles[videoAlignment]},muted:true,playsInline:true})});}ScrollVideo.defaultProps={videoSourceType:\"url\",videoSrcURL:\"https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4\",scrollLength:500,videoAlignment:\"center\",startOn:\"top\",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\",defaultValue:\"https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4\",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:500,min:100,max:2e4,step:30},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\"},startOn:{type:ControlType.Enum,title:\"Start On\",options:[\"top\",\"center\",\"bottom\"],optionTitles:[\"Top\",\"Center\",\"Bottom\"],defaultValue:\"top\",description:\"v1.0 \\n[via SegmentUI](https://www.segmentUI.com)\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ScrollVideo\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerIntrinsicWidth\":\"600\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerIntrinsicHeight\":\"400\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ScrollScrubber.map"],"mappings":"qQAKG,SAAwB,EAAY,CAAC,kBAAgB,cAAY,eAAa,eAAa,iBAAe,UAAQ,YAAU,CAAC,IAAM,EAASA,EAAO,KAAK,CAAO,EAAaA,EAAO,KAAK,CAAM,CAAC,WAAS,GAAmB,CAAM,CAAC,EAAa,GAAiBC,EAAS,EAAE,CAAM,CAAC,EAAgB,GAAoBA,EAAS,EAAE,CAAC,MAAc,CAAC,GAAG,EAAa,QAAQ,CAAC,IAAM,EAAK,EAAa,QAAQ,uBAAuB,CAAC,EAAgB,EAAO,YAAY,EAAK,IAAI,CAAC,EAAmB,EAAK,OAAO,GAAI,EAAE,CAAC,CAAqB,EAAa,EAAQ,CAAC,EAAa,EAAa,EAAgB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,MAAc,CAAC,IAAI,EAAa,EAAQ,EAAE,CAAmf,OAA/e,IAAU,MAAO,EAAQ,CAAC,UAAU,EAAE,CAAU,IAAU,SAAU,EAAQ,CAAC,UAAU,GAAG,CAAU,IAAU,WAAU,EAAQ,CAAC,UAAU,EAAE,EAAE,EAAS,IAAI,sBAAsB,CAAC,KAAS,CAAC,GAAG,EAAM,gBAAgB,EAAS,QAAQ,CAAsE,IAAM,GAAtD,EAAO,YAAY,EAAM,mBAAmB,IAAmC,GAAc,EAAgB,EAAS,QAAQ,YAAY,EAAS,EAAS,QAAQ,WAAY,EAAQ,CAAI,EAAS,SAAS,EAAS,QAAQ,EAAS,QAAQ,KAAY,CAAI,EAAS,SAAS,EAAS,UAAU,EAAS,QAAQ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