1
0
Fork 0

Add video interactivity scripts

It's a very dirty code, but there is no time to do optimizations with
the current deadline.
master
Emil Miler 2 years ago
parent e3a3fcba9b
commit b3b2230801

@ -36,14 +36,14 @@
<p>&hellip;&nbsp;ale mají kolem sebe jiné svědky, kteří to bohužel vidí.</p> <p>&hellip;&nbsp;ale mají kolem sebe jiné svědky, kteří to bohužel vidí.</p>
</div> </div>
<div class="player"> <div class="player">
<video> <video id="video" poster="/static/vid/pestouni.jpg">
<source src="/static/vid/pestouni.mp4" type="video/mp4"> <source src="/static/vid/pestouni.mp4" type="video/mp4" id="source">
</video> </video>
</div> </div>
<div class="video-list"> <div class="video-list" id="video-list">
<img src="/static/vid/pestouni.jpg" alt="Pěstouni" data-video="/static/vid/pestouni.mp4" class="active"> <img src="/static/vid/pestouni.jpg" alt="Pěstouni" data-video="/static/vid/pestouni.mp4" data-shadow="0 0 42px 0 rgba(194,66,66,0.75)" class="active">
<img src="/static/vid/tyrani.jpg" alt="Týrání" data-video="/static/tyrani.mp4"> <img src="/static/vid/tyrani.jpg" alt="Týrání" data-video="/static/vid/tyrani.mp4" data-shadow="0 0 42px 0 rgba(81, 52, 147, 0.75)">
<img src="/static/vid/samozivitel.jpg" alt="Samoživitel" data-video="/static/vid/samozivitel.mp4"> <img src="/static/vid/samozivitel.jpg" alt="Samoživitel" data-video="/static/vid/samozivitel.mp4" data-shadow="0px 0px 42px 0px rgba(172, 102, 59, 0.75)">
</div> </div>
<a href="" class="button">Vyhledat pomoc</a> <a href="" class="button">Vyhledat pomoc</a>
</div> </div>
@ -220,6 +220,7 @@
</footer> </footer>
<script type="text/javascript" src="/static/js/nav.js"></script> <script type="text/javascript" src="/static/js/nav.js"></script>
<script type="text/javascript" src="/static/js/player.js"></script>
<script type="text/javascript" src="/static/js/accordion.js"></script> <script type="text/javascript" src="/static/js/accordion.js"></script>
<script type="text/javascript" src="/static/js/vanilla-tilt.js"></script> <script type="text/javascript" src="/static/js/vanilla-tilt.js"></script>
</body> </body>

@ -188,11 +188,13 @@ body.noscroll {
} }
.player { .player {
cursor: pointer;
video { video {
width: 100%; width: 100%;
border-radius: 2rem; border-radius: 2rem;
box-shadow: 0 0 42px 0 rgba(194,66,66,0.75); box-shadow: 0 0 42px 0 rgba(194,66,66,0.75);
transition: box-shadow 1s ease;
} }
} }

@ -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…
Cancel
Save