Home > slideshow > videos verticales incluses dans paires
All checks were successful
Deploy / Deploy to Production (push) Successful in 8s
All checks were successful
Deploy / Deploy to Production (push) Successful in 8s
This commit is contained in:
parent
4412a0a01a
commit
3486ae9c6c
10 changed files with 85 additions and 43 deletions
|
|
@ -26,15 +26,34 @@ if (slideshow) {
|
|||
return index;
|
||||
}
|
||||
|
||||
function updateVideos(index) {
|
||||
const el = items[index];
|
||||
const videos = el.querySelectorAll("video");
|
||||
videos.forEach((video) => {
|
||||
video.currentTime = 0;
|
||||
video.play().catch(() => {});
|
||||
});
|
||||
}
|
||||
|
||||
function pauseAllVideos() {
|
||||
items.forEach((el) => {
|
||||
const videos = el.querySelectorAll("video");
|
||||
videos.forEach((video) => video.pause());
|
||||
});
|
||||
}
|
||||
|
||||
function goTo(index) {
|
||||
items[current].classList.remove("active");
|
||||
pauseAllVideos();
|
||||
current = index;
|
||||
items[current].classList.add("active");
|
||||
updateVideos(current);
|
||||
}
|
||||
|
||||
const firstVisible = findNext(-1, 1);
|
||||
items[firstVisible]?.classList.add("active");
|
||||
current = firstVisible;
|
||||
updateVideos(current);
|
||||
|
||||
prev?.addEventListener("click", () => goTo(findNext(current, -1)));
|
||||
next?.addEventListener("click", () => goTo(findNext(current, 1)));
|
||||
|
|
@ -45,4 +64,4 @@ if (slideshow) {
|
|||
goTo(findNext(current, 1));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue