<div id="elems">
  <div class="box elem"></div>
  <div class="box elem"></div>
  <div class="box elem"></div>
</div>
.box{
  background-color: #ea0f9b;
  width: 50px;
  height: 50px;
  margin-bottom: 20px;
}
var difDuration = anime({
  targets: '#elems .elem',
  translateX: 250,
  loop: true,
  direction: 'alternate',
  duration: function(elem, i) {
    return 1500 + (i * 500);
  }
});

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/animejs/2.2.0/anime.min.js