It's a passing carousel, but the only way I was able to do it was like this: when it arrives on the last slide, it goes back to the first, doing a sort of "return transition" at the beginning.
Question: I would like the slides to be in infinite loop. That in the end, the first would push the last, if you understand me. If you have any questions, please comment that I will try to explain further and edit the question.
Code below:
$(function(){
//número do slide atual (1 porque pega do primeiro e vai incrementando)
var controller = 1;
//identifica o número de slides (<li>)
var numSlides = $('.carrossel .item').length;
// tempo de transição
var time = 600;
//loop que gerencia a troca de slides
setInterval(function(){
//se o slide atual não for o último, anima para o próximo
if(controller < numSlides){
//animação do trilho para o próximo slide
$('.carrossel').animate({
'margin-left': '-'+controller*300+'px'
}, time);
//incrementa a var controller ao passar um slide
controller ++;
}
//se o slide atual for o último, anima para o primeiro
else{
//zera o margin-left do trilho de slides (ul)
$('.carrossel').animate({
'margin-left': '0px'
}, time/2);
//volta o controller para 1
controller = 1;
}
}, time+2500);
})
* {
margin: 0;
padding: 0;
border: 0;
list-style: none;
box-sizing: border-box;
}
.box-carrossel {
width: 300px;
margin: 10% auto;
position: relative;
background: #fff;
box-shadow: 0 0 5px 1px black;
overflow: hidden;
}
.carrossel {
width: 1000%;
background: #fff;
float: left;
list-style: none;
}
.carrossel .item {
float: left;
width: 300px;
background: #2E9ABE;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><divclass="box-carrossel">
<ul class="carrossel">
<li class="item">slide 1<img src="http://i.imgur.com/9uibBZz.png"/></li><liclass="item">slide 2<img src="http://i.imgur.com/SN10FH8.png"/></li><liclass="item">slide 3<img src="http://i.imgur.com/3Mgc4kt.png"/></li><liclass="item"> slide 4<img src="http://i.imgur.com/eeGWPqv.png"/></li><liclass="item">slide 5<img src="http://i.imgur.com/SN10FH8.png" /> </li>
</ul>
</div>