-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
36 lines (33 loc) · 862 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const vid = document.getElementById("nemo");
const vidContainer = document.querySelector("[data-video-container]");
let isPlaying = false;
vid.onloadedmetadata = () => {
vidContainer.addEventListener("click", playVideo);
};
function playVideo() {
isPlaying ? vid.pause() : vid.play();
}
vid.onplaying = function () {
isPlaying = true;
vid.addEventListener("timeupdate", () => {
vidContainer.style.setProperty(
"--borderLeft",
Math.floor(vid.currentTime) + "%"
);
vidContainer.style.setProperty(
"--borderTop",
Math.floor(vid.currentTime) + "%"
);
vidContainer.style.setProperty(
"--borderRight",
Math.floor(vid.currentTime) + "%"
);
vidContainer.style.setProperty(
"--borderBottom",
Math.floor(vid.currentTime) + "%"
);
});
};
vid.onpause = function () {
isPlaying = false;
};