I'm stacking 5 images by attributing to all of them an absolute position with the same top and left coordinates and a different z-index.
My goal is to rotate, translate and turn to 0 the opacity of the image having the highest z-index and increasing by 1 the z-index of all the other images. I'm animating the image having the highest index with CSS transfomations and I change the z-index of the other images with jquery. My code is the following:
var i = 1;
function swypeStyle(){
  var imageLength = $('.my-image').length;
  $('.my-image').each(function(){
    $(this).removeClass('rotated');
  });
  $("#image"+i).addClass('rotated'); 
  setTimeout(function(){
    for(var j = 1; j <= imageLength; j++){
      var currentZindex = $('#image'+j).css('z-index');
      if(currentZindex == imageLength){
        currentZindex = 1;
      }else{
        currentZindex++;
      }
      $('#image'+j).css('z-index',currentZindex);
    }
  }, 1100);
  if(i == imageLength){
    i = 1;
  }else{
    i++;
  }
}
window.setInterval(function () {
 swypeStyle(); 
}, 3000);.my-image{
  width: 144px;
 left: 0px;
  top: 0px;
  position: absolute;
}
.my-image.rotated {
 left: -150px;
 top: 25px; 
 -webkit-transform: rotate(-30deg);
 opacity: 0;
 -webkit-transition: all 1s ease-in-out;
}<img src="https://www.otop.sg/retailer/images/image1.jpg" class="my-image" id="image1" style="z-index: 5;">
<img src="https://www.otop.sg/retailer/images/image2.jpg" class="my-image" id="image2" style="z-index: 4;">
<img src="https://www.otop.sg/retailer/images/image3.jpg" class="my-image" id="image3" style="z-index: 3;">
<img src="https://www.otop.sg/retailer/images/image4.jpg" class="my-image" id="image4" style="z-index: 2;">
<img src="https://www.otop.sg/retailer/images/image5.jpg" class="my-image" id="image5" style="z-index: 1;">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>My animation works well, the problem is when I switch and spend some time on an other chrome tab and when I go back on my script chrome tab there's a lag between my css animation and my jquery animation.
 
     
    