Skip to content

Commit 07151a1

Browse files
committed
fix: enhance video interaction by managing pointer events and button visibility
1 parent 0a47771 commit 07151a1

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

apps/website/src/sections/Spotlight.astro

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ import PlayButton from "../assets/videos/play-button.svg";
4444
margin-inline: var(--spacing-xl);
4545
}
4646

47+
.video-not-interactive {
48+
pointer-events: none;
49+
}
50+
4751
video::-webkit-media-controls-panel {
4852
background-image: none;
4953
filter: brightness(0.2);
@@ -57,6 +61,11 @@ import PlayButton from "../assets/videos/play-button.svg";
5761
top: 50%;
5862
left: 50%;
5963
transform: translate(-50%, -50%);
64+
visibility: visible;
65+
}
66+
67+
.playButton-invisible {
68+
visibility: hidden;
6069
}
6170

6271
.playButton :hover {
@@ -99,20 +108,20 @@ import PlayButton from "../assets/videos/play-button.svg";
99108
const myButton = document.getElementsByClassName("playButton")[0] as HTMLButtonElement;
100109
let isPlaying = false;
101110

102-
video.style.pointerEvents = "none";
111+
video.classList.add("video-not-interactive");
103112

104113
myButton.addEventListener("click", () => {
105114
video.play();
106115
isPlaying = true;
107-
myButton.style.visibility = "hidden";
108-
video.style.pointerEvents = "auto";
116+
myButton.classList.add("playButton-invisible");
117+
video.classList.remove("video-not-interactive");
109118
});
110119

111120
video.addEventListener("pause", () => {
112121
if (isPlaying) {
113122
isPlaying = false;
114-
myButton.style.visibility = "visible";
115-
video.style.pointerEvents = "none";
123+
myButton.classList.remove("playButton-invisible");
124+
video.classList.add("video-not-interactive");
116125
}
117126
});
118127
});

0 commit comments

Comments
 (0)