<div id="anime-demo">
  <div class="line">
    <div class="square"></div>
    <div class="square"></div>
    <div class="square"></div>
    <div class="square"></div>
    <div class="square"></div>
  </div>
</div>
<div class="controls">
<button class="play-translate">Animate Translation</button>
<button class="play-scale">Animate Scaling</button>
<button class="play-rotate">Animate Rotation</button>
<button class="play-radius">Animate Border Radius</button>
<button class="play-all">Animate Everything</button>
</div>
body {
  margin: 20px;
  font-family: 'Lato';
  font-weight: 300;
  font-size: 1.2em;
  text-align: center;
}

button {
  background: orange;
  color: white;
  margin: 5px;
  padding: 10px;
  border-radius: 4px;
  font-family: 'Lato';
  cursor: pointer;
  border: none;
  outline: none;
}

button:hover {
  background: blue;
}

.square {
  pointer-events: none;
  position: relative;
  width: 80px;
  height: 80px;
  background-color: black;
  margin: 16px;
  display: inline-block;
  border: 8px solid orange;
}

.controls {
  margin-top: 300px;
}
var uniqueTranslation = anime({
  targets: '.square',
  translateY: function(el, i) {
    return 50 + 50 * i;
  },
  autoplay: false
});

var randomScaling = anime({
  targets: '.square',
  scale: function(el, i) {
    return Math.random()*1.5 + i/10;
  },
  autoplay: false
});

var randomRotation = anime({
  targets: '.square',
  rotate: function() {
    return anime.random(-180, 180);
  },
  autoplay: false
});

var randomRadius = anime({
  targets: '.square',
  borderRadius: function(el) {
    return 20 + Math.random()*el.offsetWidth/4;
  },
  autoplay: false
});

var randomAll = anime({
  targets: '.square',
  translateY: function(el, i) {
    return 50 + 50 * i;
  },
  scale: function(el, i) {
    return Math.random()*1.5 + i/8;
  },
  rotate: function() {
    return anime.random(-180, 180);
  },
  borderRadius: function(el) {
    return Math.random()*el.offsetWidth/2;
  },
  duration: function() { return anime.random(1500, 2400); },
  delay: function() { return anime.random(0, 1000); },
  autoplay: false
});

document.querySelector('.play-translate').onclick = uniqueTranslation.restart;
document.querySelector('.play-scale').onclick = randomScaling.restart;
document.querySelector('.play-rotate').onclick = randomRotation.restart;
document.querySelector('.play-radius').onclick = randomRadius.restart;
document.querySelector('.play-all').onclick = randomAll.restart;

External CSS

  1. https://fonts.googleapis.com/css?family=Lato:300

External JavaScript

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