Rotator content not showing the last block. How to fix?

This display of banners. Prints 2 to a page. Everything is OK, only not showing the last banner. Ie goes like this:
1 1
2 2
3
var i = 0;
$(".banner > img").hide()
 console.log($(".banner > img").length);
 var rotator = setInterval(function(){
 $(".banner > img").hide();
 $(".banner > img").eq(i*2+1).show();
 $(".banner > img").eq(i*2+2).show();
i++;
console.log(i);
 if(i == 3){
console.log("end");
i=0;
 } 
}, 2000);


HTML:
<li class="item first">
 <img width="100%" alt class="loaded" style="left: 0px;" id="item1">
</li>
<li class="item">
 <img width="100%" class="loaded" style="left: 0.15 px;" id="item1">
</li>
 <li class="item">
 <img width="100%" alt class="loaded" style="left: 0.15 px;" id="item1">
</li>
<li class="item">
 <img width="100%" class="loaded" style="left: 0.15 px;" id="item1">
</li>
<li class="item">
 <img width="100%" class="loaded" style="left: 0.15 px;" id="item1">
</li>
<li class="item">
 <img width="100%" class="loaded" style="left: 0.15 px;" id="item1">
</li>
September 26th 19 at 07:25
1 answer
September 26th 19 at 07:27
Solution
Judging by the code, never shown the first, not the last banner because eq(0).show() this code will not get called ever.
Yes. exactly, put i=-1, everything is OK - virginie.Abbott commented on September 26th 19 at 07:30
Nicer would be if the initial i to write 0, remove +1 and swap +2 to +1. - Melyssa commented on September 26th 19 at 07:33
Or even this: $(".banner > img").eq(i*2).show().next().show(); - Melyssa commented on September 26th 19 at 07:36
as, ksat, damping effect and slow the appearance better to do? if you do fadeIn fadeOut, they twitch. It is unclear why - virginie.Abbott commented on September 26th 19 at 07:39
XS should work fine.. - Melyssa commented on September 26th 19 at 07:42
for a smooth animation can use this decision - daneden.github.io/animate.css
for dynamic elements to add/remove classes. - Margaret_Gulgowski commented on September 26th 19 at 07:45

Find more questions by tags HTMLJavaScriptjQuery