pedf
/
spolky
Archived
1
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

67 lines
1.9 KiB
JavaScript

5 years ago
function rafAsync() {
return new Promise(resolve => {
requestAnimationFrame(resolve); //faster than set time out
});
}
function checkElement(selector) {
if (document.querySelector(selector) === null) {
return rafAsync().then(() => checkElement(selector));
} else {
return Promise.resolve(true);
}
}
var slideIndex = 1;
4 years ago
var slideIndex2 = 1;
var slideIndex3 = 1;
5 years ago
// Next/previous controls
4 years ago
function plusSlides(n, className = "mySlides", counter = "slideIndex", dotclass = "dot") {
5 years ago
console.log("changing slides");
4 years ago
showSlides(window[counter] += n, className, counter, dotclass);
5 years ago
}
// Thumbnail image controls
4 years ago
function currentSlide(n, className = "mySlides", counter = "slideIndex", dotclass = "dot") {
showSlides(window[counter] = n, className, counter, dotclass);
5 years ago
}
4 years ago
function showSlides(n, className = "mySlides", counter = "slideIndex", dotclass = "dot") {
5 years ago
var i;
5 years ago
var slides = document.getElementsByClassName(className);
4 years ago
var dots = document.getElementsByClassName(dotclass);
if (n > slides.length) {window[counter] = 1}
5 years ago
if (n < 1) {slideIndex = slides.length}
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" carousel-active", "");
}
4 years ago
slides[window[counter]-1].style.display = "block";
dots[window[counter]-1].className += " carousel-active";
}
5 years ago
checkElement('.mySlides') //use whichever selector you want
.then((element) => {
console.log("sldaldsaldsa");
showSlides(slideIndex);
});
5 years ago
checkElement('.mySlides2') //use whichever selector you want
.then((element) => {
console.log("sldaldsaldsa");
4 years ago
showSlides(slideIndex2, "mySlides2", "slideIndex2");
5 years ago
});
checkElement('.mySlides3') //use whichever selector you want
.then((element) => {
console.log("sldaldsaldsa");
4 years ago
showSlides(slideIndex3, "mySlides3", "slideIndex3");
5 years ago
});