File tree Expand file tree Collapse file tree 1 file changed +1
-26
lines changed Expand file tree Collapse file tree 1 file changed +1
-26
lines changed Original file line number Diff line number Diff line change @@ -4,31 +4,6 @@ import Image from "next/image";
44import { useEffect , useRef } from "react" ;
55
66export default function Page ( ) {
7- const videoRef = useRef < HTMLVideoElement > ( null ) ;
8-
9- useEffect ( ( ) => {
10- const observer = new IntersectionObserver (
11- ( entries ) => {
12- if ( videoRef . current ) {
13- if ( entries [ 0 ] . isIntersecting ) {
14- videoRef . current . play ( )
15- videoRef . current . muted = false
16- } else {
17- videoRef . current . pause ( )
18- videoRef . current . muted = true
19- }
20- }
21- } ,
22- { threshold : 0.7 } // 50% visible triggers play/pause
23- ) ;
24-
25- if ( videoRef . current ) {
26- observer . observe ( videoRef . current ) ;
27- }
28-
29- return ( ) => observer . disconnect ( ) ;
30- } , [ ] ) ;
31-
327 return (
338 < >
349 < div className = "flex justify-center items-center min-h-screen bg-purple-200" >
@@ -39,7 +14,7 @@ export default function Page() {
3914 width = { 500 }
4015 height = { 500 } />
4116 < div >
42- < video ref = { videoRef } loop autoPlay muted playsInline height = "500" width = "500" >
17+ < video loop autoPlay muted playsInline height = "500" width = "500" >
4318 < source src = "/never-gonna-give-up.mp4" type = "video/mp4" />
4419 </ video >
4520 </ div >
You can’t perform that action at this time.
0 commit comments