Add video interactivity scripts
It's a very dirty code, but there is no time to do optimizations with the current deadline.master
parent
e3a3fcba9b
commit
b3b2230801
@ -0,0 +1,30 @@
|
||||
let video = document.getElementById("video");
|
||||
let source = document.getElementById("source");
|
||||
|
||||
|
||||
let video_list = document.getElementById("video-list").getElementsByTagName("img");
|
||||
var i;
|
||||
|
||||
for (i = 0; i < video_list.length; i++) {
|
||||
video_list[i].addEventListener("click", function() {
|
||||
video.setAttribute("poster", this.getAttribute("src"));
|
||||
source.setAttribute("src", this.dataset.video);
|
||||
video.pause();
|
||||
video.currentTime = 0;
|
||||
video.load();
|
||||
|
||||
for (i = 0; i < video_list.length; i++) {
|
||||
video_list[i].classList.remove("active");
|
||||
}
|
||||
this.classList.add("active");
|
||||
|
||||
video.style["box-shadow"] = this.dataset.shadow;
|
||||
});
|
||||
}
|
||||
|
||||
video.addEventListener("click", function() {
|
||||
if (this.paused)
|
||||
this.play();
|
||||
else
|
||||
this.pause();
|
||||
});
|
Loading…
Reference in New Issue