Fixed home slideshow + new version page infos
All checks were successful
Deploy / Deploy to Production (push) Successful in 7s
All checks were successful
Deploy / Deploy to Production (push) Successful in 7s
This commit is contained in:
parent
9a615bd92d
commit
6bfd9ae262
22 changed files with 755 additions and 603 deletions
|
|
@ -1,22 +1,25 @@
|
|||
const slideshow = document.getElementById("home-slideshow");
|
||||
|
||||
if (slideshow) {
|
||||
const items = [...slideshow.querySelectorAll(".slide")];
|
||||
const prev = slideshow.querySelector(".prev");
|
||||
const next = slideshow.querySelector(".next");
|
||||
let current = 0;
|
||||
|
||||
function isDesktopOnly(index) {
|
||||
return (
|
||||
window.innerWidth < 1000 &&
|
||||
items[index].classList.contains("desktop-only")
|
||||
);
|
||||
function isPortrait() {
|
||||
return window.innerHeight > window.innerWidth;
|
||||
}
|
||||
|
||||
function isSkipped(index) {
|
||||
const el = items[index];
|
||||
if (isPortrait() && el.classList.contains("desktop-only")) return true;
|
||||
if (!isPortrait() && el.classList.contains("mobile-only")) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function findNext(from, direction) {
|
||||
let index = (from + direction + items.length) % items.length;
|
||||
let steps = 0;
|
||||
while (isDesktopOnly(index) && steps < items.length) {
|
||||
while (isSkipped(index) && steps < items.length) {
|
||||
index = (index + direction + items.length) % items.length;
|
||||
steps++;
|
||||
}
|
||||
|
|
@ -35,4 +38,11 @@ if (slideshow) {
|
|||
|
||||
prev?.addEventListener("click", () => goTo(findNext(current, -1)));
|
||||
next?.addEventListener("click", () => goTo(findNext(current, 1)));
|
||||
}
|
||||
|
||||
// Recalculer la slide active si on tourne l'écran
|
||||
window.addEventListener("orientationchange", () => {
|
||||
if (isSkipped(current)) {
|
||||
goTo(findNext(current, 1));
|
||||
}
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue