Skip to content

Commit 19b1428

Browse files
committed
give up again
1 parent f19c357 commit 19b1428

File tree

1 file changed

+1
-26
lines changed

1 file changed

+1
-26
lines changed

app/page.tsx

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,6 @@ import Image from "next/image";
44
import { useEffect, useRef } from "react";
55

66
export 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>

0 commit comments

Comments
 (0)