Well, I'm creating a Carousel, but it has reached a point where I crashed for not knowing how to do it, I need to create an infinite loop between the items inside the carousel, how can I accomplish this?
Follow the code you've created so far
JS
function carousels(){
//Capturar os carousels na page
var carousels = document.querySelectorAll(".carousel");
//Captura tamanho da tela
var windowWidth = window.innerWidth;
//Abrir função para cada um
for(var iCarousels = 0; iCarousels < carousels.length; iCarousels++){
var bannersIn = carousels[iCarousels].querySelectorAll("figure");
carousels[iCarousels].style.width = bannersIn.length * windowWidth + "px";
for(var iBannersIn = 0; iBannersIn < bannersIn.length; iBannersIn++){
bannersIn[iBannersIn].style.width = windowWidth + "px";
}
setInterval(function(){
}, 2000)
}
}carousels();
CSS
.banner-holder {
width:100%;
height:100%;
position:relative;
overflow:hidden;
}
.banner-holder .carousel {
height:100%;
position:absolute;
display:flex;
transition:all 1s ease-out;
}
.banner-holder .carousel figure {
position:relative;
overflow:hidden;
height:100%;
display:flex;
align-items:center;
}
.banner-holder .carousel img {
min-width:100%;
position:absolute;
height:100%;
left:50%;
top:50%;
transform:translate(-50%,-50%);
}
HTML
<div class="banner-holder">
<div class="carousel">
<figure>
<img src="assets/site/banners/banners_00.jpg">
<figcaption>
</figcaption>
</figure>
<figure>
<img src="assets/site/banners/banners_01.jpg">
<figcaption>
</figcaption>
</figure>
<figure>
<img src="assets/site/banners/banners_02.jpg">
<figcaption>
</figcaption>
</figure>
</div>
</div>