{"version":3,"file":"Hover_Video.CKpE6hgO.mjs","names":["React.useRef","React.useState","React.useCallback","__esmMin","ne","init_npm_react_18_3_1","ce","p","c","init_jsx_runtime","_e","de","init_framer_DcxuU94H","ControlType","addPropertyControls","HoverSoundVideoFrame","props","videoRef","containerRef","hoveredRef","visibleRef","soundOn","setSoundOn","src","videoFile","videoURL","muteVideo","video","unmuteVideo","container","observer","entry","entries","style","radius","poster","showControls","fit","indicator","indicatorLeft","indicatorBottom","indicatorSize","init_Hover_Video"],"sources":["https:/framerusercontent.com/modules/4Lmv6sTk25QJ8uzn3sNB/hlNKhWJwgLll3DO5FkSV/Hover_Video.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 HoverSoundVideoFrame(props){const{videoFile,videoURL,poster,radius,fit,loop,showControls,indicator,indicatorLeft,indicatorBottom,indicatorSize,style}=props;const videoRef=React.useRef(null);const containerRef=React.useRef(null);const hoveredRef=React.useRef(false);const visibleRef=React.useRef(true);const[soundOn,setSoundOn]=React.useState(false);const src=videoFile||videoURL;const muteVideo=React.useCallback(()=>{const video=videoRef.current;if(!video)return;video.muted=true;setSoundOn(false);},[]);const unmuteVideo=React.useCallback(()=>{const video=videoRef.current;if(!video||!visibleRef.current)return;video.volume=1;video.muted=false;setSoundOn(true);if(video.paused){video.play().catch(()=>{video.muted=true;setSoundOn(false);});}},[]);// Recover playback when this video enters or leaves the viewport.\nReact.useEffect(()=>{const container=containerRef.current;const video=videoRef.current;if(!container||!video)return;const observer=new IntersectionObserver(entries=>{const entry=entries[0];if(!entry)return;visibleRef.current=entry.isIntersecting;if(entry.isIntersecting){// Resume silently; wait for fresh hover interaction.\nvideo.muted=true;setSoundOn(false);video.play().catch(()=>{});}else{// Never leave off-screen videos audible.\nvideo.muted=true;setSoundOn(false);}},{threshold:.01});observer.observe(container);return()=>observer.disconnect();},[src]);// Start each video muted and clean up on source change/unmount.\nReact.useEffect(()=>{const video=videoRef.current;if(!video)return;video.muted=true;setSoundOn(false);hoveredRef.current=false;video.play().catch(()=>{});return()=>{video.muted=true;video.pause();};},[src]);const handlePointerEnter=event=>{if(event.pointerType!==\"mouse\")return;hoveredRef.current=true;unmuteVideo();};const handlePointerLeave=event=>{if(event.pointerType!==\"mouse\")return;hoveredRef.current=false;muteVideo();};const handlePointerMove=event=>{if(event.pointerType===\"mouse\"&&hoveredRef.current&&visibleRef.current){const video=videoRef.current;// Recover if the browser reset audio during scrolling.\nif(video&&video.muted){unmuteVideo();}}};return /*#__PURE__*/_jsxs(\"div\",{ref:containerRef,onMouseEnter:()=>{unmuteVideo();},onMouseLeave:()=>{muteVideo();},onTouchEnd:()=>{const video=videoRef.current;if(!video)return;if(video.muted){unmuteVideo();}else{muteVideo();}},style:{...style,position:\"relative\",display:\"block\",width:\"100%\",height:\"100%\",minWidth:0,minHeight:0,margin:0,padding:0,overflow:\"hidden\",borderRadius:radius,backgroundColor:\"#000000\",boxSizing:\"border-box\",isolation:\"isolate\"},children:[src?/*#__PURE__*/_jsx(\"video\",{ref:videoRef,src:src,poster:poster||undefined,autoPlay:true,muted:true,loop:loop,playsInline:true,controls:showControls,preload:\"auto\",style:{position:\"absolute\",inset:0,display:\"block\",width:\"100%\",height:\"100%\",maxWidth:\"none\",maxHeight:\"none\",objectFit:fit,border:0,margin:0,padding:0,boxSizing:\"border-box\"}}):/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",inset:0,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",padding:24,color:\"#ffffff\",fontSize:14,fontFamily:\"Inter, sans-serif\",textAlign:\"center\",boxSizing:\"border-box\"},children:\"Upload a video in the properties panel.\"}),indicator&&/*#__PURE__*/_jsxs(\"div\",{style:{position:\"absolute\",left:indicatorLeft,bottom:indicatorBottom,zIndex:10,display:\"flex\",alignItems:\"center\",gap:7,color:\"#FFFFFF\",fontFamily:\"Inter, sans-serif\",fontSize:indicatorSize,fontWeight:700,lineHeight:1.3,whiteSpace:\"nowrap\",pointerEvents:\"none\",userSelect:\"none\"},children:[soundOn?/*#__PURE__*/_jsxs(\"svg\",{width:\"16\",height:\"16\",viewBox:\"0 0 24 24\",fill:\"none\",stroke:\"currentColor\",strokeWidth:\"2\",strokeLinecap:\"round\",strokeLinejoin:\"round\",style:{flexShrink:0},children:[/*#__PURE__*/_jsx(\"polygon\",{points:\"11 5 6 9 2 9 2 15 6 15 11 19 11 5\",fill:\"currentColor\",stroke:\"none\"}),/*#__PURE__*/_jsx(\"path\",{d:\"M15.5 8.5a5 5 0 0 1 0 7\"}),/*#__PURE__*/_jsx(\"path\",{d:\"M19 5a10 10 0 0 1 0 14\"})]}):/*#__PURE__*/_jsxs(\"svg\",{width:\"16\",height:\"16\",viewBox:\"0 0 24 24\",fill:\"none\",stroke:\"currentColor\",strokeWidth:\"2\",strokeLinecap:\"round\",strokeLinejoin:\"round\",style:{flexShrink:0},children:[/*#__PURE__*/_jsx(\"polygon\",{points:\"11 5 6 9 2 9 2 15 6 15 11 19 11 5\",fill:\"currentColor\",stroke:\"none\"}),/*#__PURE__*/_jsx(\"line\",{x1:\"17\",y1:\"9\",x2:\"22\",y2:\"15\"}),/*#__PURE__*/_jsx(\"line\",{x1:\"22\",y1:\"9\",x2:\"17\",y2:\"15\"})]}),/*#__PURE__*/_jsx(\"span\",{children:soundOn?\"Sound on\":\"Hover for sound\"})]})]});}HoverSoundVideoFrame.defaultProps={videoFile:\"\",videoURL:\"\",poster:\"\",radius:0,fit:\"cover\",loop:true,showControls:false,indicator:true,indicatorLeft:24,indicatorBottom:12,indicatorSize:14};addPropertyControls(HoverSoundVideoFrame,{videoFile:{type:ControlType.File,title:\"Video\",allowedFileTypes:[\"mp4\",\"mov\",\"webm\",\"m4v\"]},videoURL:{type:ControlType.String,title:\"Video URL\",placeholder:\"Optional direct video URL\"},poster:{type:ControlType.Image,title:\"Poster\"},radius:{type:ControlType.Number,title:\"Radius\",defaultValue:0,min:0,max:100,step:1,unit:\"px\"},fit:{type:ControlType.Enum,title:\"Video Fit\",options:[\"cover\",\"contain\",\"fill\"],optionTitles:[\"Cover\",\"Contain\",\"Fill\"],defaultValue:\"cover\"},loop:{type:ControlType.Boolean,title:\"Loop\",defaultValue:true},showControls:{type:ControlType.Boolean,title:\"Native Controls\",defaultValue:false},indicator:{type:ControlType.Boolean,title:\"Sound Indicator\",defaultValue:true},indicatorLeft:{type:ControlType.Number,title:\"Indicator Left\",defaultValue:24,min:0,max:100,unit:\"px\"},indicatorBottom:{type:ControlType.Number,title:\"Indicator Bottom\",defaultValue:12,min:0,max:100,unit:\"px\"},indicatorSize:{type:ControlType.Number,title:\"Text Size\",defaultValue:14,min:8,max:32,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"HoverSoundVideoFrame\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Hover_Video.map"],"mappings":"A,sMAAyI,SAAwBe,EAAqB,EAAM,CAAC,GAAK,CAAC,YAAU,WAAS,SAAO,SAAO,MAAI,OAAK,eAAa,YAAU,gBAAc,kBAAgB,gBAAc,SAAOC,EAAYC,EAASjB,EAAa,IAAI,EAAQkB,EAAalB,EAAa,IAAI,EAAQmB,EAAWnB,EAAa,EAAK,EAAQoB,EAAWpB,EAAa,EAAI,EAAO,CAACqB,EAAQC,GAAYrB,EAAe,EAAK,EAAQsB,EAAIC,GAAWC,EAAeC,EAAUxB,MAAsB,CAAC,IAAMyB,EAAMV,EAAS,QAAYU,IAAa,EAAM,MAAM,GAAKL,EAAW,EAAK,EAAE,EAAE,CAAC,CAAC,EAAQM,EAAY1B,MAAsB,CAAC,IAAMyB,EAAMV,EAAS,QAAYU,GAAQP,EAAW,UAAe,EAAM,OAAO,EAAE,EAAM,MAAM,GAAME,EAAW,EAAI,EAAKK,EAAM,QAAQA,EAAM,KAAK,CAAC,CAAC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