When urgent the buttons to alter picture on iOS nothing occurs. On Chrome and Android it really works as anticipated.
I’ve tried so as to add eventListener touchstart
, rearranged variables (scope) and misc. different issues however I can not get it to work.
if (doc.querySelector(".slider-img-container") !== null) {
const prev = doc.querySelector(".prev");
const subsequent = doc.querySelector(".subsequent");
const pictures = doc.querySelector(".slider-img-container").kids;
const totalImages = pictures.size;
let index = 0;
if (pictures.size > 1) {
prev.addEventListener("click on", () => {
nextImage("subsequent");
});
subsequent.addEventListener("click on", () => {
nextImage("prev");
});
prev.addEventListener("touchstart", () => {
nextImage("subsequent");
});
subsequent.addEventListener("touchstart", () => {
nextImage("prev");
});
}
operate nextImage(route) {
if (route === "subsequent") {
index++;
if (index === totalImages) {
index = 0;
}
} else {
if (index === 0) {
index = totalImages - 1;
} else {
index--;
}
}
for (let i = 0; i < pictures.size; i++) {
pictures[i].classList.take away("exhibiting");
}
pictures[index].classList.add("exhibiting");
}
}
Thanks upfront for any assist!
Added eventlisteners, . The buttons nonetheless do not do something on iOS.