@@ -20,7 +20,13 @@ export const Video = ({ style, src, muted, onExitFullscreen, ...props }: VideoPr
2020
2121 const [ fullscreen , setFullscreen ] = useState ( onExitFullscreen != undefined ) ;
2222
23+ const isBgVideo = onExitFullscreen == null && fullscreen ;
24+
2325 function setPlaying ( isPlaying : boolean ) {
26+ if ( isBgVideo && isPlaying ) {
27+ setPlaying ( false )
28+ return ;
29+ }
2430 if ( ! isPlaying ) {
2531 setShowMutedIcon ( true )
2632 if ( videoRef . current != null )
@@ -37,7 +43,7 @@ export const Video = ({ style, src, muted, onExitFullscreen, ...props }: VideoPr
3743
3844 return < MediaContainer style = { { ...style } }
3945 >
40- < a href = { src } role = 'button' aria-label = 'video' style = { { position : 'relative' , display : 'flex' , width : '100%' , height : '100%' } }
46+ < div role = 'button' aria-label = 'video' style = { { cursor : 'pointer' , position : 'relative' , display : 'flex' , width : '100%' , height : '100%' } }
4147 onMouseOver = {
4248 ( e ) => {
4349 e . preventDefault ( )
@@ -76,9 +82,10 @@ export const Video = ({ style, src, muted, onExitFullscreen, ...props }: VideoPr
7682 play_circle
7783 </ span > }
7884
79- < a onClick = { ( e ) => {
85+ < div onClick = { ( e ) => {
8086 e . stopPropagation ( ) ;
8187 e . preventDefault ( ) ;
88+ setPlaying ( false ) ;
8289 return onExitFullscreen != null ? onExitFullscreen ( ) : setFullscreen ( true ) ;
8390 } } >
8491 < span className = "material-symbols-outlined" style = { {
@@ -91,16 +98,16 @@ export const Video = ({ style, src, muted, onExitFullscreen, ...props }: VideoPr
9198 // cursor: 'zoom-in'
9299 // transform: 'translate(-50%, -50%)'
93100 } } > fullscreen</ span >
94- </ a >
101+ </ div >
95102
96- < video muted autoPlay = { isPlaying } loop ref = { videoRef } src = { src } style = { { width : '100%' , height : '100%' , objectFit : "cover" } } { ...props } > </ video >
103+ < video muted autoPlay = { isPlaying } loop ref = { videoRef } src = { src } style = { { width : '100%' , height : '100%' } } { ...props } > </ video >
97104
98105 { onExitFullscreen == null && < ReactModal isOpen = { fullscreen } onRequestClose = { ( ) => setFullscreen ( false ) } style = { {
99106 overlay : { backgroundColor : 'rgba(0,0,0,0.8)' , zIndex : 1000 } ,
100107 } } >
101- < Video onExitFullscreen = { ( ) => setFullscreen ( false ) } src = { src } muted = { muted } />
108+ < Video onExitFullscreen = { ( ) => setFullscreen ( false ) } src = { src } style = { { objectFit : 'inherit' , margin : 0 } } muted = { muted } />
102109 </ ReactModal > }
103110
104- </ a >
111+ </ div >
105112 </ MediaContainer >
106113}
0 commit comments